home *** CD-ROM | disk | FTP | other *** search
/ Singles (French) / Singles-FrenchVersion-Win95.iso / data1.cab / Statemachine / mission.lua < prev    next >
Text File  |  2004-03-05  |  973b  |  45 lines

  1. -- mission controller state machine
  2.  
  3. beginStateMachine()
  4.  
  5.     onEnter(function(msg)
  6.         -- init available missions
  7.         local skipTutorial = (readConfig("Debug", "skipTutorial") == "true");
  8.         local missions = {"testMission","tutorialMoveIn"};
  9.         
  10.         if (skipTutorial) then
  11. print("starting questor");
  12.             missions = {"questor"};
  13.         else
  14. print("starting tutorial");
  15.         end
  16.             
  17.         storeData("missions", missions);
  18.         
  19.         -- start first mission
  20.         sendDelayedMsgThis("next", 1000);
  21.     end )
  22.  
  23.     onReturn(function(msg)
  24.         -- start next mission
  25.         sendDelayedMsgThis("next", 3000);
  26.     end )
  27.     
  28.  
  29.     onMsg("next", function(msg)
  30.         -- mission complete: choose next mission
  31.         print("Mission complete");
  32.         
  33.         local missions = retrieveData("missions");
  34.         if getn(missions) > 0 then
  35.             local m = missions[1];
  36.             tremove(missions, 1);
  37.             storeData("missions", missions);
  38.             
  39.             print("Starting next mission: "..m)
  40.             enterStateMachine(m);
  41.         end
  42.     end )
  43.     
  44. endStateMachine()
  45.