Game Development Community

Quick TorqueScript questions

by Richard Skala · in General Discussion · 11/20/2009 (5:44 am) · 2 replies

In TorqueScript examples, I see two different ways to access folders. What are the differences between these two?

"~/gui/mainScreen.gui"
"./gameScripts/game.cs"

That is, what is the result of the tilde and the period before the paths?

Also, are there any good TorqueScript tutorials out there?

Thanks.

#1
11/20/2009 (11:56 am)
The tilde and period are directory navigation helpers. The tilde stands for the current mod directory. The period stands for the parent directory of the executing script. For example, assume you have this directory structure (I don't have TGB, so your structure may be different):

game
 |
 -> scripts
 |     |
 |     -> client
 |     |
 |     -> gui
 |     |
 |     -> server
 |           |
 |           -> gameScripts
 |
 -> art
 |
 -> core

"Game" is the root directory that holds your EXE and "main.cs". Every folder under the root directory is considered a "mod". So in this example, "scripts", "art", and "core" are all mod directories. Let's say there is a file called "init.cs" in the server directory above, and in "init.cs" it execs the two files you mentioned in your post. You can see that "init.cs" exists in the "scripts" mod directory; therefore,

"~/gui/mainScreen.gui" == "game/scripts/gui/mainScreen.gui"

The parent directory of "init.cs" is the "server" directory; therefore,

"./gameScripts/game.cs" == "game/scripts/server/gameScripts/game.cs
#2
11/20/2009 (6:11 pm)
Great explanation -- thanks!