home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Singles (French)
/
Singles-FrenchVersion-Win95.iso
/
data1.cab
/
Statemachine
/
pool.lua
< prev
next >
Wrap
Text File
|
2004-03-05
|
2KB
|
61 lines
-- pool state machine
beginStateMachine()
onMsg("buildMenu", function(msg)
if (repairMenu()) then return end
-- build the pie menu
clearPieMenu();
local character = getStateObjectFromID(msg.sender);
local button;
local stateMachineName = character.walkSO.getStateMachine().getName();
--print("buildMenu stateMachineName: " .. stateMachineName);
button = addPieMenuButton("pm_enterPool", "enterPool");
button.addDescription(ACTIVITY, "swim");
end )
-- swim
onMsg("enterPool", function(msg)
local character = getStateObjectFromID(msg.sender);
-- check if activity if possible
local possible, result, activity = activityPossible(character, "swim", this);
-- don't care if timeslot is not fulfilled
if (possible or enumCompare(result, TIMESLOT)) then
local entryPoints = this.getEntryPoints(character);
for p = 1, getn(entryPoints) do
print(" entryPoint " .. p);
local actionPoint = entryPoints[p];
-- get the walk state object
local wso = character.walkSO;
if (wso.walkToActionPoint(actionPoint)) then
wso.queueStateMachine("poolChar.sitDown", this);
return
end
end
print("no path found");
instantAbort(character, EMOTICON_NOPATH, "emoThink")
else
-- activity not possible
print(msg.name .. " not possible");
local emoticon;
if (enumCompare(result, NO_CONDITION)) then
emoticon = conditionToEmoticon(activity.getUnfulfilledCondition());
else
emoticon = EMOTICON_CANNOT;
end
instantAbort(character, emoticon, "emoThink");
end
end )
endStateMachine()