Game Development Community

Declaring global variables

by Corey Magin · in Torque Game Builder · 02/01/2008 (5:04 pm) · 3 replies

Hi,

Where do I declare global variables at? Not sure what file to do this in.

Thanks in advance.

#1
02/01/2008 (5:55 pm)
Torquescript doesn't have variable declaration. You "declare" them whenever you use them for the first time.
#2
02/01/2008 (5:57 pm)
Thank you :D
#3
07/04/2010 (5:57 am)
I understand that Torque "declares" them when they are used, but the problem I have is I end up with globals scattered around the various script files and it makes it impossible to find them (if I want to change their default, initialization value for example). What I do is create a script file named "globals.cs" in /scripts/server. In this file I put all of my global values and a good comment so I remember what they do. Then I put 'exec("./globals.cs");' in /scripts/server/scriptExec.cs. I'm not sure if this would be considered bad practice in Torquescript, but it helps me keep stuff organized.