Game Development Community

Referencing Datablocks

by Jeremy Noetzelman · in Torque Game Engine · 09/18/2001 (7:31 am) · 6 replies

Sorry if this is a FAQ...

How do I reference datablocks from inside a datablock?

datablock a {
[...]
};

datablock b {
datablock_a_instance = a;
};

I want to be able to access data and variables in a via b.

confusing enough?

#1
09/18/2001 (9:31 am)
example:
class LinkedListNode {

LinkedListNode *next;

...
};
Either that or...
class Foo {

friend class Bar;

};
Then Bar objects can access private members inside Foo objects.
#2
09/18/2001 (9:55 am)
Umm... don't think you can do that in Scripting Pat.

Now if you're wanting to inherit from a base datablock you would do something like this:

datablock PlayerData(a){
...
...
// Data specific to a and shared with b here
...
...
};

datablock PlayerData(b) : a
{
...
...
// Data specific to datablock b here
...
...
};
#3
09/19/2001 (2:56 am)
scripting, Pat, not C++ :P datablock != class
#4
09/19/2001 (8:21 am)
There is no support for datablock or class inheritance in the scripting language. LabRat's example is a copy constructor. The variables from a are copied into b. Subsequent changes in a's variables will not reflected in b's copies.
#5
09/19/2001 (6:48 pm)
I never modify a datablock after the initial load anyway.

Thank you for correcting me on that though... was how someone had explained the reason for the databloc type(foo) : bar once
#6
09/20/2001 (1:33 am)
Oops, sorry, I thought this was talking about the DataChunker class in v12 =P