Advertisement
Edie_Shoreland

Animated Object Dance List

Jan 2nd, 2019
545
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Put your animations in the object to be animated
  2. //first. Then create a new script and paste this code
  3. //(make sure the script is in the object's inventory)
  4.  
  5. //Give it a couple minutes to warm up and then say
  6. //"dance" in chat to animate the object.  Simply
  7. //say "stop" to make the object stop.
  8.  
  9. list ani_names;
  10.  
  11. float randomFloat;
  12. string aniname;
  13. integer aninumber;
  14. integer synched;
  15. integer toggle;
  16. integer listenHandle;
  17.  
  18. integer countz ()
  19. {
  20.     return llGetInventoryNumber(INVENTORY_ANIMATION);
  21. }
  22.  
  23. list moves (integer count)
  24. {
  25.     list    InventoryList;
  26.     string  ItemName;
  27.     while (count--)
  28.     {
  29.         ItemName = llGetInventoryName(INVENTORY_ANIMATION, count);
  30.         InventoryList += ItemName;
  31.     }
  32.     return InventoryList;
  33. }
  34.  
  35. default
  36. {
  37.     state_entry()
  38.     {
  39.         synched = countz();
  40.         ani_names = moves(synched);
  41.         llSetTimerEvent(90);
  42.         listenHandle = llListen(0, "", "", "");
  43.     }
  44.    
  45.     timer()
  46.     {
  47.         randomFloat = llFrand(synched);
  48.         aninumber = (integer)randomFloat;
  49.         string oldaniname = aniname;
  50.         aniname = llList2String(ani_names, aninumber);
  51.         llStopObjectAnimation(oldaniname);
  52.         llStartObjectAnimation(aniname);
  53.     }
  54.    
  55.     listen(integer channel, string name, key id, string message)    
  56.     {
  57.         if (llToLower(message) == "stop")
  58.         {
  59.             llSetTimerEvent(0);
  60.             llStopObjectAnimation(aniname);
  61.         }
  62.         else if (llToLower(message) == "dance")
  63.         {
  64.             llSetTimerEvent(90);
  65.             llStartObjectAnimation(aniname);
  66.         }
  67.     }
  68.    
  69.     changed(integer change)
  70.     {
  71.         if (change & CHANGED_INVENTORY)
  72.         {
  73.             llSetTimerEvent(0);
  74.             llStopObjectAnimation(aniname);
  75.             llResetScript ();
  76.         }
  77.     }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement