Game Development Community

Looping through Datablock values

by Kevin Ostrowski · in Torque Game Engine · 04/27/2003 (4:22 pm) · 4 replies

Maybe I'm just thinking about it all wrong, or maybe it's not possible, but how can I loop through all the values of a datablock in script?

So for example how could I see everything in the wheeledVehicle datablock.

%Db.mass,
%Db.shapeName
and so on...

I have a good idea of how to do it in the engine, but I need to be able to do this script side.

#1
04/28/2003 (11:07 am)
Still having no luck with this... I've searched the forums as well as the code extensively. The only functions I've come across that I though may have been the answer were the getField() and getFieldCount() functions, although after experimenting I don't think that is what I was looking for unless I'm using them incorrectly. Has no one else attempted to do this?
#2
04/28/2003 (12:04 pm)
You can dump a datablock using dump() in the scripts, but I don't know if you can iterate through every variable it contains.
#3
04/28/2003 (12:35 pm)
Yeah, you could look at simobject.cc, ConsoleMethod(SimObject,dump, void, 2, 2, "obj.dump()") and write a similar function doing exactly what you need in script...
That one loops through all the datablock fields and prints the values and usage etc.
#4
04/28/2003 (1:34 pm)
Ahh, I knew there was something... I won't have a chance to dig in to it until later, but a quick look at dump() and I'm pretty sure I can do something with that. Thanks a lot.