Jump to content

Animation on touch script error


rjunyeol
 Share

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

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

Recommended Posts

Hello, I made a HUD to play an animation on touch, and turn off on touch again. For me it works fine, but when I sent it to my alt to test it's working well, it gives this error "Script trying to stop animations but PERMISSION_TRIGGER_ANIMATION permission not set". The HUD still works and animates but I want to get rid of this error since I'm selling it and that would look bad. 

the script:

integer playing;

default
{
    state_entry()
    {
        playing = FALSE;
    }
    touch_start(integer start_param)
    {
        if(playing == FALSE)
        {
            llRequestPermissions(llDetectedKey(0),PERMISSION_TRIGGER_ANIMATION);
        }
        else if(playing == TRUE)
        {
            llStopAnimation(llGetInventoryName(INVENTORY_ANIMATION,0));
            playing = FALSE;
        }
    }
    run_time_permissions(integer perm)                                  
    {
        if (perm & PERMISSION_TRIGGER_ANIMATION)
        {
            playing = TRUE;
            llStartAnimation(llGetInventoryName(INVENTORY_ANIMATION,0));
        }
    }    
}

 

Link to comment
Share on other sites

46 minutes ago, rjunyeol said:

error "Script trying to stop animations but PERMISSION_TRIGGER_ANIMATION permission not set"

the error comes when the script is transferred to another person while playing = TRUE. When the next owner touches the HUD then the script tries to stopAnimation when it doesn't have permission. What should happen  the first time the HUD is touched by the new owner then playing = FALSE,  so that the script  requests the new owner's permissions

the simple fix is to add a changed event

changed (integer change)
{
   if (change & CHANGED_OWNER)
   {
      playing = FALSE;
   }
}

http://wiki.secondlife.com/wiki/Changed

Edited by Mollymews
whe
  • Like 1
Link to comment
Share on other sites

It may look like overkill, but it's often wise to also do this in the touch_start event:

else if(playing == TRUE)
{
     playing = FALSE;
     if (llGetPermissions() & PERMISSION_TRIGGER_ANIMATION)
     {
          llStopAnimation(llGetInventoryName(INVENTORY_ANIMATION,0));
     }
     else
     {
          llRequestPermissions(llGetOwner(),PERMISSION_TRIGGER_ANIMATION);  // Since this is a HUD, you know that the toucher is the owner
     }
}

And then modify your run_time_permissions event to look like this:

run_time_permissions(integer perm)
{
     if (perm & PERMISSION_TRIGGER_ANIMATION)
     {
          if (playing == FALSE)
          {
               llStartAnimation(llGetInventoryName(INVENTORY_ANIMATION,0));
          }
          else
          {
               llStopAnimation(llGetInventoryName(INVENTORY_ANIMATION,0));
          }
          playing = !playing;
     }
}

 

  • Like 2
Link to comment
Share on other sites

Or, since it's a HUD, so it's intended to be worn when used, this should be all you need

	state_entry()
	{
		if(llGetAttached()){
			llRequestPermissions(llGetOwner(),PERMISSION_TRIGGER_ANIMATION);
		}
	}
	attach(key id)
	{
		if(id){
			llRequestPermissions(id,PERMISSION_TRIGGER_ANIMATION);
		}
	}

ETA:  All my scripts for HUDs ask for permissions in state entry if worn, so I don't have to keep on attaching and detaching them during development and testing.

Edited by Innula Zenovka
  • Like 3
Link to comment
Share on other sites

12 hours ago, Mollymews said:

the error comes when the script is transferred to another person while playing = TRUE. When the next owner touches the HUD then the script tries to stopAnimation when it doesn't have permission. What should happen  the first time the HUD is touched by the new owner then playing = FALSE,  so that the script  requests the new owner's permissions

the simple fix is to add a changed event

changed (integer change)
{
   if (change & CHANGED_OWNER)
   {
      playing = FALSE;
   }
}

http://wiki.secondlife.com/wiki/Changed

Thank you! the error is gone. However, I notice that I have to click the HUD twice for the animation to activate. Any way to fix that?

 

8 hours ago, Rolig Loon said:

