Game Development Community

Use file paths correctly to load files

by Maritn · in iTorque 2D · 05/14/2012 (8:36 am) · 3 replies

I can't get T2D to load files properly, as soon as they are in a different folder than the calling script. E.g. I've got a script in the /script folder, which calls a level file or a gui file from the /level or /gui folder.

Using exec("../projectFiles/gui/mainMenu.gui"); is working fine under windows but does not work anymore as soon as I compile it an Xcode.

How can I tell the exec-function to look in a different folder?

#1
05/14/2012 (11:23 pm)
I use a shorter path, like exec("gui/guifile.gui"); or exec("scripts/filename.cs");
#2
05/14/2012 (11:43 pm)
Try using exec("./../projectFiles/gui/mainMenu.gui");
I believe that would fix it, ./ refers to the file calling the exec where not having it refers to your exe file.
#3
05/15/2012 (7:09 am)
@Lukas: Thankts for this hint!

I got it working this way (when calling from the script-folder):
exec("./../gui/mainMenu.gui");