Jump to content

How to make a prim check the that the toucher is member of a group then display text box if the toucher is.


IdaMoore
 Share

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

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

Recommended Posts

Hello

 

I want to combind these two scripts 

 

default
{
    touch_start(integer total_number)
    {
        if (llDetectedGroup(0) )     //same as llSameGroup(llDetectedKey(0) ) (with llSameGroup, detected must be in the sim)
            llGiveInventory(llDetectedKey(0), llGetInventoryName(INVENTORY_OBJECT, 0) );
        else
            llSay(0, "Wrong active group!");
    }
}
integer  gListener;
default
{
    touch_start(integer total_number)
    {
        // See 'discussion' page for more comments on choosing a channel and possible left-open listener
        integer channel = -13572468;
        // "" saves byte-code over NULL_KEY
        gListener = llListen( channel, "", "", "");     
        llTextBox(llDetectedKey(0), "Some info text for the top of the window...", channel);
    }
    listen(integer channel, string name, key id, string message)
    {
        llListenRemove(gListener);
        llSay(0, "You wrote: " + message);
    }
}

 

1. Check if the avatar that touched have the correct active group.

2.  If yes then open a text box is  where the output comes in local chat name on the prime.

Else : You should receive a text saying that the group is wrong.

 

When i try to combind these two scrips it fails. 

 

 

Link to comment
Share on other sites

When you want to put several statements, as in the touch start event in the second script, into one part of an if statement you need to enclose them in braces, {}, unlike in the first script where there's only a single statement.

integer  gListener;
default
{
    touch_start(integer total_number)
    {
        if (llDetectedGroup(0) )     //same as llSameGroup(llDetectedKey(0) ) (with llSameGroup, detected must be in the sim)
        {
            // See 'discussion' page for more comments on choosing a channel and possible left-open listener
            integer channel = -13572468;
            // "" saves byte-code over NULL_KEY
            gListener = llListen( channel, "", "", "");     
            llTextBox(llDetectedKey(0), "Some info text for the top of the window...", channel);
        }
        else
            llSay(0, "Wrong active group!");
    }
    listen(integer channel, string name, key id, string message)
    {
        llListenRemove(gListener);
        llSay(0, "You wrote: " + message);
    }
}

 

  • Thanks 1
Link to comment
Share on other sites

How does it fail? What does your combined script look like?

As a matter of course, check out the documentation on the wiki regarding the IF THEN ELSE flow control in LSL. It will give you examples with explanations.

Breaking the logic down by writing out what you want to happen can help (as you've already done). The next step is to translate that into LSL bit by bit.

"IF the avatar that touched the object has the same active group, THEN do stuff. ELSE warn them with a message."

Your first script does exactly that, except the "stuff" it does is a single command of offering inventory. So you would want to replace that with the commands from the other script. When you want your IF statement to perform multiple commands on a given branch, you should enclose each branch within curly braces {} to define the scope - basically, their contents. (Notice how each event uses curly braces to define their scope in a similar way)

if(condition)
{
	//do stuff if condition evaluated to TRUE
}
else
{
	//otherwise do this stuff if condition evaluated to FALSE
}

In this case, your condition would be (llDetectedGroup(0)). The TRUE branch would contain the 2nd script's commands to define the channel, open the listener, and generate the textbox. And the FALSE branch would have the warning message.

And of course, you would copy over the rest of the stuff from the 2nd script: the global variable and the entire listen event.

If you are very new to scripting (or programming in general), I highly recommend spending some time reading through the tutorials on the wiki. They have some good beginners documents that can get a newcomer up to speed on the basics.

https://wiki.secondlife.com/wiki/Category:LSL_Tutorials

  • Thanks 1
Link to comment
Share on other sites

Thanks!! 🙂

 

I had this Included in the IF

 

    }
    listen(integer channel, string name, key id, string message)
    {
        llListenRemove(gListener);
        llSay(0, "You wrote: " + message);
    }
}

 

But putting it after IF / ELSE  like in your example worked perfect! 

Many thanks!

Link to comment
Share on other sites

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