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

  1. -- camera state machine
  2.  
  3. beginStateMachine()
  4.  
  5.     onMsg("buildMenu", function(msg)
  6.     
  7.         -- build the pie menu
  8.         clearPieMenu();
  9.         local button;
  10.         button = addPieMenuButton("pm_washDishes", "washDishes");
  11.         button.addDescription(ACTIVITY, "washDishes");       
  12.         button.addDescription(ACTIVITY, "improvePlateTidiness");        
  13.         button.addIcon("guiIconWohnung");
  14.     end )
  15.  
  16.     -- 
  17.     onMsg("washDishes", function(msg)
  18.         -- get character who initiated this action
  19.         local character = getStateObjectFromID(msg.sender);
  20.         
  21.         -- check if activity if possible
  22.         local possible, result, activity = activityPossible(character, msg.name, this);
  23.         
  24.         -- don't care if timeslot is not fulfilled
  25.         if (possible or enumCompare(result, TIMESLOT)) then
  26.             -- get the walk state object
  27.             local wso = character.walkSO;
  28.             local wsoContext = StateMachineContext();
  29.             
  30.             local dishwashers = character.getObjectsWithBehavior("dishwasher");
  31.             local dishwasher = dishwashers[1];
  32.             
  33.             if (dishwasher) then
  34.                 character.pushCommand("pm_washDishes", "washDishes", dishwasher, "");
  35.                 character.popQueueEntry();
  36.             else
  37.                 print("no dishwasher found");
  38.                 instantAbort(character, EMOTICON_CANNOT, "emoThink")
  39.             end
  40.         else
  41.             -- activity not possible
  42.             print(msg.name .. " not possible");
  43.             
  44.             local emoticon;
  45.             if (enumCompare(result, NO_CONDITION)) then
  46.                 emoticon = conditionToEmoticon(activity.getUnfulfilledCondition());
  47.             else
  48.                 emoticon = EMOTICON_CANNOT;
  49.             end
  50.             instantAbort(character, emoticon, "emoThink");    
  51.         end
  52.     end )
  53.             
  54.             
  55. endStateMachine()
  56.