Advertisement
BloodknightStudios

Untitled

Dec 12th, 2015
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.17 KB | None | 0 0
  1. // Read the level file and find the level object strings, then create the action object via eval so we
  2. // can extract the params from it and load them into global vars
  3. function Torque::getLevelInfo( %this, %missionFile )
  4. {
  5.    %file = new FileObject();
  6.    
  7.    %LevelInfoObject = "";
  8.    
  9.    if ( %file.openForRead( %missionFile ) )
  10.    {
  11.       %inInfoBlock = false;
  12.  
  13.       while ( !%file.isEOF() )
  14.       {
  15.          %line = %file.readLine();
  16.          %line = trim( %line );
  17.          if( %line $= "new ScriptObject(LevelInfo) {" )
  18.             %inInfoBlock = true;
  19.          else if( %line $= "new LevelInfo(theLevelInfo) {" )
  20.             %inInfoBlock = true;
  21.          else if( %inInfoBlock && %line $= "};" ) {
  22.             %inInfoBlock = false;
  23.  
  24.             %LevelInfoObject = %LevelInfoObject @ %line;
  25.             break;
  26.          }
  27.  
  28.          if( %inInfoBlock )
  29.             %LevelInfoObject = %LevelInfoObject @ %line @ " ";
  30.       }
  31.  
  32.       %file.close();
  33.    }
  34.    %file.delete();
  35.  
  36.    if( %LevelInfoObject !$= "" )
  37.    {
  38.       %LevelInfoObject = "%LevelInfoObject = " @ %LevelInfoObject;
  39.       eval( %LevelInfoObject );
  40.  
  41.       return %LevelInfoObject;
  42.    }
  43.    
  44.    // Didn't find our LevelInfo
  45.    return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement