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

  1. -- pool character state machine
  2. beginStateMachine()
  3.     
  4.     onEnter(function(msg)
  5.         print("poolChar enter ------------------------------------------");
  6.         local pool = getStateObjectFromID(msg.sender)
  7.         storeStateObject("pool", pool);
  8.                 
  9.     end )
  10.     
  11.  
  12.     onExit(function(msg)
  13.         print("poolChar exit ------------------------------------------ queue:" .. getParent().getActivityQueueCount());
  14. --        local pool = retrieveStateObject("pool");
  15. --        getParent().unlockActionPoints(pool);
  16. --        getParent().stopAllActivities(pool);        
  17. --        removeStateObject("pool");
  18.  
  19.         unlockAll("pool");        
  20.                                 
  21.                                 getParent().stopAllActivities();
  22.     end )
  23.     
  24.     
  25.     state("sitDown")
  26.     
  27.         onEnter(function(msg)
  28.             --local currentOutfit = getParent().getOutfit();
  29.             if (hasOutfit(getParent(), SWIMMING)) then
  30.                 startAnimation("poolSitDown");
  31.             else
  32.                 setState("undress");
  33.             end
  34.         end )
  35.         
  36.         onMsg("end", function(msg)
  37.             setCurrentPosition();
  38.             if testCancel() then
  39.                 setState("getUp")
  40.             else
  41.                 setState("enter")
  42.             end            
  43.         end )
  44.         
  45.         
  46.     state("undress")
  47.     
  48.         onEnter(function(msg)
  49.             --startAnimation("ausziehen2");
  50.             startAnimation(getChangeOutfitAnim(getParent()));
  51.             sendDelayedMsgThis("underwear", 1600);
  52.         end )
  53.         
  54.         onMsg("underwear", function(msg)
  55.             changeOutfit(getParent(), SWIMMING);
  56.         end )
  57.     
  58.         onMsg("end", function(msg)
  59.             setState("sitDown")
  60.         end )
  61.             
  62.     
  63.     state("enter")
  64.     
  65.         onEnter(function(msg)
  66.             print("enter");
  67.             startAnimation("poolGetIn");
  68.             
  69.             getParent().enableBlobShadow(false);
  70.         end )
  71.         
  72.         onMsg("end", function(msg)
  73.         
  74.             getParent().playSound("splashSoft");
  75.         
  76.             if testCancel() then
  77.                 setCurrentPosition();
  78.                 flipPoseDirection();
  79.                 setState("exit")
  80.             else
  81.                 local pool = retrieveStateObject("pool")
  82.                 setCurrentPosition();
  83.                 flipPoseDirection();
  84.                 enterStateMachine("swimChar.stand");
  85.                 -- start the swimming activity
  86.                 getParent().startActivity("swim", pool);
  87.                 nextAction();
  88.                 -- storeStateObject("pool", pool);
  89.             end            
  90.         end )
  91.         
  92.         onReturn(function(msg)
  93.             setState("exit");
  94.         end )
  95.         
  96.  
  97.  
  98.     state("exit")
  99.     
  100.         onEnter(function(msg)
  101.             print("exit");
  102.             -- replace the current entry in the activity queue by a replace pool action
  103.             local character = this.getParent();
  104.             local pool = retrieveStateObject("pool");
  105.             --character.replaceQueueEntry(0, "pm_exitPool");
  106.             -- stop the activity
  107.             getParent().stopActivity("swim", pool);
  108.             flipPoseDirection();
  109.             getParent().playSound("splashSoft");
  110.             startAnimation("poolGetOut");
  111.             
  112.         end )
  113.         
  114.         onMsg("end", function(msg)
  115.             setCurrentPosition();
  116.             getParent().enableBlobShadow(true);
  117.             setState("getUp");
  118.         end )
  119.         
  120.         
  121.         
  122.     state("getUp")
  123.     
  124.         onEnter(function(msg)
  125.             print("getUp");
  126.             startAnimation("poolStandUp");
  127.         end )
  128.         
  129.         onMsg("end", function(msg)
  130.             setCurrentPosition();
  131.             
  132.             exitStateMachine();
  133.             --exitAndGoAway();
  134.         end )
  135.             
  136.     
  137. endStateMachine()