home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Singles (French)
/
Singles-FrenchVersion-Win95.iso
/
data1.cab
/
Statemachine
/
doublebed.lua
< prev
next >
Wrap
Text File
|
2004-03-05
|
5KB
|
155 lines
-- bed state machine
beginStateMachine()
onMsg("buildMenu", function(msg)
if (repairMenu()) then return end
-- build the pie menu
clearPieMenu();
local button ;
button = addPieMenuButton("pm_sleep", "sleep");
button.addDescription(ACTIVITY, "sleep");
-- can always be selected by user
button.addDescription(ALWAYS_USERSELECTABLE, "true");
local character = getStateObjectFromID(msg.sender);
if (not isUser(character, this, {"lie"})) then
local otherUsers = getOtherUsers(character, this, "lie")
if (getn(otherUsers) > 0) then
local characterInBed = otherUsers[1];
if activityPossible(character, "getIntimateBed", characterInBed) then
button = addPieMenuButton("pm_getIntimateBed", "getIntimateBed");
button.addDescription(ACTIVITY, "getIntimateBed");
else
-- add grayed out
button = addPieMenuButton("pm_getIntimateBed", "getIntimateBed");
button.addDescription(GRAYED_OUT, "true");
end;
end
end
-- local occupants = getCharactersWithActivity("sleep");
-- if (getn(occupants)>0) then
--
-- button = addPieMenuButton("pm_getIntimateBed", "getIntimateBed");
-- button.addDescription(ACTIVITY, "getIntimateBed");
-- --button.addDescription(DONTQUEUE, "true");
-- end
end )
-- get intimate with a bed occupant
onMsg("getIntimateBed", function(msg)
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
local occupants = getOtherUsers(character, this, "lie")
if (getn(occupants) == 0) then
print("doublebed.lua::getIntimateBed no occupants found");
instantAbort(character, EMOTICON_CANNOT, "emoThink");
return
end
local occupant = occupants[1];
character.sendMsg("getIntimateBed", occupant);
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 )
-- get intimate with a bed occupant
onMsg("getIntimateBedShortcut", function(msg)
local character = getStateObjectFromID(msg.sender);
--local occupants = getCharactersWithActivity("sleep");
local occupants = getOtherUsers(character, this, "lie")
if (getn(occupants) == 0) then
print("doublebed.lua::getIntimateBed no occupants found");
--instantAbort(character, EMOTICON_CANNOT, "emoThink");
return
end
local occupant = occupants[1];
character.sendMsg("getIntimateBedShortcut", occupant);
end )
-- lay on bed
onMsg("sleep", 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
-- check if sombody else in bed, and if we can share a bed with him
local occupants = getOtherUsers(character, this, "lie");
if (getn(occupants) > 0) then
local occupant = occupants[1];
if (not activityPossible(character, "inBedTogether", occupant)) then
instantAbort(character, EMOTICON_SHY, "emoRefuseChar", occupant);
return
end
end
-- walk to the closest action point
local actionPoint = character.getClosestFreeActionPointToClickPoint(this, {"layDown1", "layDown2"});
-- 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("doublebedChar.layDown", this, wsoContext);
else
print("no path found");
instantAbort(character, EMOTICON_NOPATH, "emoThink")
end
else
print("doublebed.lua: no action point found of layDown1, layDown2");
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()