home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Singles (French)
/
Singles-FrenchVersion-Win95.iso
/
data1.cab
/
Statemachine
/
guitarChar.lua
< prev
next >
Wrap
Text File
|
2004-03-05
|
5KB
|
190 lines
-- guitar character state machine
beginStateMachine()
onEnter(function(msg)
local guitarRack = getStateObjectFromID(msg.sender);
storeStateObject("guitarRack", guitarRack);
if (guitarRack) then
-- guitarRack does exist
if exitIfWrongPosition(getParent(), guitarRack, retrieveData("actionPointName")) then return end;
if (getParent().isOneActionPointLocked(guitarRack)) then
-- action point is locked
getParent().setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
sendMsg("emoThink", getParent().walkSO);
exitStateMachine();
else
getParent().lockActionPoints(guitarRack);
end
else
-- guitarRack does not exist anymore
getParent().setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
sendMsg("emoThink", getParent().walkSO);
exitStateMachine();
end
freeHands(getParent());
end )
onExit(function(msg)
freeHands(getParent());
removeStateObject("guitar");
-- local guitarRack = retrieveStateObject("guitarRack");
-- getParent().unlockActionPoints(guitarRack);
-- getParent().stopAllActivities(guitarRack);
-- removeStateObject("guitarRack");
unlockAll("guitarRack");
getParent().stopAllActivities();
end )
state("takeGuitar")
onEnter(function(msg)
--startAnimation("playGuitarLoop");
local guitarRack = retrieveStateObject("guitarRack");
local guitar = guitarRack.createGameObject("guitar");
storeStateObject("guitar", guitar);
getParent().attachLeftObjectHolder(guitarRack, "guitar");
getParent().handSO.setPose("leftHandHoldVert");
setState("lookForSeat");
end )
-- onMsg("queue", function(msg)
-- getParent().detachLeftObjectHolder();
-- exitStateMachine();
-- end )
--
-- onMsg("end", function(msg)
-- if testCancel() then
-- getParent().detachLeftObjectHolder();
-- exitStateMachine();
-- else
-- startAnimation("playGuitarLoop");
-- end
-- end )
-- state("lookForSeat")
-- print("lookForSeat");
--
-- onEnter(function(msg)
-- -- find a sofa to play guitar
-- local seat, actionPoint = getNextReadSit(getParent());
-- if (not seat) then
-- sendMsgThis("noPlaceToPlay");
-- return
-- end
--
-- local wso = getParent().walkSO;
-- if (wso.walkToActionPoint(actionPoint)) then
--
-- -- create state machine contexts
-- local wsoContext = StateMachineContext();
-- wsoContext.storeStateObject("seat", seat);
-- wsoContext.storeStateObject("guitarRack", retrieveStateObject("guitarRack"));
-- wsoContext.storeStateObject("guitar", retrieveStateObject("guitar"));
-- wsoContext.storeData("actionPointName", actionPoint.getName());
--
-- wso.queueStateMachine("sofaGuitarChar.sitDown", this, wsoContext);
-- exitStateMachine();
-- else
-- print("no path found");
-- character.setEmoticon(EMOTICON_NOPATH, EMOTICON_DELAY);
-- sendMsg("emoThink", character.walkSO);
-- sendMsgThis("noPlaceToPlay");
-- end
--
--
--
--
-- end)
state("lookForSeat")
print("lookForSeat");
onEnter(function(msg)
-- find a sofa to play guitar
local seat, actionPoint = getNextReadSit(getParent());
if (not seat) then
sendMsgThis("noPlaceToPlay");
return
end
--local wso = getParent().walkSO;
if (walkToPointImmediate(actionPoint)) then
-- create state machine contexts
-- local wsoContext = StateMachineContext();
-- wsoContext.storeStateObject("seat", seat);
-- wsoContext.storeStateObject("guitarRack", retrieveStateObject("guitarRack"));
-- wsoContext.storeStateObject("guitar", retrieveStateObject("guitar"));
-- wsoContext.storeData("actionPointName", actionPoint.getName());
-- wso.queueStateMachine("sofaGuitarChar.sitDown", this, wsoContext);
-- exitStateMachine();
storeStateObject("sofa", seat);
storeData("actionPointName", actionPoint.getName());
enterStateMachine("subwalk.walk");
else
print("no path found");
character.setEmoticon(EMOTICON_NOPATH, EMOTICON_DELAY);
sendMsg("emoThink", character.walkSO);
sendMsgThis("noPlaceToPlay");
end
end)
onReturn(function(msg)
print("lookForSeat onReturn");
setState("sitAndPlay");
end)
onMsg("noPlaceToPlay", function(msg)
print("no place to play");
-- detach book if attached to left hand
-- getParent().detachLeftObjectHolder();
-- getParent().detachRightObjectHolder();
-- local guitar = retrieveStateObject("guitar");
-- if (guitar) then guitar.deleteGameObject(); end
-- getParent().handSO.stopPose();
getParent().setEmoticon(EMOTICON_NOSOFA, EMOTICON_DELAY);
sendMsg("emoThink", getParent().walkSO);
exitStateMachine();
end)
state("sitAndPlay")
onEnter(function(msg)
print("sitAndPlay onEnter");
storeData("sitState", "playGuitar");
enterStateMachine("sofaChar.sitDown");
-- enterStateMachine("sofaGuitarChar.sitDown");
end)
onReturn(function(msg)
print("sitAndPlay onReturn");
exitStateMachine();
end)
endStateMachine()