home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Singles (French)
/
Singles-FrenchVersion-Win95.iso
/
data1.cab
/
Statemachine
/
toiletChar.lua
< prev
next >
Wrap
Text File
|
2004-03-05
|
6KB
|
242 lines
-- toilet character state machine
beginStateMachine()
onEnter(function(msg)
print("toilet character state machine onEnter");
local toilet = getStateObjectFromID(msg.sender);
storeStateObject("toilet", toilet);
if (toilet) then
--toilet does exist
local actionPointName = retrieveData("actionPointName");
if exitIfWrongPosition(getParent(), toilet, actionPointName) then return end;
if (getParent().isOneActionPointLocked(toilet)) then
-- action point is locked
getParent().setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
sendMsg("emoThink", getParent().walkSO);
exitStateMachine();
else
getParent().lockActionPoints(toilet);
end
else
-- chair does not exist anymore
getParent().setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
sendMsg("emoThink", getParent().walkSO);
exitStateMachine();
end
freeHands(getParent());
end )
onExit(function(msg)
local toilet = retrieveStateObject("toilet");
getParent().unlockActionPoints(toilet);
getParent().stopAllActivities(toilet);
toilet.setChildEnable("stink", false);
removeStateObject("toilet");
getParent().enableBlend(false);
end )
-- sit down on toilet
state("sitDown")
onEnter(function(msg)
local character = getParent();
local other, result = getDisturbingChar(character, "showNaked");
if (other) then
exitStateMachine();
character.setEmoticon(EMOTICON_SHY, EMOTICON_DELAY);
other.sendMsg("emoShameChar", character.walkSO);
return
end;
print("sitDown onEnter");
startAnimation("sitdownToilet");
getParent().enableBlend(true);
end )
onMsg("end", function(msg)
if testCancel() then
setState("standUp");
else
setState("sit");
end
end )
onMsg("queue", function(msg)
setState("standUp");
end )
onMsg("sitSound", function(msg)
end )
-- sit
state("sit")
onEnter(function(msg)
print("sitDown onEnter");
--actionComplete();
sendDelayedMsgThis("testCancel", CANCEL_POLLING_INTERVAL);
sendDelayedMsgThis("stink", 5*1000);
local toilet = retrieveStateObject("toilet");
dirtify(toilet, DIRTIFY_PER_SIT_TOILET);
local sitToilet = getParent().startActivity("sitToilet", toilet);
local length, scale = getActivityLength(sitToilet);
sendDelayedMsgThis("complete", length);
end )
onExit(function(msg)
local toilet = retrieveStateObject("toilet");
getParent().stopActivity("sitToilet", toilet);
end )
onMsg("stink", function(msg)
local toilet = retrieveStateObject("toilet");
toilet.setChildEnable("stink", true);
end )
onMsg("complete", function(msg)
setState("standUp");
end )
onMsg("queue", function(msg)
sendMsgThis("complete");
end )
onMsg("testCancel", function(msg)
-- if testCancel() or (this.getParent().getActivityQueueCount() > 1) or (not this.getParent().getCurrentActivityGain()) then
if testCancel() or (not this.getParent().getCurrentActivityGain()) then
--if testCancel() or (this.getParent().getActivityQueueCount() > 1) then
sendMsgThis("complete");
else
sendDelayedMsgThis("testCancel", CANCEL_POLLING_INTERVAL);
end
end )
-- stand up from toilet
state("standUp")
onEnter(function(msg)
startAnimation("standupToilet");
sendDelayedMsgThis("flushSound", 4200);
end )
onMsg("flushSound", function(msg)
getParent().playSound("closetFlush");
end )
onMsg("end", function(msg)
local toilet = retrieveStateObject("toilet");
toilet.setChildEnable("stink", false);
getParent().enableBlend(false);
exitAndGoAway();
end )
state("cleanStart")
onEnter(function(msg)
-- grab sponge
local sponge = getParent().loadGameObject("StandardGO","sponge");
getParent().attachRightObjectHolder(sponge);
storeStateObject("sponge", sponge);
startAnimation("cleanClosetStart");
sendDelayedMsgThis("cleanSound", 900);
end )
onMsg("cleanSound", function(msg)
local toilet = retrieveStateObject("toilet");
toilet.playSound("cleanToiletStart", 0.25);
end )
onMsg("end", function(msg)
if (testCancel()) then
exitStateMachine();
else
setState("clean");
end
end )
-- clean up
state("clean")
onEnter(function(msg)
local toilet = retrieveStateObject("toilet");
local clean = getParent().startActivity("clean", toilet);
local length, scale = getActivityLength(clean);
storeData("scale", scale);
startAnimation("cleanClosetLoop", false, scale);
toilet.loopSound("cleanToiletLoop", 0.25);
--sendDelayedMsgThis("complete", length);
--this.actionComplete();
end )
onExit(function(msg)
local toilet = retrieveStateObject("toilet");
toilet.stopSound("cleanToiletLoop");
end )
onMsg("complete", function(msg)
getParent().stopActivity("clean", retrieveStateObject("toilet"));
setState("cleanEnd");
end )
onMsg("end", function(msg)
local toilet = retrieveStateObject("toilet");
local dirt = toilet.getDirtiness();
if (testCancel() or dirt<0.01) then
sendMsgThis("complete");
else
local scale = retrieveData("scale");
startAnimation("cleanClosetLoop", false, scale, 500);
--toilet.playSound("cleanToilet");
clean(toilet, CLEAN_PER_LOOP);
end
end )
state("cleanEnd")
onEnter(function(msg)
startAnimation("cleanClosetEnd");
sendDelayedMsgThis("cleanSound", 600);
sendDelayedMsgThis("cleanSound", 1650);
end )
onMsg("cleanSound", function(msg)
local toilet = retrieveStateObject("toilet");
toilet.playSound("cleanToiletStart", 0.25);
end )
onMsg("end", function(msg)
-- remove sponge
local sponge = getParent().getRightHeldObject()
getParent().detachRightObjectHolder();
if (sponge) then sponge.deleteGameObject(); end
if (not testCancel()) then queueNextClean(getParent()) end;
exitAndGoAway();
end )
endStateMachine()