Jump to content

Owner only controlled Dialog script


Queenship3001
 Share

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

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

Recommended Posts

So, I have a script that will change colors on a linked set of prims via llDialog. However, and I realize it's probably staring me in the face and I'm blind, I can't figure out how to make it so it's owner accessed only. The closest I got was making it so when other people click the prim, they don't get a mnu, however I do... That's VERY annoying... I did look for other threads about thios, but it always seems to be about the llDialog function itself, not who specifically can use it. If there IS a thread about it, link it, I'll try it, if it works, I'll delete this thread (I can delete my own threads, right?). Until then, this is my current script.:

 

list colors = ["Red", "Yellow", "Blue", "Pink", "Green", "White", "Purple", "Orange"];
string msg = "What do you want your new color to be?";
key owner;
integer channel;
integer listener;

default
{
    state_entry()
    {
        channel = -1 - (integer)("0x" + llGetSubString( (string)llGetKey(), -7, -1) );
    }
    
    touch_start(integer num_detected)
    {
        owner = llGetOwner();
        llListenRemove(listener);
        listener = llListen(channel, "", owner, "");
        llDialog(owner, msg, colors, channel);
        llSetTimerEvent(60.0);
    }
    
    listen(integer channel, string name, key id, string message)
    {
        if(message=="Red")
        {
            llSetLinkColor(LINK_ALL_CHILDREN, <1.000, 0.255, 0.212>, ALL_SIDES);
        }
        if(message=="Yellow")
        {
            llSetLinkColor(LINK_ALL_CHILDREN, <1.000, 0.863, 0.000>, ALL_SIDES);
        }
        if(message=="Blue")
        {
            llSetLinkColor(LINK_ALL_CHILDREN, <0.000, 0.455, 0.851>, ALL_SIDES);
        }
        if(message=="Pink")
        {
            llSetLinkColor(LINK_ALL_CHILDREN, <0.941, 0.071, 0.745>, ALL_SIDES);
        }
        if(message=="Green")
        {
            llSetLinkColor(LINK_ALL_CHILDREN, <0.180, 0.800, 0.251>, ALL_SIDES);
        }
        if(message=="White")
        {
            llSetLinkColor(LINK_ALL_CHILDREN, <1.0, 1.0, 1.0>, ALL_SIDES);
        }
        if(message=="Purple")
        {
            llSetLinkColor(LINK_ALL_CHILDREN, <0.694, 0.051, 0.788>, ALL_SIDES);
        }
        if(message=="Orange")
        {
            llSetLinkColor(LINK_ALL_CHILDREN, <1.000, 0.522, 0.106>, ALL_SIDES);
        }
    }
    
    timer()
    {
        llSetTimerEvent(0);
        llListenRemove(listener);
    }
}

 All I need is to know how to make it so anyone who ISN'T the owner unable to use the dialog and prims.

Link to comment
Share on other sites

You are almost there.

