home *** CD-ROM | disk | FTP | other *** search
-
- -- NOT_COMPLETE = 0;
- -- JUST_COMPLETE = 1;
- -- COMPLETE = 2;
-
- function checkTutorial3Complete()
-
- -- 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
-
-
- -- check elaine
- local elaine = getParent().getCharacter(ELAINE);
-
- if (not elaine) then
- return 0;
- end
-
- --local romantic = elaine.getRelationshipCondition(MIKE, REL_FRIENDSHIP);
- --if romantic < 1 then
- -- not complete
- -- return 0;
- --end
-
- -- check mike
- local mike = getParent().getCharacter(MIKE);
-
- if (not mike) then
- return 0;
- end
-
- --romantic = 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"});
- popupMission();
- end )
-
- onMsg("getText", function(msg)
- -- set mission text
- if (checkTutorial3Complete() == 0) then
- -- mission is not yet complete
- setMissionText("tutorial3_name", "tutorial3_desc");
- else
- -- mission is complete
- setMissionText("tutorial3_name", "tutorial3_finish");
- end
- 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 (checkTutorial3Complete() == 1) then
- popupMission();
- end
- end )
-
- onMsg("ok", function(msg)
- print("3 ok pressed");
- if (checkTutorial3Complete() == 2) then
- exitStateMachine();
- end
- end )
-
- endStateMachine()
-