home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Singles (French)
/
Singles-FrenchVersion-Win95.iso
/
data1.cab
/
Statemachine
/
kommode.lua
< prev
next >
Wrap
Text File
|
2004-03-05
|
3KB
|
84 lines
-- kommode state machine
beginStateMachine()
onMsg("buildMenu", function(msg)
if (repairMenu()) then return end
-- build the pie menu
clearPieMenu();
-- get character who initiated this action
local character = getStateObjectFromID(msg.sender);
if (character) then
-- get the pie menu buttons
local outfits = character.getOutfits();
for i = 1, getn(outfits) do
local button;
local outfit = outfits[i];
if not enumCompare(outfit.getID(), character.getOutfit()) then
--print("######### outfitname: "..outfit.getName().." - outfit - "..tostring(outfit.getID()));
button = addPieMenuButton(outfit.getName(), "outfit", tostring(outfit.getID()));
end
-- button.addIcon("guiIconComfort");
end
end
end )
-- change outfit
onMsg("outfit", function(msg)
-- get the game object server
local gameObjectServer = getGameObjectServer();
-- get character who initiated this action
local character = getStateObjectFromID(msg.sender);
-- check if activity if possible
local possible, result, activity = activityPossible(character, msg.name, this);
-- don't care if timeslot is not fulfilled
if (possible or enumCompare(result, TIMESLOT)) then
-- walk to the closest action point
local actionPoint = character.getClosestFreeActionPoint(character, this, {"change1", "change2"});
--local actionPoints = character.getFreeActionPoints(this, {"change1", "change2"});
if (actionPoint) then
-- get the walk state object
local wso = character.walkSO;
if (wso.walkToActionPoint(actionPoint)) then
-- notify current mission
character.sendMsg("outfit", gameObjectServer.mission);
print("walkToActionPoint true");
-- create state machine contexts
local wsoContext = StateMachineContext();
-- store the action point
wsoContext.storeData("actionPointName", actionPoint.getName());
-- store the outfit
wsoContext.storeData("outfit", tonumber(msg.data));
wso.queueStateMachine("kommodeChar.outfit", this, wsoContext);
else
print("no path found for actionpoint " .. actionPoint.getName());
-- character.setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
-- sendMsg("emoThink", character.walkSO);
instantAbort(character, EMOTICON_NOPATH, "emoThink");
end
else
print("no action point found");
-- character.setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
-- sendMsg("emoThink", character.walkSO);
instantAbort(character, EMOTICON_CANNOT, "emoThink");
end
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()