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

  1. -- dishwasher character state machine
  2. beginStateMachine()
  3.     
  4.     onEnter(function(msg)
  5.     
  6.     
  7.         --local dishwasher = getStateObjectFromID(msg.sender);
  8.         local dishwasher = getStoredOrSender("dishwasher", msg)
  9.         storeStateObject("dishwasher", dishwasher);
  10.         
  11.         if (dishwasher) then
  12.             -- dishwasher does exist
  13.             if (getParent().isOneActionPointLocked(dishwasher)) then
  14.                 -- action point is locked
  15.                 getParent().setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
  16.                 sendMsg("emoThink", getParent().walkSO);
  17.                 exitStateMachine();
  18.             else
  19.                 getParent().lockActionPoints(dishwasher);
  20.             end
  21.         else
  22.             -- dishwasher does not exist anymore
  23.             getParent().setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
  24.             sendMsg("emoThink", getParent().walkSO);
  25.             exitStateMachine();
  26.         end
  27.         
  28.         --freeHands(getParent());
  29.                 
  30.     end )
  31.     
  32.     onExit(function(msg)
  33. --        local dishwasher = retrieveStateObject("dishwasher");
  34. --        getParent().unlockActionPoints(dishwasher);
  35. --        getParent().stopAllActivities(dishwasher);
  36. --        removeStateObject("dishwasher");
  37.         
  38.         unlockAll("dishwasher");
  39.         
  40.         getParent().stopAllActivities();        
  41.     end )
  42.     
  43.  
  44.     
  45.  
  46.     state("washDishes")
  47.     
  48.         onEnter(function(msg)
  49.             getParent().handSO.stopAnimation(0.0);
  50.             startAnimation("loadDishwasher", true, 1.0, 0.0);
  51.             local dishwasher = retrieveStateObject("dishwasher");
  52.             dishwasher.startAnimation("dishwasher");
  53.             
  54.             sendDelayedMsgThis("openSound", 1300);
  55.             sendDelayedMsgThis("openSound", 4200);
  56.             sendDelayedMsgThis("dropDishes", 2000);
  57.         end )
  58.         
  59.         onMsg("openSound", function(msg)
  60.             local dishwasher = retrieveStateObject("dishwasher");
  61.             dishwasher.playSound("fridgeOpen");
  62.         end)
  63.         
  64.         onMsg("dropDishes", function(msg)
  65.             local dishHeap = getParent().getRightHeldObject();
  66.             if (dishHeap) then dishHeap.deleteGameObject(); end
  67.             getParent().detachRightObjectHolder();
  68.             getParent().playSound("dishwasherLoad");
  69.             --getParent().playSound("stackPlates");
  70.         end )    
  71.     
  72.  
  73.         onMsg("end", function(msg)
  74.             local dishwasher = retrieveStateObject("dishwasher");
  75.             dishwasher.playSound("dishwasherStart");
  76.             exitAndGoAway();
  77.         end )    
  78.         
  79.  
  80.                 
  81. endStateMachine()
  82.