Game Development Community

Get all global varibles

by Konik · in Torque Game Builder · 11/15/2012 (5:50 am) · 4 replies

Hello, please tell me how to get a list of all global variables, and how you can get a list of class variables (for example Player ::).

Thanks for the help

#1
11/15/2012 (7:38 am)
Perhaps TorqueScript is different, but usually one of the main disadvantages of global variables in any language is that since there is nothing above them in the object hierarchy, there's no way to reference them all using the same function.

About the other question, make an object of type Player. then do:

error("*************************************")
%object.dump()
error("*************************************")

And all the objects fields and methods will be printed to the console between red asterisk.

If you know the name of a scene object that has Player somewhere in its class structure, the you can open the console and do:

[insert name of player object].dump()
#2
11/15/2012 (9:17 am)
Thank you very much, what I need! Can you even tell how to delete a global variable? For example $ a = 10, how to remove $ a list of global variables?
#3
11/15/2012 (11:02 pm)
@Konik, you can't delete global varies as such I believe. But you could just say $a = "" or something else to indicate to your code that it should treat it as deleted.
#4
11/17/2012 (8:41 am)
+1 to Lukas.

The value to "nullifying" the value of a global variable like Lukas suggests is obvious errors when the global gets referenced again.

In other words, sometimes, you might consider it good to tell your program that you're done with a certain global, but if it gets referenced again, after being set to a null string, it will throw an error, alerting you that your program did not behave exactly how you thought it was.