Jump to content

Trigger word script animation not working!


Morgan Mode
 Share

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

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

Recommended Posts

I want the word "ass" in chat to trigger a twerk animation. I've named everything correctly but the animation doesn't trigger. Is my script wrong?

Quote

//start_unprocessed_text
/*string animation = "twerk";
default
{
    state_entry()
    {
        llListen(0,"","","ass");
        llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);                
    }

    listen(integer channel, string name, key id, string message)
    {
        if (message == "ass")
        {
            llStartAnimation(animation);
        }
    }

    run_time_permissions(integer permissions)
    {
        if (permissions & PERMISSION_TRIGGER_ANIMATION)
        {
            return;
        }
        else
        {
            llOwnerSay("can not trigger animation, detaching");
                llDetachFromAvatar();
        }
    }
}*/
//end_unprocessed_text
//nfo_preprocessor_version 0
//program_version Firestorm-releasex64 6.2.4.57588 - WilliamBeauclerc
//last_compiled 07/24/2019 17:43:58
//mono




string animation = "twerk";
default
{
    state_entry()
    {
        llListen(0,"","","ass");
        llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);                
    }

    listen(integer channel, string name, key id, string message)
    {
        if (message == "ass")
        {
            llStartAnimation(animation);
        }
    }

    run_time_permissions(integer permissions)
    {
        if (permissions & PERMISSION_TRIGGER_ANIMATION)
        {
            return;
        }
        else
        {
            llOwnerSay("can not trigger animation, detaching");
                llDetachFromAvatar();
        }
    }
}

 

I have purchased this script from a creator, please don't use without permission.

Edited by Morgan Mode
Including details.
Link to comment
Share on other sites

You don't need to ask 

if (message == "ass")

since you already filtered for that in the llListen statement, but the redundancy shouldn't keep it from working unless you're typing "ass" incorrectly.  My guess is that Wulfie's right.. Try writing the listen handler as 

llListen (0,"","","");

and then asking 

if ( llStringTrim( llToLower( message ), STRING_TRIM) == "ass" )

and then 

be sure that you have the anim named correctly.

Oh, and avoid listening on channel 0 unless you really need to.

Edited by Rolig Loon
  • Thanks 1
Link to comment
Share on other sites

2 minutes ago, Morgan Mode said:

So it works, but it doesn't get triggered by other people's chats or the messages sent out by spankers. How can i get it to recognize the slapper text? Also does the script allow for the animation to only play once? I don't want it to loop.

As the script is now, the animation will only play if someone says "ass" and nothing else. "Someone slapped your ass." will not be detected. The script would need to be modified slightly.

Whether the animation loops or not is determined by the animation itself. Animations either loop or they don't, a script cannot loop a non-looping animation or the other way.

Link to comment
Share on other sites

Something like this:

llListen (0, "", "", "");

if (llSubStringIndex (message, "ass") > -1)
{
    llStartAnimation (animation);
}

This checks if the string "ass" appears anywhere in the incoming message. It will respond positively if the message contains words like "bass" or "Cassiopeia" as well as just "ass".

It is possible, though considerably more involved, to check if "ass" appears as a stand-alone word rather than as part of a longer word.

 

  • Thanks 1
Link to comment
Share on other sites

Yes, you set the timer when you start the animation (10 seconds in this case):

llStartAnimation (animation);
llSetTimerEvent (10.0);

and in the timer event you stop the timer and the animation:

timer ()
{
    llSetTimerEvent (0.0);
    llStopAnimation (animation);
}

One other thing (probably redundant now you've found a suitable script) is that in order to use llDetachFromAvatar () you need to have asked for permissions to do so:

llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION | PERMISSION_ATTACH);

  • Thanks 1
Link to comment
Share on other sites

So, now it's time to look back at what I said at the end of my earlier post:

11 hours ago, Rolig Loon said:

Oh, and avoid listening on channel 0 unless you really need to.

When you listen on the public chat channel (channel 0), the servers are being told to pay attention to every single thing that is said in the region and then decide how much of that is within your own chat range.  That's a lot of listening, even if nobody says anything. Now, if someone does say something, you are going to ask the servers to listen to every single word and decide whether the word is "ass."  That's a lot of extra work, especially if there are lots of people saying things, as in a club, for example.  This is the sort of script that can create measurable chat lag and get people really ticked.  A bad idea.  That's why one of the basic rules that responsible scripters learn very early on is 

11 hours ago, Rolig Loon said:

Oh, and avoid listening on channel 0 unless you really need to.

 

  • Like 2
Link to comment
Share on other sites

2 minutes ago, Rolig Loon said:

When you listen on the public chat channel (channel 0), the servers are being told to pay attention to every single thing that is said in the region and then decide how much of that is within your own chat range.  That's a lot of listening, even if nobody says anything. Now, if someone does say something, you are going to ask the servers to listen to every single word and decide whether the word is "ass."  That's a lot of extra work, especially if there are lots of people saying things, as in a club, for example.  This is the sort of script that can create measurable chat lag and get people really ticked.  A bad idea.  That's why one of the basic rules that responsible scripters learn very early on is 

While I agree with you in principle and on a grander(?) scale, I think you're blowing this a little out of proportion in context.

  • Primarily the emphasis on "every single word," not really. Still just each message as a whole, no extra work for the sim besides skipping the string-matching.
  • Pattern-searching a string is not a very expensive method, and since that's pretty much all the script is doing, you can't even leverage the script-lag argument.
  • This seems like it's probably going to be used by very few people, and even if 100 people on sim was using it, the chat lag from the sim checking for those 100 scripts would almost definitely not be noticeable.

Here's where my agreements come in. "Don't listen public chat" is a good mantra so we don't accidentally end up in a bad situation in the future (I wish we had a similar mantra for high poly mesh), but for some use-cases it just can't be avoided. In this case they want an animation to play when someone else's script is triggered (which talks in public chat), so there are few (if any) options unless the creator of that other object has already taken this situation into account and it's talking in two channels at the same time.

  • Like 2
Link to comment
Share on other sites

27 minutes ago, Wulfie Reanimator said:

Here's where my agreements come in. "Don't listen public chat" is a good mantra so we don't accidentally end up in a bad situation in the future (I wish we had a similar mantra for high poly mesh), but for some use-cases it just can't be avoided. In this case they want an animation to play when someone else's script is triggered (which talks in public chat), so there are few (if any) options unless the creator of that other object has already taken this situation into account and it's talking in two channels at the same time.

Agreed.  Hence "... unless you really need to."  Sometimes you really need to, because there's there's no other way to do the job.  This may be one of those cases.  It's still worth asking whether the whole script is worth doing.  Rather than offend the OP, let me point to a different example -- tummy talkers -- which are widely regarded as a scourge on the SL landscape.  There's probably no way to make a tummy talker work more efficiently, but that doesn't make tummy talkers a good idea.  Whoever thought up the product in the first place should have taken a step back and asked, "Should I really be creating this?"

  • Like 1
Link to comment
Share on other sites

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