Game Development Community

Arrays in Datablocks?

by Matt "Mr. Pig" Razza · in Torque Game Engine · 06/04/2007 (12:47 pm) · 4 replies

Is it possible to expose an array to a datablock?

I.E. addField();
then in script
datablock foo(bar)
{
foo[1] = bar;
foo[2] = bar;
};

#1
06/05/2007 (8:07 am)
If I remember this right....

Yes... because saying
foo[1]=bar;
is equal to saying
foo_1=bar;
#2
06/05/2007 (8:34 am)
Here's some more info too: tdn.garagegames.com/wiki/TorqueScript#Arrays:
#3
06/05/2007 (8:47 am)
Wow, what an example of people not reading the question properly.

Matt is asking about exposing arrays from code. Matt, you can indeed do this, for example:

addField("splashEmitter",  TypeParticleEmitterDataPtr,   Offset(splashEmitterList,   PlayerData), NUM_SPLASH_EMITTERS);

(from Player.cc)

Where NUM_SPLASH_EMITTERS is the size of the array.

Ian
#4
06/05/2007 (12:20 pm)
@Ian, thank you very much!