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

  1. -- oven character state machine
  2. beginStateMachine()
  3.     
  4.     onEnter(function(msg)
  5.     
  6.         local oven = getStateObjectFromID(msg.sender);
  7.         storeStateObject("oven", oven);
  8.                 
  9.         if (oven) then
  10.             -- oven does exist
  11.             if (getParent().isOneActionPointLocked(oven)) then
  12.                 -- action point is locked
  13.                 getParent().setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
  14.                 sendMsg("emoThink", getParent().walkSO);
  15.                 exitStateMachine();
  16.             else
  17.                 getParent().lockActionPoints(oven);
  18.             end
  19.         else
  20.             -- oven does not exist anymore
  21.             getParent().setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
  22.             sendMsg("emoThink", getParent().walkSO);
  23.             exitStateMachine();
  24.         end        
  25.         
  26.     end )
  27.     
  28.     onExit(function(msg)    
  29.         local oven = retrieveStateObject("oven");
  30.         --oven.setChildEnable("pot", false);
  31.         if (oven) then
  32.             --oven.setChildEnable("spoon", false);
  33.             getParent().unlockActionPoints(oven);
  34.             removeStateObject("oven");
  35.         end
  36.     end )
  37.     
  38.     state("switchon")
  39.         onEnter( function(msg)
  40.             local oven = retrieveStateObject("oven");
  41.             --oven.setChildEnable("pot", false);
  42.             if (oven) then            
  43.                 --notify mission that the character damaged on the oven
  44.                 getParent().sendMsg(
  45.                     "on",
  46.                     getParent().getGameObjectServer().mission, 
  47.                     tostring(oven.getUniqueID()) );
  48.                 --oven.setBroken(true);
  49.                 --oven.gotoStateMachine("oven");
  50.                 --oven.enterStateMachine("oven");
  51.             end
  52.             exitStateMachine();
  53.         end )
  54.     
  55.     
  56. endStateMachine()
  57.