Advertisement
Shinobiace

Fish Pond

Sep 29th, 2020
374
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. integer out  = FALSE;
  3. integer rod_equip = FALSE;
  4.  
  5. key rod_owner;    // 3. Since you are passing messages over several events we need to store the rod owner key in a global variable.
  6.  
  7. //time 15 seconds delay for it to be visible
  8.  
  9. integer lchan;
  10.    
  11. default
  12. {
  13.      state_entry()
  14.     {
  15.         llListen(-11223,"Fishing Rod","","");
  16.        
  17.                          
  18.     }
  19.     //listen for fishing rod is equip
  20.     listen(integer channel, string what, key who, string msg)
  21.     {        
  22.  
  23.     list tmp = llParseString2List(msg,["_"],[]);   // 4. We parse the message sent from the rod to the pond. The message will be split into elements in a list at the separator.  
  24.    
  25.     string cmd = llList2String(tmp,0); // 5. The value to the left of the separator will become the first element in the list.  i,e "Equip".   Note that list elements begin at 0.
  26.    
  27.     string val = llList2String(tmp,1); // 6. The value to the right of the separator will become the second element in the list.    i,e The rod owner key.
  28.        
  29.             if(cmd=="Equip" ) // 7. Note this changes to if(cmd=="Equip" ) because we are checking the parsed message.
  30.             {
  31.                
  32.                rod_equip = TRUE;
  33.                rod_owner = (key)val;  // 8. We need to store this in the global variable container so we can send it on to the spawner.
  34.                return;
  35.             }
  36.             else
  37.             {            
  38.                 rod_equip = FALSE;
  39.                 return;
  40.             }
  41.  
  42.  
  43.                        
  44.     }
  45.    
  46.     touch_start(integer total_number)
  47.     {
  48.  
  49.     lchan = ((integer)("0x"+llGetSubString((string)llDetectedKey(0),-8,-1)) - 723) | 0x8000000;
  50.         //ask for the fishing rod  
  51.              
  52.         llSay(-11223,"CheckRod");        
  53.         if(out == TRUE && rod_equip == TRUE)
  54.         {
  55.             llOwnerSay("Toggle off");
  56.             out = FALSE;      
  57.             llSay(lchan,"off_"+ rod_owner);          
  58.             return;
  59.         }
  60.        
  61.         else if(out == FALSE && rod_equip == TRUE)
  62.         {
  63.             llOwnerSay("Toggle On");
  64.             out = !out;
  65.             llSay(lchan,"on_"+ rod_owner);  //9. We send the message on to the spawners and whichever spawner with an owner key that matches the rod owner key will spawn fish.
  66.             return;
  67.         }
  68.                                      
  69.     }      
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement