home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Singles (French)
/
Singles-FrenchVersion-Win95.iso
/
data1.cab
/
Statemachine
/
kitchenTable.lua
< prev
next >
Wrap
Text File
|
2004-03-05
|
2KB
|
55 lines
-- table state machine
beginStateMachine()
onMsg("buildMenu", function(msg)
if (repairMenu()) then return end
-- build the pie menu
clearPieMenu();
local button ;
if (this.getDirtiness() > 0.01) then
button = addPieMenuButton("pm_clean", "clean");
button.addDescription(ACTIVITY, "clean");
button.addDescription(ACTIVITY, "improveObjectTidiness");
button.addIcon("guiIconWohnung");
end;
end )
onMsg("clean", function(msg)
-- get the game object server
local gameObjectServer = getGameObjectServer();
-- get character who initiated this action
local character = getStateObjectFromID(msg.sender);
-- if character is too unhappy: abort characters action
if instantAbortIfUnhappy(character, "clean", this) then return end;
-- walk to the closest action point
local actionPoint = character.getClosestFreeActionPoint(character, this, {"chair1", "chair2", "chair3", "chair4", "chair5", "chair6", "front1", "front2"});
-- get the walk state object
local wso = character.walkSO;
if (actionPoint) then
-- create state machine contexts
local wsoContext = StateMachineContext();
-- store the action point
wsoContext.storeData("actionPointName", actionPoint.getName());
if (wso.walkToActionPoint(actionPoint)) then
wso.queueStateMachine("tableChar.clean", this, wsoContext);
else
print("no path found");
--queueNextClean(character);
instantAbort(character, EMOTICON_NOPATH, "emoThink")
end
else
print("no action point found");
--queueNextClean(character);
instantAbort(character, EMOTICON_CANNOT, "emoThink")
end
end )
endStateMachine()