home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Singles (French)
/
Singles-FrenchVersion-Win95.iso
/
data1.cab
/
Statemachine
/
fridgeTabletChar.lua
< prev
next >
Wrap
Text File
|
2004-03-05
|
5KB
|
162 lines
-- fridge character state machine
beginStateMachine()
onEnter(function(msg)
local fridge = getStateObjectFromID(msg.sender);
storeStateObject("fridge", fridge);
if (fridge) then
-- fridge does exist
if exitIfWrongPosition(getParent(), fridge, retrieveData("actionPointName")) then return end;
if (getParent().isOneActionPointLocked(fridge)) then
-- action point is locked
print(" >>>> fridge action point is locked abort by " .. getParent().getCharacterName())
getParent().setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
sendMsg("emoThink", getParent().walkSO);
exitStateMachine();
else
print(" >>>> fridge locked by " .. getParent().getCharacterName())
getParent().lockActionPoints(fridge);
end
else
-- fridge does not exist anymore
print(" >>>> fridge does not exist anymore abort by " .. getParent().getCharacterName())
getParent().setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
sendMsg("emoThink", getParent().walkSO);
exitStateMachine();
end
freeHands(getParent());
end )
onExit(function(msg)
local fridge = retrieveStateObject("fridge");
getParent().unlockActionPoints(fridge);
removeStateObject("fridge");
end )
-- open the fridge
state("open")
onEnter(function(msg)
local fridge = retrieveStateObject("fridge");
-- create the cracker box
--local crackerBox = fridge.createGameObject("CrackerBox");
-- start to open the fridge
startAnimation("openFridge");
fridge.startAnimation("fridge");
-- show the inside of the fridge
fridge.setChildEnable("fridgeIn", true);
-- show the cracker box
--fridge.setChildEnable("CrackerBox", true);
-- send a delayed message for open sound
sendDelayedMsgThis("openSound", 800);
-- send a delayed message for attach
sendDelayedMsgThis("grabBreakfast", 5000);
-- send a delayed message for close sound
sendDelayedMsgThis("closeSound", 6000);
end )
onMsg("openSound", function(msg)
local fridge = retrieveStateObject("fridge");
fridge.playSound("fridgeOpen");
fridge.loopSound("fridgeLoop");
end)
onMsg("grabBreakfast", function(msg)
-- attach cracker box to left hand of character
local fridge = retrieveStateObject("fridge");
--getParent().attachLeftObjectHolder(fridge, "CrackerBox");
-- attach tablet
print("create tablet");
local tabletType = retrieveData("tabletType", "tabletBreakfast");
local tablet = getParent().loadGameObject("StandardGO", tabletType);
storeStateObject("tablet", tablet);
getParent().attachLeftObjectHolder(tablet);
fridge.playSound("fridgeTake");
local hso = getParent().handSO;
if (not hso) then
print("no hands found");
else
hso.setPose("leftHandHold");
end
end)
onMsg("closeSound", function(msg)
local fridge = retrieveStateObject("fridge");
fridge.playSound("fridgeClose");
fridge.stopSound("fridgeLoop");
end)
onMsg("end", function(msg)
print("end")
-- hide the inside of the fridge
local fridge = retrieveStateObject("fridge");
fridge.setChildEnable("fridgeIn", false);
if testCancel() then
-- detach tablet if attached to left hand
local tablet = getParent().getLeftHeldObject();
if (tablet) then
getParent().detachLeftObjectHolder();
tablet.deleteGameObject();
end
local hso = getParent().handSO;
hso.stopPose();
exitStateMachine();
else
setState("lookForChair");
end
end )
onExit(function(msg)
-- getParent().detachObjectAnimator();
end)
-- look for free chair
state("lookForChair")
print("lookForChair");
onEnter(function(msg)
local tablet = retrieveStateObject("tablet");
getParent().handSO.setPose("leftHandHold");
getParent().attachLeftObjectHolder(tablet);
local wsoContext = StateMachineContext();
wsoContext.storeStateObject("tablet", tablet);
wsoContext.storeStateObject("tableObject", tablet);
wsoContext.storeData("chairCommand", "eatByTableChar.sitDown");
wsoContext.storeData("checkPartnerChair", true);
queueStateMachine("tableChairChar.findChair", this, wsoContext);
exitStateMachine();
end)
-- onMsg("noPlaceToEat", function(msg)
-- print("no place to eat");
-- -- detach tablet if attached to left hand
-- getParent().detachLeftObjectHolder();
-- getParent().detachRightObjectHolder();
-- local tablet = retrieveStateObject("tablet");
-- if (tablet) then
-- tablet.deleteGameObject();
-- end
-- local hso = getParent().handSO;
-- hso.stopPose();
--
-- getParent().setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
-- exitStateMachine();
-- sendMsg("emoThink", getParent().walkSO);
-- end)
endStateMachine()