home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Singles (French)
/
Singles-FrenchVersion-Win95.iso
/
data1.cab
/
Statemachine
/
phone.lua
< prev
next >
Wrap
Text File
|
2004-03-05
|
5KB
|
137 lines
-- camera state machine
beginStateMachine()
onMsg("buildMenu", function(msg)
if (repairMenu()) then return end
-- build the pie menu
clearPieMenu();
button = addPieMenuButton("pm_callFriends", "callFriends");
button.addDescription(ACTIVITY, "callFriends");
button = addPieMenuButton("pm_callPizza", "callPizza");
button.addDescription(ACTIVITY, "eatPizza");
--button = addPieMenuButton("pm_callOffice", "callOffice");
-- button.addDescription(ACTIVITY, "callOffice");
end )
--
onMsg("callFriends", 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.getFreeActionPoint(this, "use");
local actionPoint = character.getClosestFreeActionPoint(character, this, {"use1", "use2", "use3", "use4"});
if (actionPoint) then
-- get the walk state object
local wso = character.walkSO;
if (wso.walkToActionPoint(actionPoint)) then
-- create state machine contexts
local wsoContext = StateMachineContext();
-- store the action point
wsoContext.storeData("actionPointName", actionPoint.getName());
wso.queueStateMachine("phoneChar.callFriendsStart", 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
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 )
onMsg("callPizza", 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.getFreeActionPoint(this, "use");
local actionPoint = character.getClosestFreeActionPoint(character, this, {"use1", "use2", "use3", "use4"});
if (actionPoint) then
-- get the walk state object
local wso = character.walkSO;
if (wso.walkToActionPoint(actionPoint)) then
-- create state machine contexts
local wsoContext = StateMachineContext();
-- store the action point
wsoContext.storeData("actionPointName", actionPoint.getName());
wso.queueStateMachine("phoneChar.callPizzaStart", 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
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 )
-- onMsg("callOffice", function(msg)
-- -- get the game object server
-- local gameObjectServer = getGameObjectServer();
-- -- get character who initiated this action
-- local character = getStateObjectFromID(msg.sender);
-- -- walk to the closest action point
-- local actionPoint = character.getFreeActionPoint(this, "use");
-- if (actionPoint) then
-- -- get the walk state object
-- local wso = character.walkSO;
-- if (wso.walkToActionPoint(actionPoint)) then
-- wso.queueStateMachine("phoneChar.callOffice", this);
-- 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()