Game Development Community

Function for Level Name

by UAT (#0025) · in Torque Game Builder · 09/27/2007 (11:24 pm) · 2 replies

I need a function to find what the level name is. I can make one, but would rather use a pre-built one. I looked through the documentation for it, but couldn't find anything like that.

Do you know any functions that return the current level name?

About the author

Recent Threads


#1
09/28/2007 (2:50 am)
I couldn't find a function to return name of the last level loaded. Here is a solution for you, or you can do your own.

Add to common/gameScripts/levelManagement.cs:
//This holds the name of the last level loaded.
$lastLevelName = "";
function getLastLevelLoaded()
{
   return fileName($lastLevelName);
}
Note: The fileName() function strips all the proceeding path from the string, you may wish to compare the path as well. If so modify this to return the global directly.

And to within the function:
function t2dSceneWindow::loadLevel(%sceneWindow, %levelFile)
under the line
$lastLoadedScene = %scenegraph;
Add
$lastLevelName = %levelFile;

Gabriel
#2
09/29/2007 (10:23 pm)
Thank you very much. It works perfectly!