It may look like overkill, but it's often wise to also do this in the touch_start event:

else if(playing == TRUE)
{
     playing = FALSE;
     if (llGetPermissions() & PERMISSION_TRIGGER_ANIMATION)
     {
          llStopAnimation(llGetInventoryName(INVENTORY_ANIMATION,0));
     }
     else
     {
          llRequestPermissions(llGetOwner(),PERMISSION_TRIGGER_ANIMATION);  // Since this is a HUD, you know that the toucher is the owner
     }
}

And then modify your run_time_permissions event to look like this:

run_time_permissions(integer perm)
{
     if (perm & PERMISSION_TRIGGER_ANIMATION)
     {
          if (playing == FALSE)
          {
               llStartAnimation(llGetInventoryName(INVENTORY_ANIMATION,0));
          }
          else
          {
               llStopAnimation(llGetInventoryName(INVENTORY_ANIMATION,0));
          }
          playing = !playing;
     }
}

 

I copied your code over but I keep getting syntax errors. Sorry I don't know anything about scripts so I'm not sure what I'm doing wrong. I did put it where you said  to.

 

6 hours ago, Innula Zenovka said:

Or, since it's a HUD, so it's intended to be worn when used, this should be all you need

	state_entry()
	{
		if(llGetAttached()){
			llRequestPermissions(llGetOwner(),PERMISSION_TRIGGER_ANIMATION);
		}
	}
	attach(key id)
	{
		if(id){
			llRequestPermissions(id,PERMISSION_TRIGGER_ANIMATION);
		}
	}

ETA:  All my scripts for HUDs ask for permissions in state entry if worn, so I don't have to keep on attaching and detaching them during development and testing.

On key id I'm supposed to put the id of the hud? I don't know how to get that. But I also kept getting syntax errors. 

 

Thanks all for your help but if you can please be more specific where I have to paste the code you're giving me and how the whole code is supposed to look like cause I can't seem to fix these syntax errors.

Link to comment
Share on other sites

1 hour ago, rjunyeol said:

Thanks all for your help but if you can please be more specific where I have to paste the code

The sections of code that I posted are simply straight replacements for the code in your script.  The if (playing == TRUE) block replaces the if (playing == TRUE) code block that is now in your script's touch_start event.  The run_time_permissions block replaces your entire run_time_permissions block. 

As a reminder, if you want someone to write scripts for you, you should be posting in the InWorld Employment forum. The Scripting forum is a place for scripters (and people who are learning to script) to trade ideas.  We rarely post complete scripts for each other, except as examples.

Link to comment
Share on other sites

5 hours ago, Lucia Nightfire said:

Except when we are bored or are showing off, heh.

my thoughts on this

the mood of this forum has changed in recent months

for a long time, many years, the mood of this forum was to not be overly helpful. Based on a premise that scripting is a commercial endeavour and we should not write scripts for our competitors

the effect of this was that this forum had very few people new to scripting, posting to it.  Just the odd experienced scripter asking for help on obscurities. New person often told to go somewhere else for help

then the mood changed a few months ago due to the postings of one new person to the forum, and a lamentation from a elder forum regular. I thought about that and decided to support these two people. Type type code code post post post, like the new person is doing, and what the elder person was lamenting. The lack of help for new people

as a consequence others who had observed the don't help the competitors rule for ages have also starting to go code code post post post as well

new scripters now getting lots more help. code snippets, work flows, engaged conversations, etc. And more and more new people are now posting and becoming engaged with this scripting forum community.  This forum today is now like the the ancient forums, when everybody was new to LSL

back in the ancient days everybody posted code just because they could. Is how we got the wiki and the ancient scripting forums full of scripting wisdom and the travails of the elders in acquiring that wisdom

in another thread I mentioned all the elder old school scripters I miss.  I miss them because they shared their knowledge, and they were never afraid that I newbie scripter would ever eat their scripting lunch.  May be one day in some distant future I might get to a level  where we could have a shared lunch, but even then they will be bringing the main course and I am bringing the entree

is the same beginning to happen now today like it was in the olden days

