[sldev] Incorporating multiple animations in an object

Harold Brown labrat.hb at gmail.com
Wed May 23 21:31:11 PDT 2007


Change these lines:
llSetTimerEvent(llFrand(maxTime));
To this:
 llSetTimerEvent(llFrand(maxTime) + 1);

What is happening is it is randomly selecting 0 and that will stop the
timer.

On 5/23/07, Dana Moore <dana.virtual at gmail.com> wrote:
>
> Just a follow up on my previous posting
> there were a number of syntax and other problems (undeclared variables,
> etc) with the donated script as written.
> I have corrected it in an effort to make sure we donate things that are
> correct as possible.
> Although this compiles and will work for a few iterations of timer(), it
> seems to lose its way after a while and not fire the next animation. I am
> investigating and will report back to y'all as I discover why.
>
> Cheers,
> ________  BEGIN CUT __________________
> float maxTime = 20;    // Maximum time between animation changes
> key avatar;
> key trigger;
> string animation;
> string HOVERTEXT="Se reposer";
> string SIT_TEXT="Relax";
> string HOVER_RGB="255,255,255";
> integer LISTEN=TRUE;
> integer CHANNEL=0;
> vector POSITION=<0.0, 0.0, 0.05>;
>
> // Function to randomly select and play an animation
> randomAnimation()
> {
>  // Get the total number of animations in the inventory
>  integer max = llGetInventoryNumber(INVENTORY_ANIMATION);
>
>  // Pick a random animation to play
>  integer anim = (integer)llFrand(max);
>  // Start the animation
>  animation = llGetInventoryName(INVENTORY_ANIMATION,anim);
>  llSay(0, "Timer elapsed... aimation chosen is :"+animation);
>  llStartAnimation(animation);
>  llSetTimerEvent(llFrand(maxTime));
> }
>
> set_text()
> {
>        if (llStringLength(HOVERTEXT)>0)
>         {
>             rgb=llCSV2List(HOVER_RGB);
>             llSetText(HOVERTEXT,<llList2Float(rgb,0)*
> 0.003921568627450980392156862745098 ,
>             llList2Float(rgb,1)*0.003921568627450980392156862745098,
>             llList2Float(rgb,2)*0.003921568627450980392156862745098>,1.0);
>
>         }
>         else
>            llSetText("",<0,0,0>, 0.0);
> }
> start_listen()
> {
>     llListenRemove(listener);
>     if (LISTEN==TRUE)
>         listener=llListen(CHANNEL,"","","");
> }
> hide_me()
> {
>     llSetAlpha( 0.0, ALL_SIDES);
>     llSetText("",<0,0,0>,0.0);
> }
> show_me()
> {
>     llSetAlpha(1.0, ALL_SIDES);
>     set_text();
> }
>
> list rgb;
> integer listener;
> default{
>   state_entry(){
>        if (llStringLength(SIT_TEXT)>0)
>             llSetSitText(SIT_TEXT);
>         llSitTarget(POSITION, ZERO_ROTATION);
>         set_text();
>         start_listen();
>       }
>       on_rez(integer r)
>     {
>         start_listen();
>     }
>
>     listen(integer channel, string name, key id, string msg)
>     {
>         if (msg=="hide")
>         {
>             hide_me();
>             llMessageLinked(LINK_SET,0,"hide", NULL_KEY);
>         }
>         else if (msg=="show")
>         {
>             show_me();
>             llMessageLinked(LINK_SET,0,"show", NULL_KEY);
>         }
>     }
>
>   changed(integer change)
>     {
>         if(change & CHANGED_LINK)
>         {
>             avatar = llAvatarOnSitTarget();
>             if(llKey2Name(avatar))
>             {
>                 if(trigger != avatar)
>                     llRequestPermissions(avatar,
> PERMISSION_TRIGGER_ANIMATION);
>             }
>             else if(trigger)
>             {
>                 llSetTimerEvent(0);
>                 if(trigger == llGetPermissionsKey())//right user?
>                     if(llGetPermissions() &
> PERMISSION_TRIGGER_ANIMATION)//got permissions?
>                         if(llKey2Name(trigger))
>                             llStopAnimation(animation);
>             }
>         }
>     }
>
>     run_time_permissions(integer perm)
>     {
>         avatar = llAvatarOnSitTarget();
>         if(perm & PERMISSION_TRIGGER_ANIMATION && llKey2Name(avatar) != ""
>
>             && avatar == llGetPermissionsKey())
>         {
>             trigger = avatar;
>             llStopAnimation("sit");
>             randomAnimation();
>             llSetTimerEvent(llFrand(maxTime));
>         }
>     }
>
>  timer()
>  {
>   randomAnimation();
>  }
>
> }
>
> ____________________ END CUT ________________
>
> On 5/23/07, Harold Brown <labrat.hb at gmail.com> wrote:
> >
> >  float maxTime = 10;    // Maximum time between animation changes
> >
> >
> > // Function to randomly select and play an animation
> > function randomAnimation()
> > {
> >  // Get the total number of animations in the inventory
> >  integer max = llGetInventoryNumber(INVENTORY_ANIMATION);
> >
> >  // Pick a random animation to play
> >  integer anim = (integer)llFrand(max);
> >
> >  // Start the animation
> >  llStartAnimation(llGetInventoryName(INVENTORY_ANIMATION,anim));
> >
> >  llSetTimerEvent(llFrand(maxTime));
> > }
> >
> > default()
> > {
> >  state_entry()
> >  {
> >   // Do setup code here
> >  }
> >
> >  changed(integer change)
> >     {
> >         if(change & CHANGED_LINK)
> >         {
> >             avatar = llAvatarOnSitTarget();
> >             if(llKey2Name(avatar))
> >             {
> >                 if(trigger != avatar)
> >                     llRequestPermissions(avatar,
> > PERMISSION_TRIGGER_ANIMATION);
> >             }
> >             else if(trigger)
> >             {
> >     llSetTimerEvent(0);
> >                 if(trigger == llGetPermissionsKey())//right user?
> >                     if(llGetPermissions() &
> > PERMISSION_TRIGGER_ANIMATION)//got permissions?
> >                         if(llKey2Name(trigger)) //user in the sim?
> > modern permision system makes this last check unnecessary.
> >                             llStopAnimation(animation);
> >             }
> >         }
> >     }
> >
> >     run_time_permissions(integer perm)
> >     {
> >         avatar = llAvatarOnSitTarget();
> >         if(perm & PERMISSION_TRIGGER_ANIMATION && llKey2Name(avatar) !=
> > "" && avatar == llGetPermissionsKey())
> >         {
> >             trigger = avatar;
> >             llStopAnimation("sit");
> >             randomAnimation();
> >    llSetTimerEvent(llFrand(maxTime));
> >         }
> >     }
> >
> >  timer()
> >  {
> >   randomAnimation();
> >  }
> >
> > }
> >
> >
> >  On 5/23/07, Dana Moore < dana.virtual at gmail.com> wrote:
> >
> > > Forgive what is probably a nOOb question, but I have googled for an
> > > answer and poked about in the FAQs and can't seem to get this one.
> > > Suppose I have a pose ball attached to a chair and I have several
> > > individual sit animations.
> > > I would like them to fire randomly, and perhaps have a stock sit
> > > action to tween.
> > > I thought perhaps that  simply including them in the content of the
> > > pose ball might be all I would need to do (silly me).
> > > Perhaps someone with a larger cranial capacity could suggest the right
> > > way to do this?
> > >
> > >
> > > Dana Moore
> > > Division Scientist
> > > BBN Technologies
> > > YM: dana_virtual
> > > SL: ElectricSheep Expedition
> > >
> > > _______________________________________________
> > > Click here to unsubscribe or manage your list subscription:
> > > /index.html
> > >
> > >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.secondlife.com/pipermail/sldev/attachments/20070523/ef0aa7d0/attachment-0001.htm


More information about the SLDev mailing list