Advertisement
salahzar

Emoter script

Feb 28th, 2015
440
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. key operator;
  2.  
  3. list gAnimations ;
  4.  
  5.  
  6.  
  7. restartAnimations()
  8. {
  9.     integer i ;
  10.     integer max = llGetListLength(gAnimations) ;
  11.     string ani ;
  12.     for (i=0;i<max;i++)
  13.     {
  14.         ani = llList2String(gAnimations, i) ;
  15.         llStopAnimation(ani) ;
  16.         llStartAnimation(ani) ;
  17.     }
  18. }
  19.  
  20. addAnimation(string ani)
  21. {
  22.     //ensure that the animation isn't already in the list
  23.     if(-1 == llListFindList(gAnimations, [ani]))
  24.     {
  25.         //llOwnerSay("Add animation "+ani);
  26.         gAnimations = gAnimations + [ani] ;
  27.         llSetTimerEvent(0.5) ;
  28.     }
  29. }
  30. removeAnimation(string ani)
  31. {
  32.     integer idx = llListFindList(gAnimations, [ani]) ;
  33.    
  34.     if(-1 != idx)
  35.     {
  36.         //llOwnerSay("Remove animation "+ani);
  37.         gAnimations = llDeleteSubList(gAnimations, idx,idx);
  38.     }
  39.     if(0==llGetListLength(gAnimations))
  40.     {
  41.         llSetTimerEvent(0) ;
  42.     }
  43. }
  44.  
  45. default
  46. {
  47.    
  48.     listen(integer channel, string name, key id, string str)
  49.     {
  50. //        llOwnerSay("Received "+str);
  51.         list cmds=llParseStringKeepNulls(str,[" "],[]);
  52.         string cmd=llList2String(cmds,0);
  53.         //integer index=(integer)llList2String(cmds,1);
  54.         //string parm=llList2String(nomi,index);
  55.         string parm=llList2String(cmds,1);
  56.         if(cmd=="add") addAnimation(parm) ;
  57.         if(cmd=="del") removeAnimation(parm);
  58.     }
  59.    
  60.     timer()
  61.     {
  62.         restartAnimations() ;
  63.     }
  64.     touch_start(integer count)
  65.     {
  66.         integer linkno=llDetectedLinkNumber(0);
  67.         string name=llGetLinkName(linkno);
  68.         integer idx = llListFindList(gAnimations, [name]) ;
  69.         if(idx<0) {
  70.             addAnimation(name);
  71.             llSetLinkPrimitiveParams(linkno,[ PRIM_COLOR, ALL_SIDES,<0,1,0>,0.5 ]);
  72.         } else {
  73.             removeAnimation(name);
  74.                   llSetLinkPrimitiveParams(linkno,[ PRIM_COLOR, ALL_SIDES,<0,0,0>,0 ]);
  75.         }
  76.        
  77.     }
  78.    
  79.     changed(integer change)
  80.     {
  81.         if(change & CHANGED_OWNER)
  82.         {
  83.             llResetScript() ;
  84.         }
  85.     }
  86.     on_rez(integer rez)
  87.     {
  88.         llResetScript();
  89.     }
  90.  
  91.     state_entry()
  92.     {
  93.    
  94.         llListen(200,"",llGetOwner(),"");
  95.    
  96.         if (!(llGetPermissions() & PERMISSION_TRIGGER_ANIMATION))
  97.         {
  98.             llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
  99.         }
  100.         if(0>llGetListLength(gAnimations))
  101.         {
  102.             llSetTimerEvent(0.5) ;
  103.         }
  104.         llOwnerSay("Ready");
  105.     }
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement