Game Development Community

Help me find my way to Pathing

by Kevin James · in Torque Game Builder · 07/24/2006 (7:00 pm) · 4 replies

I have seen various symbols at the beggining of a path to a file. such as "~/" and "./". I have always gotten my pathing right, but I still don't know exactly what these mean. Thanks for the help.

About the author

Computer security, digital forensics, and platform jumper enthusiast. shells.myw3b.net/~syreal/


#1
07/24/2006 (7:15 pm)
When you use "./", your getting a file from the directory your currently in. For example, "game.cs" is in the gameScripts directory. You create a player file and save it in the gameScripts directory. In order to execute the file you type (in game.cs) exec("./player.cs"); because it's in the same directory. ~/ on the other hand, resets to the home directory of the game. More precisely, if you installed in the default directory, it's "C:\Program Files\TorqueGameBuilderPro\games\\". You would use this when your loading a level for example. Level1.t2d is stored in "C:\Program Files\TorqueGameBuilderPro\games\\data\levels\". When you want to load a new level, you would type "~/data/levels/level1.t2d" since it's not in the same directory as the script your calling it from.
Bit of a lengthy explanation, but hopefully it's clear :)
#2
07/25/2006 (5:51 am)
Clear as crystal, you've been a big help again, Apurva. That's kind of what I assumed, but I wanted to make darn sure of it.
#3
07/25/2006 (8:17 am)
Just for future reference, when you do load a level, you would use a different pathname method. I didn't want to edit my explanation above incase of confusion but if you do load a level, do it like this:

function loadNewLevel(){
    sceneWindow2D.loadLevel("<projectname>"/data/levels/myLevel.t2d");
}

Although the "~/" in theory means the same thing, for some reason you have to explicitly define the project name in the path directory. This was discussed in this thread
#4
07/25/2006 (4:10 pm)
Yeah, I'd actually already had read that thread, but thanks for the heads up anyway!