Loading Level problem
by Benjamin L. Grauer · in Torque Game Builder · 10/03/2006 (7:54 pm) · 7 replies
When i'm trying to load a level I get "Error loading level ~/data/levels/level.t2d. Invalid file."
Here's the script for changing level.
The error "Error loading level ~/data/levels/level.t2d. Invalid file." is occuring with any of my levels.
Am I missing something ?
Here's the script for changing level.
function levelload(%level)
{
sceneWindow2D.endlevel();
if( isFile( %level ) || isFile( %level @ ".dso"))
{
sceneWindow2D.loadLevel(%level);
}
}The error "Error loading level ~/data/levels/level.t2d. Invalid file." is occuring with any of my levels.
Am I missing something ?
#2
I see "loading ~/data/levels/level.t2d." but still "Error loading level ~/data/levels/level.t2d. Invalid file." and nothing happen, the level doesn't load. But the file I specify does exist and load well in level builder Oo
This is ALL what I wrote for loading the level, nothing more, did I forgot something important ?
Is calling this function simply "function levelload(%level)" is correct ?
10/03/2006 (8:41 pm)
I tried like this :function levelload(%level)
{
sceneWindow2D.endlevel();
if( isFile( %level ) || isFile( %level @ ".dso"))
{
echo("loading ", %level);
sceneWindow2D.loadLevel(%level);
}else
warn("level ", %level, " doesn't exist");
}I see "loading ~/data/levels/level.t2d." but still "Error loading level ~/data/levels/level.t2d. Invalid file." and nothing happen, the level doesn't load. But the file I specify does exist and load well in level builder Oo
This is ALL what I wrote for loading the level, nothing more, did I forgot something important ?
Is calling this function simply "function levelload(%level)" is correct ?
#3
Just a hunch that the engine isn't recognizing the directory you are specifying in your call to loadLevel.
Here is some of my code that works
10/03/2006 (8:46 pm)
Try adding the debug code to levelManagement.cs as I suggested- my guess is you will see instead of of "~/data/..." you will see YourGame/data/levels/levlel.t2dJust a hunch that the engine isn't recognizing the directory you are specifying in your call to loadLevel.
Here is some of my code that works
sceneWindow2D.loadLevel( %pOwner.getNextLevel() );
#4
10/03/2006 (8:48 pm)
Where getNextLevel is returning a string like "MLEggs/data/levels/L2.t2d"
#5
Well, it works ^^
It seems that "~" is a little fishy, its strange that the "is level" command doesn't stop on it.
Thanks Alex ^^
10/03/2006 (8:50 pm)
"YourGame/data/levels/levlel.t2d"Well, it works ^^
It seems that "~" is a little fishy, its strange that the "is level" command doesn't stop on it.
Thanks Alex ^^
#6
Happy dev-ing!
10/03/2006 (10:15 pm)
I also ran into this. Here is the solution (using the original function):function levelload( %level )
{
sceneWindow2D.endlevel();
if( isFile( %level ) || isFile( %level @ ".dso") )
{
sceneWindow2D.loadLevel( expandFilename( %level ) ); // <- expandFilename call translates the ~
}
}Happy dev-ing!
#7
10/06/2006 (10:46 pm)
Nice. That expandFilename function saved me alot of research.
Torque Owner Alex Rice
Default Studio Name
function t2dSceneWindow::loadLevel(%sceneWindow, %levelFile) { warn("loading level" SPC %levelFile); ...Then look at the output when you load/unload levels in TGB level builder. Then use those same path-strings in your coding.