Post tutorial RSS How to Execute a File

Teaches the very basics of scripts used by TGE, and explains how to get files authored by you for modding recognized and loaded into the game's active working memory. Adapted from a similar tutorial on the forum by EmperorWiggy.

Posted by on - Intermediate Client Side Coding

There are two types of script files used by the Torque Game Engine:

1) .cs: These are the 'source code' files. These are the files one opens up, modifies, and generally changes.

2) .dso: These are the compiled forms of the .cs's. These are not used by the user. Torque Game Engine, when asked to exec a file, uses the compiled .dso file, because that is what it reads. If there is no .dso file, TGE compiles the .cs file into a .dso and uses that.

Anyways, to properly exec a script:

1) First confirm you have made the proper changes to the .cs file. Confirm that you have made all the necessary changes, and check it for any syntax errors or missing semicolons.

2) Now, to exec the file. There are two methods to do so:
a) The simpler method: Restart TOB. When the engine opens it compiles everything the game uses. This has its downsides (i.e., when running a server, doing this closes the server), but it is certainly easier.
b) The faster method: Manually exec the file. Go to the console and type:

Code:

exec("filelocation.cs");



Replace filelocation with the file's location, such as

Code:

exec("dtb/server/scripts/game.cs");



This is definitely faster, and thus is the recommended method. It's also easier to find errors using the console.

3) If something goes wrong, open the console. It should give you an error location. Use that to locate and fix the error and re-exec the file.

Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.