Jump to content

Hud to play a series of animations in cycle


bbrasta Boa
 Share

You are about to reply to a thread that has been inactive for 1014 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hello :)

I am trying to make a hud, to activate an animation of more than three minutes, the animation would be divided into four pieces (currently I have only put two, because I'm still testing it), the animations go without a loop, but I can't make them flow between them, I have tried to play with the ease in ease out values , from 0.0 to 0.1, without success, and also I don't know how to make them stop when clicking on the hud again, any help?

Thanks in advance.

Quote

key uuid_ON = "e293f57f-100a-14e7-8937-858988119c10";
key uuid_OFF = "370b36b4-4b89-0f3d-ce17-a61ca9281676";
key Owner;
integer chanel = 989898;
reset_script()
{
    llOwnerSay("Restarting the Animation Hud.");
    llResetScript();
}
texture_change_hud_on()
{
    string texture = uuid_ON;
    llSetTexture(texture, ALL_SIDES);
}
texture_change_hud_off()
{
    string texture = uuid_OFF;
    llSetTexture(texture, ALL_SIDES);
}
default
{
    state_entry()
    {
    Owner = llGetOwner();
    llRequestPermissions(Owner, PERMISSION_TRIGGER_ANIMATION);
   texture_change_hud_off();
    llStopAnimation("Animation test 01");
    llStopAnimation("Animation test 02");
}
touch_start (integer total_number)
{
    state on;
    }
    
    attach(key id)
    {
 if (id)
 { 
        reset_script();
     }
  }
}
state on
{
    state_entry()
    {
        texture_change_hud_on();
        Owner = llGetOwner();
        llRequestPermissions(Owner, PERMISSION_TRIGGER_ANIMATION);
        llListen(chanel, "","","");
    }
    attach(key id)
    {
        if (id)
        {
            reset_script();
}
}
touch_start(integer detected)
{
    state default;
    }
    
    run_time_permissions(integer perm)
    {
        if (perm & PERMISSION_TRIGGER_ANIMATION)
        {
            llStartAnimation("Animation test 01");
            llSleep(48.125);
            llStartAnimation("Animation test 02");
            llSleep(48.125);
            llResetScript();
            }
            }
            }

 

Link to comment
Share on other sites

Careful using a llSleep if the user can interact with the HUD at any time, as the script is unresponsive when slept and (I think) loses touch events that occur when slept.

Smooth transitions are possible but depend on the animations themselves having similar start and end positions, and the ease in / ease out would be better if set to around 1 second ish. If you use a timer, and offset that with the ease in duration of the following animation you can achieve near seamless transitions (note that there is always some variation as you cannot guarantee an animation is present in cache)

Sidenote: I notice you're swapping texture UUIDs to represent the status of the HUD (on or off) - is this needed? You can use a texture atlas to swap the colour of a button, or alternatively make the button texture greyscale and use llSetPrimitiveParams to apply a tint (e.g. red or green) to represent the state instead

Edited by Jenna Huntsman
Link to comment
Share on other sites

llSleep freezes your script. Events are NO interrupts so your script will do absolutely nothing for 3 minutes (if all 4 animations are equipped)

If you want to keep it responsive:
- never use llSleep
- use the timer
- llStopAnimation will stop an animation - reset or state change will not stop an animation

Animations play on the viewers not the server. If I stand in front of you and you trigger the animation my viewer will load the animation 1st (maybe 2 seconds) then start playing it.
If I look aside your animation will be halted. If I look back it will continue to play. So no timing can be guaranteed.

If you start the animations a 2nd time and I keep looking at you it should be possible to get the timing to work - if there is no lag.

 

Link to comment
Share on other sites

5 hours ago, bbrasta Boa said:

Hello :)

I am trying to make a hud, to activate an animation of more than three minutes, the animation would be divided into four pieces (currently I have only put two, because I'm still testing it), the animations go without a loop, but I can't make them flow between them, I have tried to play with the ease in ease out values , from 0.0 to 0.1, without success, and also I don't know how to make them stop when clicking on the hud again, any help?

Thanks in advance.

Honestly for doing this sort of thing, You'd probably be better off making a gesture than trying to do this with a script. All of the animations need to be full-perm (to you, not to the people you might sell/give it to) though.

  • Thanks 1
Link to comment
Share on other sites

Go over your script and check the wiki for every command that is in there so you have a better idea what you are doing.
And plz remove that listener, its bothering the hell out of me 😛

To keep it simple and to get you started use a timer and do something like.....
string i = 1;
llSetTimerEvent(48.125);  
timer(){

   if(i == 1){play_animation a}
   if(i == 2){play_animation b... stop animation ax++}
   i++

}

  • Like 2
Link to comment
Share on other sites

17 hours ago, Quistess Alpha said:

Honestly for doing this sort of thing, You'd probably be better off making a gesture than trying to do this with a script. All of the animations need to be full-perm (to you, not to the people you might sell/give it to) though.

We make all our animation from scratch, anyways thum up for you becase is good idea remember to everybody that is not safe buy full perms animations, cause surely they are stolen, and we are tired of send DMCA...

 

14 hours ago, bobsknief Orsini said:

Go over your script and check the wiki for every command that is in there so you have a better idea what you are doing.
And plz remove that listener, its bothering the hell out of me 😛

To keep it simple and to get you started use a timer and do something like.....
string i = 1;
llSetTimerEvent(48.125);  
timer(){

   if(i == 1){play_animation a}
   if(i == 2){play_animation b... stop animation ax++}
   i++

}

Thank you so much for that tip, I started from begining the script, and this is what I have right now, I just learning script so I'm newbie and I'm a lil stuck, can someone tell me what I'm doing wrong? :S there are not many examples of the timer event on the wiki, thanks in advance.

 

Quote

key uuid_ON = "5d22d13a-18bb-19c1-894c-77f52f37972e";
key uuid_OFF = "4591c717-b539-69cd-0548-54b9313f8892";
key Owner;
key id;
string i = 1;

reset_script()
{
    llResetScript();
}
texture_change_hud_on()
{
    string texture = uuid_ON;
    llSetTexture(texture, ALL_SIDES);
}
texture_change_hud_off()
{
    string texture = uuid_OFF;
    llSetTexture(texture, ALL_SIDES);
}

default
{
    attach(key id)
    {
        if (id)
        {
            reset_script();
}
}


    state_entry()
    {
    Owner = llGetOwner();
    llRequestPermissions(Owner, PERMISSION_TRIGGER_ANIMATION);
   texture_change_hud_off();
    llStopAnimation("Dance_1");
    llStopAnimation("Dance_2");
    llStopAnimation("Dance_3");
    llStopAnimation("Dance_4");
    llStopAnimation("Dance_5");

}

touch_start (integer total_number)
{
    state on;
    }
  }
state on
{
    state_entry()

    {
        texture_change_hud_on();
        Owner = llGetOwner();
        llRequestPermissions(Owner, PERMISSION_TRIGGER_ANIMATION);
    }

touch_start(integer detected)
{
    state default;
    }
    
    run_time_permissions(integer perm)
    {
        if (perm & PERMISSION_TRIGGER_ANIMATION)
        {

llSetTimerEvent(35.5); 
     }
    }
timer()
{
   if(i == 1)llStartAnimation("Dance_1")+llStopAnimation("Dance_2")+llStopAnimation("Dance_3")+llStopAnimation("Dance_4")+llStopAnimation("Dance_5")+(i++);
   if(i == 2)llStartAnimation("Dance_2")+llStopAnimation("Dance_1")+llStopAnimation("Dance_3")+llStopAnimation("Dance_4")+llStopAnimation("Dance_5")+(i++);
   if(i == 3)llStartAnimation("Dance_3")+llStopAnimation("Dance_1")+llStopAnimation("Dance_2")+llStopAnimation("Dance_4")+llStopAnimation("Dance_5")+(i++);
   if(i == 4)llStartAnimation("Dance_4")+llStopAnimation("Dance_1")+llStopAnimation("Dance_2")+llStopAnimation("Dance_3")+llStopAnimation("Dance_5")+(i++);
   if(i == 5)llStartAnimation("Dance_5")+llStopAnimation("Dance_1")+llStopAnimation("Dance_2")+llStopAnimation("Dance_3")+llStopAnimation("Dance_4")+(i++);

     }

    }

 

Link to comment
Share on other sites

key uuid_ON = "5d22d13a-18bb-19c1-894c-77f52f37972e";
key uuid_OFF = "4591c717-b539-69cd-0548-54b9313f8892";
list animations = 
[
  "Dance_1",
  "Dance_2",
  "Dance_3",
  "Dance_4",
  "Dance_5"
  // no final ','
];
integer indexAnimation;

texture_change_hud_on()
{
    llSetTexture(uuid_ON, ALL_SIDES);
}
texture_change_hud_off()
{
    llSetTexture(uuid_OFF, ALL_SIDES);
}

default
{
    state_entry()
    {
        texture_change_hud_off();
        /*
        integer index = llGetListLength(animations);
      	while(~--index)
        {
          llStopAnimation(llList2String(Animations,index));
        }
        */
    }

    touch_start (integer total_number)
    {
    	llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
    }
    run_time_permissions(integer perm)
    {
        if (perm & PERMISSION_TRIGGER_ANIMATION)
        {
            state on;
        }
    }
}
state on
{
    state_entry()
    {
        indexAnimation=-1;
        texture_change_hud_on();
        llSetTimerEvent(35.5);
    }
    attach(key ID)
    {
      if(ID)
      {   state default;
      }
    }
    touch_end(integer detected)
    {
        state default;
    }
    timer()
    {
        llStopAnimation(llList2String(animations,indexAnimation));
        ++indexAnimation;
        if(indexAnimation>=llGetListLength(animations))
        {   state default;
        }else // this 'else' is technically unnessesary.
        {   llStartAnimation(llList2String(animations,indexAnimation));
        }
    }
    state_exit()
    {   llSetTimerEvent(0);
    }
}

If I were doing it from scratch I might do it in a way that avoids the state transition, but assuming I didn't make any major mistakes, that should be a decent demonstration of how to go about something like this using a list rather than rolling out a command for each animation.

Edited by Quistess Alpha
*whistles* and changes touch_start to touch_end
  • Thanks 1
Link to comment
Share on other sites

On 9/8/2021 at 7:16 PM, Quistess Alpha said:
key uuid_ON = "5d22d13a-18bb-19c1-894c-77f52f37972e";
key uuid_OFF = "4591c717-b539-69cd-0548-54b9313f8892";
list animations = 
[
  "Dance_1",
  "Dance_2",
  "Dance_3",
  "Dance_4",
  "Dance_5"
  // no final ','
];
integer indexAnimation;

texture_change_hud_on()
{
    llSetTexture(uuid_ON, ALL_SIDES);
}
texture_change_hud_off()
{
    llSetTexture(uuid_OFF, ALL_SIDES);
}

default
{
    state_entry()
    {
        texture_change_hud_off();
        /*
        integer index = llGetListLength(animations);
      	while(~--index)
        {
          llStopAnimation(llList2String(Animations,index));
        }
        */
    }

    touch_start (integer total_number)
    {
    	llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
    }
    run_time_permissions(integer perm)
    {
        if (perm & PERMISSION_TRIGGER_ANIMATION)
        {
            state on;
        }
    }
}
state on
{
    state_entry()
    {
        indexAnimation=-1;
        texture_change_hud_on();
        llSetTimerEvent(35.5);
    }
    attach(key ID)
    {
      if(ID)
      {   state default;
      }
    }
    touch_end(integer detected)
    {
        state default;
    }
    timer()
    {
        llStopAnimation(llList2String(animations,indexAnimation));
        ++indexAnimation;
        if(indexAnimation>=llGetListLength(animations))
        {   state default;
        }else // this 'else' is technically unnessesary.
        {   llStartAnimation(llList2String(animations,indexAnimation));
        }
    }
    state_exit()
    {   llSetTimerEvent(0);
    }
}

If I were doing it from scratch I might do it in a way that avoids the state transition, but assuming I didn't make any major mistakes, that should be a decent demonstration of how to go about something like this using a list rather than rolling out a command for each animation.

Thank you very much :) , although in principle it did not work for me, it has been a very good base to work on, I have been on it all day, and it works almost well, except that when I click on the hud, the animation takes time to start 38.5 seconds later. I have not been able to use touch_end, if I click on the hud it changes from off to on, and then it changes to off, without playing the animation.

This is what I have now:

Quote

key uuid_ON = "cfdc1aa5-1194-8f7e-f161-0996d3be0901";
key uuid_OFF = "4b9d4122-7f78-9721-ded1-b88b1ebe1395";
list animations = ["Dance_1","Dance_2","Dance_3","Dance_4","Dance_5"];
integer indexAnimation;

texture_change_hud_on()
{
    llSetTexture(uuid_ON, ALL_SIDES);
}
texture_change_hud_off()
{
    llSetTexture(uuid_OFF, ALL_SIDES);
}

default
{
    state_entry()
    {
texture_change_hud_off();
integer index = llGetListLength(animations);

         while(~--index)
{
          llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
          llStopAnimation(llList2String(animations,index));
        }   
    }
    

    touch_start (integer total_number)

{
            state on;
        }
}
state on
{
    state_entry()
    {
        indexAnimation=-1;
        texture_change_hud_on();
        llSetTimerEvent(38.5);

            }
    attach(key id)
    {
        if (id)     
        {
               llResetScript();
        }
       
    }
  touch_start(integer detected)
    {
          state default;
}

    timer()
    {
        llStopAnimation(llList2String(animations,indexAnimation));
        ++indexAnimation;
        if(indexAnimation>=llGetListLength(animations))
{   
        state default;
        }
        else // this 'else' is technically unnessesary.
{  
         llStartAnimation(llList2String(animations,indexAnimation));
        }
    }
    state_exit()
    {   llSetTimerEvent(0);
    }
}

 

