home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Singles (French)
/
Singles-FrenchVersion-Win95.iso
/
data1.cab
/
Statemachine
/
ovenDamaged.lua
< prev
next >
Wrap
Text File
|
2004-03-05
|
3KB
|
89 lines
-- oven state machine
beginStateMachine()
onEnter(function(msg)
local damp = findChildGO("damp");
damp.setEmitRate(0.0);
end )
onMsg("buildMenu", function(msg)
-- here we need a repairMenu that always works
if (repairMenu()) then return end
-- rebuild the pie menu
clearPieMenu()
--if (retrieveData("online")) then
-- addPieMenuButton("pm_switchOff", "switchoff");
--else
addPieMenuButton("pm_switchOn", "switchon");
--end
end )
--
onMsg("switchon", function(msg)
storeData("online", true);
-- get the game object server
local gameObjectServer = getGameObjectServer();
-- get character who initiated this action
local character = getStateObjectFromID(msg.sender);
-- if this is broken: abort characters action
if abortIfBroken(character) then return end;
-- walk to the closest action point
local actionPoint = character.getFreeActionPoint(this, "cook");
if (actionPoint) then
-- get the walk state object
local wso = character.walkSO;
-- create state machine contexts
local wsoContext = StateMachineContext();
-- store the action point
wsoContext.storeData("actionPointName", actionPoint.getName());
if (wso.walkToActionPoint(actionPoint)) then
-- enque action
wso.queueStateMachine("ovenDamagedChar.switchon", this, wsoContext);
else
print("no path found");
instantAbort(character, EMOTICON_NOPATH, "emoThink")
end
else
print("no action point found");
instantAbort(character, EMOTICON_CANNOT, "emoThink")
end
end )
-- repair
onMsg("repair", function(msg)
print("onMsg repair");
-- get character who initiated this action
local character = getStateObjectFromID(msg.sender);
-- walk to the closest action point
local actionPoint = character.getFreeActionPoint(this, "repair");
-- 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("repairChar.repairStart", this, wsoContext);
else
print("no path found");
instantAbort(character, EMOTICON_NOPATH, "emoThink")
end
else
print("no action point found");
instantAbort(character, EMOTICON_CANNOT, "emoThink")
end
end )
endStateMachine()