Some new forum person goes: hi! I am trying to make my lunch. And I go: have an entree to get you started. And they go thanks! And then another person pops in and goes: try this for your main.  New person goes; wow! thanks

then after a bit, new person goes: hey! look how cool is this. I made dessert! Not sure what is going to taste like, but I made it! woohoo! You want some? And we all go woohoo! thanks! and everybody is happy!

then another new scripter person sees all this and posts: Hi! people, I am trying to make dinner but am a bit stuck, here's the ingredients I have and what I think is the recipe. And we go; oooh! dinner!  And go: hmm! that recipe is for lamb, and at the moment all you have is a chicken. I give you a piece of lamb to get you started. And they go: thanks ! and we go: you welcome! and everybody happy

i am enjoying this forum now, is friendly, helpful and welcoming and nobody who is now a elder is afraid of getting their lunch eaten by somebody else

Edited by Mollymews
lack of
  • Like 5
  • Thanks 3
Link to comment
Share on other sites

8 hours ago, Rolig Loon said:

The sections of code that I posted are simply straight replacements for the code in your script.  The if (playing == TRUE) block replaces the if (playing == TRUE) code block that is now in your script's touch_start event.  The run_time_permissions block replaces your entire run_time_permissions block. 

As a reminder, if you want someone to write scripts for you, you should be posting in the InWorld Employment forum. The Scripting forum is a place for scripters (and people who are learning to script) to trade ideas.  We rarely post complete scripts for each other, except as examples.

Yes I replaced them, but I kept getting syntax errors, and I wasn't sure what I messed up.

I'm not asking anyone to write scripts for me, only asked how to fix the error. But you and others provided me with codes and I wanted to try them out, just wasn't working for me. The code I asked help for I'm sure is something very simple and beginner level for all scripters here, so yeah I don't need to hire someone for something like that. I also don't plan to become a scripter. If I need someone to write me an advanced code, I'll definitely pay for it. 

Link to comment
Share on other sites

10 hours ago, rjunyeol said:

On key id I'm supposed to put the id of the hud? I don't know how to get that. But I also kept getting syntax errors. 

 

key id in the attach event is the key of the avatar to whom the HUD is attached.  When the HUD is detached then key id = NULL_KEY

so the code: if (id) ... request permissions.  from the avatar who has attached (is wearing) the HUD

the code snippet that Innula posted is a safer way to do this. Safer than what I posted

 

about the syntax errors

in your OP script delete the state_entry event.  The event clause includes the ending brace } which is on the line above touch start. 

then carefully paste Innula's code snippet where the original state_entry event was

the snippet is a new state_entry event and a new attach event

be very sure that above you newly pasted state_entry event it says

default
{

and below the end brace of the newly pasted attach event it says

touch_start(integer start_param)

for every ending brace there is a matching opening brace {  ...code..  }. When the braces don't match up then we get a syntax error

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

12 hours ago, rjunyeol said:

Thank you! the error is gone. However, I notice that I have to click the HUD twice for the animation to activate. Any way to fix that?

 

I copied your code over but I keep getting syntax errors. Sorry I don't know anything about scripts so I'm not sure what I'm doing wrong. I did put it where you said  to.

 

On key id I'm supposed to put the id of the hud? I don't know how to get that. But I also kept getting syntax errors. 

 

Thanks all for your help but if you can please be more specific where I have to paste the code you're giving me and how the whole code is supposed to look like cause I can't seem to fix these syntax errors.

Sorry, I gave you a code fragment, thinking that you would know how to use it.   I'll explain in more detail.

The attach event fires when an attachment is added or removed.   When it fires, it returns the uuid of the avatar who has just attached the object.   When detached it returns NULL_KEY (a long string of zeros).    

What my code says, in effect, is "as soon as someone adds/wears the HUD, request their  permission to animate  them, and then you can stop worrying about it".

string strAnim;
default
{
    state_entry()
    {
        strAnim = llGetInventoryName(INVENTORY_ANIMATION,0);//get the name of the animation
        if(llGetAttached()){
            llRequestPermissions(llGetOwner(),PERMISSION_TRIGGER_ANIMATION);
        }
    }
    attach(key id)
    {
        if(id){//if someone has just attached the HUD, ask for permission to animate them
            llRequestPermissions(id,PERMISSION_TRIGGER_ANIMATION);
        }
    }

    changed(integer change)
    {
        if(change & CHANGED_INVENTORY){//the contents of the HUD's inventory have changed,
            llResetScript();//so reset the script to force it to check to see if the animation is the same
        }
    }

    run_time_permissions(integer permissions)
    {
        if(permissions & PERMISSION_TRIGGER_ANIMATION){//animation perms granted
            if(llGetInventoryType(strAnim)==INVENTORY_ANIMATION){//check there is actually an animation to play
                llStartAnimation(llGetInventoryName(INVENTORY_ANIMATION,0));//play it
            }

        }
    }

}

 

Edited by Innula Zenovka
  • Like 1
Link to comment
Share on other sites

7 hours ago, Mollymews said:

for a long time, many years, the mood of this forum was to not be overly helpful. Based on a premise that scripting is a commercial endeavour and we should not write scripts for our competitors

The mood changes over time, I think.    I post full scripts when I think that's most useful, but if somebody seems genuinely interested in learning, I often prefer to help them with advice on their specific question, and let them have the satisfaction of making the method work in their script -- I don't want to take away that feeling of achievement when they finally understand and get the thing to work.

I'm delighted to help people with their scripting if they're trying to learn or having difficulties with something and I can help, but we've certainly had periods in the past when some people clearly kept on accepting paid commissions that were well beyond their capabilities and then relied on the forum to bail them out.

 

  • Like 3
Link to comment
Share on other sites

9 hours ago, Mollymews said:

the mood of this forum has changed in recent months

for a long time, many years, the mood of this forum was to not be overly helpful.

That forum-mindset is prevalent everywhere, and for twenty years I have seen group after group around the net decline because the hard core of existing posters have snapped and snarled at newcomers for breaches of etiquette, failure to google for help before asking the forum, and failure to instantly adopt the cosiness of the group mind. I have seen these forums in many diverse areas dwindle as the older regulars died or drifted away and insufficient newcomers stepped in to fill the gaps. It''s no fun saying "I told you so" when those you told aren't there anymore :)

This forum, I am glad to say, has managed to avoid that dead end, and it is indeed due to the regulars making a distinct effort to accept a more diverse range of people.

The payback is a lot of interesting and challenging questions, and new insights either from the newcomers, or because of them asking questions that take us outside of our usual boundaries.

I still agree that simply posting a full script in response to a question is a mistake, it doesn't encourage the newcomers to learn, it is often too specific to illustrate more general points, and it obviously robs some scripters of revenue. My approach for years has been that I will always those who will try and help themselves.

  • Like 3
Link to comment
Share on other sites

On 10/24/2021 at 11:58 PM, Innula Zenovka said:

we've certainly had periods in the past when some people clearly kept on accepting paid commissions that were well beyond their capabilities and then relied on the forum to bail them out.

 

On 10/25/2021 at 1:49 AM, Profaitchikenz Haiku said:

it obviously robs some scripters of revenue.

just on this part

is true that sometimes people hang out their scripter-for-hire shingle then take on jobs which are beyond their capabilities. Under and over price their work as well.  This is true of all creative fields

and sometimes the customer turns up on the forums also looking for somebody else to complete the job

disappointment comes with the territory tho sometimes. As anyone who got promised a bathroom upgrade completed in two weeks and 4 weeks later are still looking at a empty space where the wash stand is supposed to be. And the builder goes something something slow container ship, when before ripping the old wash stand out they earnestly promised that the new wash stand would be here tomorrow

which just happens to be my current situation. I am like a olden days pioneer now, I do everything now in the kitchen sink.  All I need to compete the set is wood range to cook on and boil bath water and I will be totes pioneer!  I now have  a delivery date of 16th of next month. Oh! well! Keep smiling and looking for happiness. At least I have a private indoor well, not like some people way worse off than me.  Is not like I have to trudge 2 kms everyday to the village well for water :)

 

  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1069 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...