Advertisement
salahzar

Sit x animations corrected with stop all animations

Dec 8th, 2014
380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Jippen Faddoul's Poseball script - Low ram/lag posepall thats just drag-and drop simple
  2. // Copyright (C) 2007 Jippen Faddoul
  3. //    This program is free software: you can redistribute it and/or modify
  4. //    it under the terms of the GNU General Public License version 3, as
  5. //    published by the Free Software Foundation.
  6. //
  7. //    This program is distributed in the hope that it will be useful,
  8. //    but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  10. //    GNU General Public License for more details.
  11. //
  12. //   You should have received a copy of the GNU General Public License
  13. //    along with this program.  If not, see <http://www.gnu.org/licenses/>
  14.  
  15.  
  16.  
  17. //This text will appear in the floating title above the ball
  18. string TITLE="Clicca per animarti";            
  19. //You can play with these numbers to adjust how far the person sits from the ball. ( <X,Y,Z> )
  20. vector offset=<0.0,0.0,0.5>;            
  21.  
  22. ///////////////////// LEAVE THIS ALONE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  23. string ANIMATION;
  24. integer visible = TRUE;
  25. key avatar;
  26.  
  27. vector COLOR = <1.0,1.0,1.0>;
  28. float ALPHA_ON = 1.0;
  29. float ALPHA_OFF = 0.0;
  30.  
  31. show(){
  32.     visible = TRUE;
  33.     llSetText(TITLE, COLOR,ALPHA_ON);        
  34.     llSetAlpha(ALPHA_ON, ALL_SIDES);
  35. }
  36.  
  37. hide(){
  38.     visible = FALSE;
  39.     llSetText("", COLOR,ALPHA_ON);        
  40.     llSetAlpha(ALPHA_OFF, ALL_SIDES);
  41. }
  42. stopall()
  43. {
  44.      list anims = llGetAnimationList(llGetPermissionsKey());        // get list of animations
  45.             integer len = llGetListLength(anims);
  46.             integer i;
  47.            
  48.            // llSay(0, "Stopping " + (string)len + llGetSubString(" animations",0,-1 - (len == 1)));//strip the "s" when there is only 1 to stop.
  49.             for (i = 0; i < len; ++i) llStopAnimation(llList2Key(anims, i));
  50. }
  51.  
  52. default{
  53.     state_entry() {
  54.         llSitTarget(offset,ZERO_ROTATION);
  55.         if((ANIMATION = llGetInventoryName(INVENTORY_ANIMATION,0)) == ""){
  56.             llOwnerSay("Error: No animation");
  57.             ANIMATION = "sit";
  58.             }
  59.         llSetSitText(TITLE);
  60.         show();
  61.     }
  62.  
  63.     touch_start(integer detected) {
  64.         //llOwnerSay("Memory: " + (string)llGetFreeMemory());
  65.         if(visible){ hide(); }
  66.         else       { show(); }
  67.     }
  68.  
  69.     changed(integer change) {
  70.         if(change & CHANGED_LINK) {
  71.             avatar = llAvatarOnSitTarget();
  72.             if(avatar != NULL_KEY){
  73.                 //SOMEONE SAT DOWN
  74.                 hide();
  75.                 llRequestPermissions(avatar,PERMISSION_TRIGGER_ANIMATION);
  76.                 return;
  77.             }else{
  78.                 //SOMEONE STOOD UP
  79.                 if (llGetPermissionsKey() != NULL_KEY){ llStopAnimation(ANIMATION); }
  80.                 show();
  81.                 return;
  82.             }
  83.         }
  84.         if(change & CHANGED_INVENTORY) { llResetScript(); }
  85.         if(change & CHANGED_OWNER)     { llResetScript(); }
  86.     }
  87.  
  88.     run_time_permissions(integer perm) {
  89.         if(perm & PERMISSION_TRIGGER_ANIMATION) {
  90.            // llSay(0,"runtime ok anim");
  91.            stopall();
  92.             llStartAnimation("stand");
  93.            
  94.            // llStartAnimation("stand");
  95.            // llSleep(0.2);
  96.             llStartAnimation(ANIMATION);
  97.             hide();
  98.         }
  99.     }
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement