home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Singles (French)
/
Singles-FrenchVersion-Win95.iso
/
data1.cab
/
Statemachine
/
mission1.lua
< prev
next >
Wrap
Text File
|
2004-03-05
|
3KB
|
110 lines
-- NOT_COMPLETE = 0;
-- JUST_COMPLETE = 1;
-- COMPLETE = 2;
function checkMissionComplete()
-- if mission is already complete: return 2
if (retrieveData("complete")) then
return 2;
end
-- check if mission is complete now
-- needed objects list has to be empty
local neededObjects = retrieveData("neededObjects");
if getn(neededObjects) > 0 then
-- not complete
return 0;
end
-- number of kisses needs to be at least 1
local kisses = retrieveData("kisses", 0);
if kisses == 0 then
-- not complete
return 0;
end
--
local romantic = getParent().getCharacter(ELAINE).getRelationshipCondition(MIKE, REL_FRIENDSHIP);
if romantic < 1 then
-- not complete
return 0;
end
romantic = getParent().getCharacter(MIKE).getRelationshipCondition(ELAINE, REL_FRIENDSHIP);
if romantic < 1 then
-- not complete
return 0;
end
-- now complete: return 1
storeData("complete", 1);
return 1;
end
beginStateMachine()
onEnter(function(msg)
-- list of useful things that have to be built
storeData("neededObjects", {"lamp", "kommode", "tv", "plant", "flower"});
end )
onMsg("getText", function(msg)
-- set mission text
if (checkMissionComplete() == 0) then
-- mission is not yet complete
setMissionText(translate(
"Mike und Linda ziehen ein\n\n"
.."Die neue Wohnung, jedoch noch wⁿst und leer. Was nutzt einem ein Blick auf den Park, wenn man sich nicht mal hinsetzen kann?\n"
.."-Richte die Wohnung mit ein paar Sofas und Dekoration ein, damit sich die beiden wohl fⁿhlen.\n"
.."-Um sich kennenzulernen, sollen Mike und Linda miteinander reden. Dazu mⁿssen sie sich wohl fⁿhlen, also z.B. keinen Hunger haben etc.\n"
));
else
-- mission is complete
setMissionText(translate("geschafft!"));
end
end )
onMsg("kiss", function(msg)
local d = retrieveData("kisses", 0);
d = d + 1;
storeData("kisses", d);
end )
onMsg("buy", function(msg)
-- check if something useful was built
local sender = getStateObjectFromID(msg.sender);
local neededObjects = retrieveData("neededObjects");
for i = 1, getn(neededObjects) do
print("checking needed object " .. neededObjects[i]);
if sender.hasBehavior(neededObjects[i]) then
print("found");
-- remove from needed objects and store needed objects again
tremove(neededObjects, i);
storeData("neededObjects", neededObjects);
-- remove a moving carton
local cartons = sender.getObjectsWithBehavior("movingCarton");
if getn(cartons) > 0 then
print("delete");
cartons[1].deleteGameObject();
end
break;
end
end
end )
onMsg("checkComplete", function(msg)
if (checkMissionComplete() == 1) then
popupMission();
end
end )
endStateMachine()