Try making some alterations on these lines:

	state_entry()	{		owner = llGetOwner(); //set value of owner here, rather than keep looking it up		channel = -1 - (integer)("0x" + llGetSubString( (string)llGetKey(), -7, -1) );	}	changed(integer change)	{		if (change & CHANGED_OWNER){//if the owner of the object changes			llResetScript();//reset script to reset value of owner		}	}		touch_start(integer num_detected)	{		if (llDetectedKey(0)==owner){//if the toucher is my owner			llListenRemove(listener);			listener = llListen(channel, "", owner, "");			llDialog(owner, msg, colors, channel);			llSetTimerEvent(60.0);		}	}

 

Link to comment
Share on other sites

So like I said, the script above works. However, I didn't plan on being so..... excentric... with my avatar mod. Meaning I have 9 attachments that, using the above script, would need to be indavidually clicked. This does not bode for good reviews on my product, So I've tried looking in to having a controller script to change the color of all the attachments at once. Now in THEORY, it looks right to me. The reality is I'm wrong and nothing happens.

 

Controller script:

list colors = ["Delete Script", "Red"];string msg = "What do you want your new color to be?";key owner;integer channel;integer listener;integer fullbright;default{    state_entry()    {        owner = llGetOwner(); //set value of owner here, rather than keep looking it up        channel = 677 - (integer)("0x" + llGetSubString( (string)llGetKey(), -7, -1) );    }        changed(integer change)    {        if (change & CHANGED_OWNER)        {//if the owner of the object changes            llResetScript();//reset script to reset value of owner        }    }        touch_start(integer num_detected)    {        if (llDetectedKey(0)==owner)        {            llListenRemove(listener);            listener = llListen(channel, "", owner, "");            llDialog(owner, msg, colors, channel);            llSetTimerEvent(60.0);        }    }    listen(integer channel, string name, key id, string message)    {        if(message=="Red")        {            llRegionSay(676, "Red");        }        if(message=="Delete Script")        {            llRegionSay(676, "Delete");        }    }        timer()    {        llSetTimerEvent(0);        llListenRemove(listener);    }}

 

Listener/Color change script(s):

integer channel = 676;
integer listening;
integer fullbright;

default
{
    state_entry()
    {
        channel - (integer)("0x" + llGetSubString( (string)llGetKey(), -7, -1) );
    }
    listen(integer channel, string name, key id, string message)
    {
        llListen(channel, "", NULL_KEY, "");
        if(message=="Red")
        {
            llSetLinkColor(LINK_ALL_CHILDREN, <1.000, 0.255, 0.212>, ALL_SIDES);
        }

        else if(message=="Delete")
        {
            llRemoveInventory(llGetScriptName());
        }
    }
    
    timer()
    {
        llSetTimerEvent(0);
        llListenRemove(listening);
    }
}

 

Now.... Something tells me I'm doing this TOTALLY wrong and need to be barred from ever scripting again.... But for efficiency I'll be making apeals to the court in that event.

Can someone tell me what I'm doing wrong and what needs to be changed?

Link to comment
Share on other sites

A problem -- and probably the one that's causing the trouble -- is that you are calculating the channel based on the uuids of the objects each script is in.  That's what

channel = 677 - (integer)("0x" + llGetSubString( (string)llGetKey(), -7, -1) );

does -- takes the UUID of the prim that contains the script and converts it into an integer.   So the different attachments are using different channels, and no messages are getting through.

Try substituting llGetOwner() for llGetKey() when calculating the channel.

Also (this isn't what's causing the problem, but it's good practice to do it this way) if you use llRegionSayTo(llGetOwner(), someChannel, message), then all the objects that are attached to the owner (or that the owner is sitting on) can hear the message, too, if they're listening on the right channel, and nothing else can).   So try using llRegionSayTo(llGetOwner()... ) too.

 

Link to comment
Share on other sites

Try something like this.   NB -- when you test it, the listening attachments will only hear the message if they're attached, not if they're rezzed on the ground.

key owner;integer CommsChannel;default{	state_entry()	{		owner = llGetOwner(); //set value of owner here, rather than keep looking it up		CommsChannel = 677 - (integer)("0x" + llGetSubString( (string)owner, -7, -1) );//NB change here		//don't use "channel" as a variable name -- risks confusion with the variable in the listen event		llListen(CommsChannel,"","","");	}	listen(integer channel, string name, key id, string message)	{ 		llRegionSayTo(owner,CommsChannel,message);//put this in the listen event of the menu script, to tell the other attachments		//what to do				if("Red"==message){ //put this in all scripts			llSetLinkColor(LINK_ALL_CHILDREN, <1.000, 0.255, 0.212>, ALL_SIDES);		}		else if ("Yellow"==message){			//and so on		}					}}

 

  • Like 1
Link to comment
Share on other sites

 

Controller:

list colors = ["Delete Script", "Red"];string msg = "What do you want your new color to be?";key owner;integer channel;integer listener;integer fullbright;default{    state_entry()    {        owner = llGetOwner(); //set value of owner here, rather than keep looking it up        channel = 677 - (integer)("0x" + llGetSubString( (string)owner, -7, -1) );    }        changed(integer change)    {        if (change & CHANGED_OWNER)        {//if the owner of the object changes            llResetScript();//reset script to reset value of owner        }    }        touch_start(integer num_detected)    {        if (llDetectedKey(0)==owner)        {            llListenRemove(listener);            listener = llListen(channel, "", owner, "");            llDialog(owner, msg, colors, channel);            llSetTimerEvent(60.0);        }    }    listen(integer channel, string name, key id, string message)    {        if(message=="Red")        {            llRegionSayTo(owner,channel,"Red");        }        //if(message=="Delete Script")        //{        //    llRegionSay(676, "Delete");        //}    }        timer()    {        llSetTimerEvent(0);        llListenRemove(listener);    }}

 Prim scripts:

key owner;integer CommsChannel;default{    state_entry()    {        owner = llGetOwner(); //set value of owner here, rather than keep looking it up        CommsChannel = 677 - (integer)("0x" + llGetSubString( (string)owner, -7, -1) );//NB change here        //don't use "channel" as a variable name -- risks confusion with the variable in the listen event        llListen(CommsChannel,"","","");    }    listen(integer channel, string name, key id, string message)    {         llRegionSayTo(owner,CommsChannel,message);//put this in the listen event of the menu script, to tell the other attachments        //what to do                if("Red"==message){ //put this in all scripts            llSetLinkColor(LINK_ALL_CHILDREN, <1.000, 0.255, 0.212>, ALL_SIDES);        }        else if ("Yellow"==message){            //and so on        }                    }}

 Houston! We have turned Red! Took me a minute to figure out what broke initially (Script error?) but I got it xD

Thank you so much ^.^ You've made my life a WHOLE lot easier :D

Link to comment
Share on other sites

Great.  I would take out the  llRegionSayTo(owner,channel,"Red"); from the listener scripts, though.  That needs to be in the transmitter, but not in the listeners.

If you leave it in the listeners, you risk setting up a feedback loop, as all the objects keep relaying the same message to each other until everything crashes.

Link to comment
Share on other sites

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