Game Development Community

about torque excute a file

by james mathw · in Technical Issues · 06/18/2011 (4:55 am) · 12 replies

Hi morning everybody I need ask a more important question,I try to know the information of how Torque excute programm,start from which statement? as you know we use Exec() function to excute a file(gui,cs).use as this :Exec("./misc/camera.cs");but actually in camera.cs file we write so many function within it,therefore Torque will excute misc/camera.cs file from which function and which statement?please explain How torque step by step excute that file very detail?thanks for your help.

#1
06/18/2011 (9:33 am)
Find where other files in the same folder are executed. Do a search for the exec for those files, then execute your gui.
#2
06/18/2011 (7:40 pm)
did you mean first search and excute other files in the same folder,and then excute the gui file?is that correct?
#3
06/19/2011 (8:28 am)
Micheal I re-read your comment again,I feeling you was los a important thing not tell me,you say find where other file in same folder are excuted,but excute other files in which file's same folder?
#4
06/19/2011 (10:39 am)
1. Put the new file you want to execute in a folder with other similar files
2. Search in the scripts where those other files are executed
3. Execute your new file in the same script
#5
06/19/2011 (11:32 am)
Hi micheal thanks! I have truly understand some, but please give me more information of step 2 and tell me detail about "in the scripts "and "in the same script"is mean what?which script?
#6
06/19/2011 (12:46 pm)
There is no specific script. You have to pick one. It can be anywhere.
#7
06/19/2011 (6:08 pm)
micheal I think I have hard to just read comment to understand,please give me a example show pick up a script and use it.
#8
06/20/2011 (2:07 am)
The execution starts from main.cs in your project's root folder. You can trace the flow from that file onwards.
#9
06/20/2011 (2:30 am)
Thanks dmitry,but did you know how torque excute that main.cs and other files,there is no function call main.cs,just have some exec function,but
not all.how torque excute them?
#10
06/20/2011 (9:49 am)
The root main.cs is looked for directly by the engine. Inside that main.cs you will find some functions that load things like $defaultGame and common, or core. These directories/mods are initialized with another main.cs script file inside said directory. Notice how things are branching like a tree? Follow the branches and you will find other main.cs or init.cs script files that load additional stuff. Your custom script should be exec'd somewhere inside the $defaultGame mod - you'll see where.

You can turn on trace() inside of main.cs and then watch the console and you will see the loadup and execution of your game step by step.
// add this to main.cs or anywhere you wish to start tracking program flow
trace(1);
#11
06/20/2011 (12:51 pm)
I follow the branch tree as you mentioned,and I find a gui file,in this file just have lit bit objects,no a function call how to excute
it?I trace it,but I can't understand the trace information.
#12
06/20/2011 (2:46 pm)
GUI files contain data representing the properties of a certain GUI element. Somewhere else within the scripts that GUI data is being looked for and instantiated. Take the name of your GUI declaration and do a 'find-in-files" search and you'll find every instance in your game scripts that specific GUI data is being used. The same principle works for finding script execution as well: search for any given filename and you'll find where that file is exec'd from.

Trace does indeed return a lot of information. It's deep and complex seeming, but is a great way to see the 'flow' in operation.