Guest User

Untitled

a guest
Sep 12th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Currently, this script will choose a random animation from inventory to play upon sit.
  2. //The animations are named with this convention: name#;time  Ex: dance19;23.0 dance24;19.5 dance32;27.8
  3. //What I would like to do is (after the first random animation has played) set a timer to play each animation for its given length of time, then choose another animation at random.  And the process repeats itself.
  4.  
  5. string old_anim;
  6. float anim_duration;
  7.  
  8. random_anim()
  9. {   all_animations = llListRandomize(all_animations, 1);
  10.     list this = llParseString2List(llList2String(all_animations,0),";");//parses the string to find the duration
  11.     animation = llList2String(all_animations,0);
  12.     anim_duration = (float)llList2String(this,1);//assigns the duration as a variable float
  13. }
  14.  
  15. rotation  my_rotation;
  16. list all_animations;
  17. string animation;
  18.  
  19. default
  20. {   state_entry()
  21.     {   llSetSitText( "sit");
  22.         integer i;
  23.         for (i=0; i< llGetInventoryNumber(INVENTORY_ANIMATION);i++)
  24.         {   all_animations += [llGetInventoryName(INVENTORY_ANIMATION, i)];
  25.         }
  26.         vector offset = <0.0, 0.0, 0.25>; // x, y, z
  27.         vector rot = <0, 0, 0>; // x, y, z (degrees)
  28.         llSitTarget(offset, llEuler2Rot(rot * DEG_TO_RAD));
  29.     }
  30.     touch_start(integer total_number)
  31.     {   my_rotation = llGetRot();
  32.         llSay(0, "Rotation = " + (string) my_rotation);
  33.     }
  34.     changed(integer change)
  35.     {   if (change & CHANGED_LINK)
  36.         {   key agent = llAvatarOnSitTarget();
  37.             if (agent)
  38.             {   llRequestPermissions(agent, PERMISSION_TRIGGER_ANIMATION);
  39.             }  
  40.             else
  41.             {   llStopAnimation(animation);
  42.                 llResetScript();  
  43.             }
  44.         }
  45.         else if (change & CHANGED_INVENTORY)
  46.         {   llOwnerSay("ball resets in 10 seconds");
  47.             llSleep(10);
  48.             llResetScript();
  49.         }
  50.     }
  51.     timer()
  52.     {
  53.          random_anim();//chooses a new
  54.          llStartAnimation(animation);//starts it
  55.      llSetTimerEvent(anim_duration);//sets the time
  56.      llStopAnimation(old_anim);//stops the old
  57.          old_anim=animation;//reassigns the name to stop the next one
  58.      }  
  59.     run_time_permissions(integer perm)
  60.     {   if (perm)
  61.         {   llStopAnimation("sit");
  62.             random_anim();
  63.             llStartAnimation(animation);
  64.         llSetTimerEvent(anim_duration);
  65.         old_anim=animation;
  66.         }  
  67.     }
  68. }
Add Comment
Please, Sign In to add comment