[sldev] Incorporating multiple animations in an object
Frans
mrfrans at gmail.com
Wed May 23 21:36:49 PDT 2007
Hi Dana,
Not sure if you know, but there is a lsl mailing list.
https://lists.secondlife.com/cgi-bin/mailman/listinfo/secondlifescripters
That list is dedicated to lsl problems and questions.
Regards,
Frans
On 5/24/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();
> }
>
> }
>
--
RL: Jeroen Frans / SL: Frans Charming
http://www.thevesuviusgroup.com
http://www.fransinnovations.com
http://www.linkedin.com/in/mrfrans
http://secondslog.blogspot.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.secondlife.com/pipermail/sldev/attachments/20070524/4157a24b/attachment.htm
More information about the SLDev
mailing list