ZenMondo's Touch-n-Go Animator

From ZenMondo Wormser, 1 Year ago, written in Linden Scripting, viewed 384 times.
URL http://flynnos.org/flynnbin/view/f1ecc6be Embed
Download Paste or View Raw
  1. ///////////////////////////////////////////////////////////////////////
  2. // ZenMondo's Touch-n-Go Animator
  3. //
  4. // Animates a texture when clicked, and stops when clicked again.
  5. //
  6. //////////////////////////////////////////////////////////////////////
  7.  
  8.  
  9. integer isAnimating;
  10. integer haveTexture;
  11.  
  12. //Face of prim to display texture
  13. integer side = 2;
  14.  
  15. //Number of Frames in animation texture
  16. // x_frames = horizontal frames
  17. // y_frames = vertical frames
  18. integer x_frames = 12;
  19. integer y_frames = 1;
  20.  
  21. //Start of Animation  0.0 is the first frame
  22. float start = 0.0;
  23.  
  24. //length of animaion 0.0 if you want it to loop back to the begining.
  25. float length = 0.0;
  26.  
  27. //Rate in frames per second.
  28. float rate = 10.0;
  29.  
  30. {
  31.     state_entry()
  32.     {
  33.         string texture = llGetInventoryName(INVENTORY_TEXTURE, 0);
  34.        
  35.         if(llGetInventoryType(texture) == INVENTORY_TEXTURE) // test to see if texture is in inventory.
  36.         {
  37.             llSetTexture(texture, side);
  38.             llSetTextureAnim(ANIM_ON | LOOP, side, x_frames, y_frames, start, length, rate);
  39.             isAnimating = TRUE;
  40.             haveTexture = TRUE;
  41.         }
  42.        
  43.         else
  44.         {
  45.             llWhisper(0, "There is not a texture present in inventory.");
  46.             llSetTextureAnim( FALSE , side, 1, 1, 0, 0, 0.0 ); //Turn off the Animation.
  47.             haveTexture = FALSE;
  48.         }  
  49.     }
  50.  
  51.     touch_start(integer total_number)
  52.     {
  53.         if(haveTexture)
  54.         {
  55.             if(isAnimating)
  56.             {
  57.                 llSetTextureAnim(ANIM_ON, side, x_frames, y_frames, -1.0, 0.0, rate); //Freeze Animation on the first frame.
  58.                 isAnimating = FALSE;
  59.             }
  60.        
  61.             else
  62.             {
  63.                 llSetTextureAnim(ANIM_ON | LOOP, side, x_frames, y_frames, start, length, rate);
  64.                 isAnimating = TRUE;
  65.             }
  66.         }    
  67.     }
  68.    
  69.     changed(integer change)
  70.     {
  71.         if(change & CHANGED_INVENTORY || change & CHANGED_TEXTURE)
  72.         {
  73.             llResetScript();
  74.         }
  75.     }
  76. }
  77.  

Reply to "ZenMondo's Touch-n-Go Animator"

Here you can reply to the paste above

captcha