Edie_Shoreland

Temporary Automatic Animation Changer with Occupancy

Aug 29th, 2018
634
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //This script was originally designed for gachas using AVSitter, but is also ideal for
  2. //objects that can be modified containing AVpos notecards that cannot be edited or
  3. //for AVpos notecards (like ones in gacha items) that you may not want to edit.
  4.  
  5. //CHANGE THE NAMES IN ani_names TO THE NAMES OF ANIMATIONS IN THE SIT MENU/AVpos NOTECARD
  6. //YOU WANT TO RANDOMLY CYCLE THROUGH. (You can add more names, just use quotation marks.)
  7. list ani_names = ["Male_01", "Male_05", "Male_06", "Male_10", "Female_05", "Female_06", "Female_08", "Male_08"];
  8.  
  9. //CHANGE THE INTEGER IN Tcycle TO THE NUMBER OF SECONDS YOU WANT BETWEEN ANIMATION AND
  10. //POSE CHANGES.
  11. integer Tcycle = 110;
  12.  
  13. float randomFloat;
  14. string aniname;
  15. integer aninumber;
  16. integer synched;
  17.  
  18. //CHANGE THIS NUMBER TO THE MAXIMUM NUMBER OF AVATARS THAT YOU WANT SEATED ON THIS OBJECT.
  19. //THIS VALUE IS USED IN COMBINATION WITH THE Bot_Signal FUNCTION.
  20. integer max_sitters = 1;
  21.  
  22. //BotSignal uses the description field to communicate maximum occupancy to scripted agents.
  23. //If you're using AVSitter to cycle through animations for NPCs or bots this is a low lag
  24. //way to convey this information using llGetObjectDetails through a second script instead of
  25. //using a listen event.
  26. string Bot_Signal(integer Max_Occupancy)
  27. {
  28.     string OccORnot = "Occupied";
  29.     if ((llGetNumberOfPrims()- llGetObjectPrimCount(llGetKey())) < Max_Occupancy) OccORnot = "Unoccupied";
  30.     return OccORnot;
  31. }
  32.  
  33.  
  34.  
  35. default
  36. {
  37.     state_entry()
  38.     {
  39.         synched = llGetListLength(ani_names);
  40.         llSetTimerEvent(Tcycle);
  41.     }
  42.    
  43.     timer()
  44.     {
  45.         randomFloat = llFrand(synched);
  46.         aninumber = (integer)randomFloat;
  47.         aniname = llList2String(ani_names, aninumber);
  48.         llMessageLinked(LINK_SET,90000,aniname,"0");
  49.     }
  50.  
  51.     changed(integer change)
  52.     {
  53.         //Here's where the Bot_Signal does it's magic...
  54.         if (change & CHANGED_REGION_START) llSetObjectDesc(Bot_Signal(max_sitters));
  55.         if (change & CHANGED_LINK) llSetObjectDesc(Bot_Signal(max_sitters));
  56.         //The words "Occupied" or "Unoccupied" appear in the
  57.         //object's description.  If the seat says "Occupied"
  58.         //the bot can be scripted (using llGetObjectDetails)
  59.         //to avoid that seat and find some other place to sit
  60.         //with no listener required.
  61.  
  62.         if (change & CHANGED_INVENTORY) llResetScript();
  63.     }
  64. }
Advertisement