Link to comment
Share on other sites

13 hours ago, bbrasta Boa said:

Thank you very much :) , although in principle it did not work for me, it has been a very good base to work on, I have been on it all day, and it works almost well, except that when I click on the hud, the animation takes time to start 38.5 seconds later. I have not been able to use touch_end, if I click on the hud it changes from off to on, and then it changes to off, without playing the animation.

This is what I have now:

 

I manage how to do that, thank you so much again :)

Link to comment
Share on other sites

On 9/10/2021 at 7:55 AM, bbrasta Boa said:

 when I click on the hud, the animation takes time to start 38.5 seconds later.

 

a way to do this generally

touch_end(integer num)
{
   // start the timer so it will fire prety much immediately
   llSetTimerEvent(0.1);
}

timer()
{
   // stop the timer
   llSetTimerEvent(0.0);

   ... set up for next animation
   
   ... when we know the length of the next animation
   float time = ...get_next_animation_time...
   
   // restart the timer
   llSetTimerEvent(time);
}

 

 

Link to comment
Share on other sites

10 hours ago, Mollymews said:
timer()
{
   // stop the timer
   llSetTimerEvent(0.0);

   ... set up for next animation
   
   ... when we know the length of the next animation
   float time = ...get_next_animation_time...
   
   // restart the timer
   llSetTimerEvent(time);
}

I would remove the llSetTimerEvent(0); at the top, and just be sure to stop it at the bottom if there is no next animation. Otherwise, I generally agree with the approach :)

When I have a llSetTimerEvent(0); at the top of my timer event, that's usually a sign I'm using my timer as a one-time delay rather than a repeating timer.

(one time delays are useful for (among other things) dialog timeouts and as an element in detecting double-clicks.)

 

... actually now I think about it, do events get scheduled while an event is running? Will have to check next time I'm in world:

default
{
  state_entry()
  {  llSetTimerEvent(0.1);
  }
  timer()
  {  llSay(0,"Tick");
     llSleep(1.0);
     llSetTimerEvent(0);
  }
}

 

Edited by Quistess Alpha
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1014 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...