home *** CD-ROM | disk | FTP | other *** search
/ Singles (French) / Singles-FrenchVersion-Win95.iso / data1.cab / Statemachine / tutorial2.lua < prev    next >
Text File  |  2004-03-05  |  2KB  |  100 lines

  1.  
  2. -- NOT_COMPLETE = 0;
  3. -- JUST_COMPLETE = 1;
  4. -- COMPLETE = 2;
  5.  
  6. function checkTutorial2Complete()
  7.  
  8.     -- if mission is already complete: return 2
  9.     if (retrieveData("complete")) then
  10.         return 2;
  11.     end
  12.  
  13.     -- check if mission is complete now
  14.     
  15.     -- check elaine
  16.     local elaine = getParent().getCharacter(ELAINE);
  17.     
  18.     -- return if there is no elaine
  19.     if (not elaine) then
  20.         return 0;
  21.     end
  22.     
  23.     --local talk = elaine.getActivityCount("talkCasual");
  24.     --if talk < 1 then
  25.         -- not complete
  26.     --    return 0;
  27.     --end
  28.     
  29.     --local hunger = elaine.getCondition(NEED_HUNGER);
  30.     --if hunger < 0.9 then
  31.         -- not complete
  32.     --    return 0;
  33.     --end
  34.     
  35.     local friendship = elaine.getRelationshipCondition(MIKE, REL_FRIENDSHIP);
  36. --elaine.incRelationshipCondition(MIKE, REL_FRIENDSHIP);
  37.     if friendship < 1 then
  38.         -- not complete
  39.         return 0;
  40.     end
  41.  
  42.     -- check mike
  43.     local mike = getParent().getCharacter(MIKE);
  44.  
  45.     --talk = mike.getActivityCount("talkCasual");
  46.     --if talk < 1 then
  47.         -- not complete
  48.     --    return 0;
  49.     --end
  50.     
  51.     --hunger = mike.getCondition(NEED_HUNGER);
  52.     --if hunger < 0.9 then
  53.         -- not complete
  54.     --    return 0;
  55.     --end
  56.  
  57.     friendship = mike.getRelationshipCondition(ELAINE, REL_FRIENDSHIP);
  58.     if friendship < 1 then
  59.         -- not complete
  60.         return 0;
  61.     end
  62.  
  63.     -- now complete: return 1
  64.     storeData("complete", 1);
  65.     return 1;
  66. end
  67.  
  68.  
  69. beginStateMachine()
  70.  
  71.     onEnter(function(msg)
  72.         popupMission();
  73.     end )
  74.  
  75.     onMsg("getText", function(msg)
  76.         -- set mission text
  77.         if (checkTutorial2Complete() == 0) then
  78.             -- mission is not yet complete
  79.             setMissionText("tutorial2_name", "tutorial2_desc");
  80.         else
  81.             -- mission is complete
  82.             setMissionText("tutorial2_name", "tutorial2_finish");
  83.         end
  84.     end )
  85.  
  86.     onMsg("checkComplete", function(msg)
  87.         if (checkTutorial2Complete() == 1) then
  88.             popupMission();
  89.         end
  90.     end )
  91.  
  92.     onMsg("ok", function(msg)
  93.         print("2 ok pressed");
  94.         if (checkTutorial2Complete() == 2) then
  95.             exitStateMachine();
  96.         end
  97.     end )
  98.  
  99. endStateMachine()
  100.