Jump to content

Script : Stop Listenning /working to owner only - object


Svenn007
 Share

Recommended Posts

Hello talented scripters.

I need some help to set a Full perm script i bought ,  making able to  create a text in a prim

The Display script , making the menu  , seems accessible only for the owner .  There is a line somewhere to change but each time i tried , i have an error  :s   >    I want ..  ( yeah not usual )  ... everybody be able to use it .

PLease ..  be my hero  ?   Thank You in advance

 

Here is the end of the  script :

 

   }

    touch_start(integer num_detected)
    {
        owner = llGetOwner();
        if (owner == llDetectedKey(0)) {
            // Show menu to the owner only.
            llDialog(owner, "What would you like to customize?",["Text","Font","Color"],com_channel);
            listener = llListen(com_channel, "", llGetOwner(), "");
        } else {
            llRegionSayTo(llDetectedKey(0), 0, "Sorry you are not authorized to configure me.");                                 
        }
    }

    listen(integer channel, string name, key id, string message)
    {
        llListenRemove(listener);
        // Listen from owner only.
        if (channel== com_channel && id==owner) {
            // Check for message and do accordingly.
            if (message == "Text") {
                selection = "Text";
                listener = llListen(com_channel+1, "", owner, "");
                llTextBox(owner, "Please enter the text you wish to display. (Single line)", com_channel+1);
            } else if (message == "Font") {
                selection = "Font";
                listener = llListen(com_channel, "", owner, "");
                llDialog(owner,"Choose a font.", GetMenuCycle(ALL_FONT_ITEMS, ""), com_channel);
            } else if (message == "Color") {
                selection = "Color";
                listener = llListen(com_channel, "", owner, "");
                llDialog(owner,"Choose a color.", GetMenuCycle(ALL_COLOR_ITEMS, ""), com_channel);
            } else if(message == NEXT_BUTTON && selection == "Font") {
                listener = llListen(com_channel, "", owner, "");
                llDialog(llGetOwner(), "Choose a font.", GetMenuCycle(ALL_FONT_ITEMS, NEXT_BUTTON), com_channel);
            } else if(message == PREV_BUTTON && selection == "Font") {
                listener = llListen(com_channel, "", owner, "");
                llDialog(llGetOwner(), "Choose a font.", GetMenuCycle(ALL_FONT_ITEMS, PREV_BUTTON), com_channel);
            } else if(message == NEXT_BUTTON && selection == "Color") {                
                listener = llListen(com_channel, "", owner, "");
                llDialog(llGetOwner(), "Choose a color.", GetMenuCycle(ALL_COLOR_ITEMS, NEXT_BUTTON), com_channel);
            } else if(message == PREV_BUTTON && selection == "Color") {
                listener = llListen(com_channel, "", owner, "");
                llDialog(llGetOwner(), "Choose a color.", GetMenuCycle(ALL_COLOR_ITEMS, PREV_BUTTON), com_channel);
            } else if (llListFindList(ALL_FONT_ITEMS,[message])>-1) {
                cfont=llList2String(ALL_FONT_MAP,llListFindList(ALL_FONT_MAP,[message])+1);
                llMessageLinked(LINK_SET, 0, cfont, "fw_var: cfont");
            } else if (llListFindList(ALL_COLOR_ITEMS,[message])>-1) {
                ccolor=llList2String(ALL_COLOR_MAP,llListFindList(ALL_COLOR_MAP,[message])+1);
                llMessageLinked(LINK_SET, 0, ccolor, "fw_var: ccolor");
            }
        } else if (channel== com_channel+1 && id==owner) {
            selection = "";
            llMessageLinked(LINK_SET, 0, message, "fw_data : Display");
        }  
    }
}

 

 

Edited by Svenn007
Link to comment
Share on other sites

Get rid of the red lines, and make the small changes in BOLD:

touch_start(integer num_detected)
    {
        owner = llGetOwner();
        if (owner == llDetectedKey(0)) {
            // Show menu to the owner only.
            llDialog(llDetectedKey(0), "What would you like to customize?",["Text","Font","Color"],com_channel);   <<< ---- Change the bold stuff
            listener = llListen(com_channel, "", " ", "");                                                                     <<< --- Notice that llGetOwner() is replaced by " "
        } else {
            llRegionSayTo(llDetectedKey(0), 0, "Sorry you are not authorized to configure me.");                                 
        }

    }

  • Thanks 3
Link to comment
Share on other sites

There are a few more changes that will need to be made, since the listen event also has logic to filter out non-owners, and every followup llTextBox, llDialog, and llListen also use llGetOwner or the global variable owner (which presumably will have the same value as llGetOwner).

Continuing Rolig's suggestion, I presume you'd also want to remove the "&& id==owner" part of the listen event's IF conditionals, as otherwise that would prevent the script from acting on messages from non-owners. Similarly, you would need to change every instance of owner or llGetOwner used in the listen event's llTextBox and llDialog function calls. For these, I would actually suggest changing them to instead be the id variable from the listen event's header. This is because that variable will contain the key of whoever just triggered the listen event. For the llListen function calls, follow the same edit Rolig suggested in the touch_start event: replacing owner with "".

  • Like 1
Link to comment
Share on other sites

Posted (edited)

A Lot of thanks of you both for the help

Changing  Rolig's suggestion make the menu accessible to everybody .  👍

 

Sadly , each button seems inactive since, for me and for others .

 

I copy you what i have changed :

key owner;
integer ITEMS_COUNT = 0;
integer CYCLE_INDEX = 0;
integer COLOR_ITEMS_COUNT = 0;
integer COLOR_CYCLE_INDEX = 0;
integer FONT_ITEMS_COUNT = 0;
integer FONT_CYCLE_INDEX = 0;
integer MAX_DIALOG_BUTTONS = 12;
integer listener;
integer com_channel;
string PREV_BUTTON = "<< Prev";
string NEXT_BUTTON = "Next >>";
string ccolor="c=black;";
string cfont="f=def;";
string selection;

//Fonts
list ALL_FONT_ITEMS = ["DEFAULT","ANDALE","A_PRO","A_PRO_BOLD","DEJAVU","DEJAVU_BOLD","ENVYCODER","FREEFONT","INCONSOLATA","LIBERATION","LIBERATION_B","LUXI","LUXI_BOLD","MONOFUR","NOVA","PROFONT"];
list ALL_FONT_MAP = ["DEFAULT","f=def;","ANDALE","f=e31ce6e8-4117-7073-6aac-e6503034b4c5;","A_PRO", "f=24c4ead5-04cd-1831-5fd9-ec48882e00b1;","A_PRO_BOLD","f=82c4fcac-3990-223c-286d-5bc92a258fbc;","DEJAVU","f=f974fdfc-8fbd-2f29-2b38-3c34411c1fcc;","DEJAVU_BOLD","f=5054fec3-1465-af8f-2fe5-e9507795c82a;","ENVYCODER","f=a2ec2cf0-b207-db51-d4a1-f3f8d6684c07;","FREEFONT","f=05f6f69e-8bdf-a824-a2cf-d91c9e371c23;","INCONSOLATA", "f=867288f9-940e-a7cf-ac7d-5596ea7fb2c5;","LIBERATION","f=c992dfc4-0aca-02c8-bc01-8330e6db6f87;","LIBERATION_B","f=1494337d-5296-3c43-8f7c-45617448ec9a;","LUXI","f=2d8f52d7-2220-2d7a-15b5-e685a9449e5c;","LUXI_BOLD","f=03812794-535b-f546-6171-6bec5bf399be;","MONOFUR","f=8fc63e35-a18f-e335-3936-e2ca196a944d;","NOVA","f=2df8e09d-e1bd-d17f-6bec-b8d713790380;","PROFONT","f=45a8e6f6-90e4-299d-d3bc-0bf4dbf170db;"];

//Colors
list ALL_COLOR_ITEMS = ["DEFAULT","WHITE","SILVER","GRAY","BLACK","RED","GREEN","BLUE","CYAN","MAGENTA","YELLOW","DARKRED","DARKGREEN","DARKBLUE","DARKCYAN","DARKMAGENTA","DARKYELLOW"];
list ALL_COLOR_MAP = ["DEFAULT","c=def;","WHITE","c=white;","SILVER","c=silver;","GRAY","c=gray;","BLACK","c=black;","RED","c=red;", "GREEN","c=green;","BLUE","c=blue;","CYAN","c=cyan;","MAGENTA","c=magenta;","YELLOW","c=yellow;","DARKRED","c=darkred;","DARKGREEN","c=darkgreen;","DARKBLUE","c=darkblue;","DARKCYAN","c=darkcyan;","DARKMAGENTA","c=darkmagenta;","DARKYELLOW","c=darkyellow;"];

//Menu cycle method
list GetMenuCycle(list items, string direction)
{
    if (selection == "Font") {
        ITEMS_COUNT = FONT_ITEMS_COUNT;
        CYCLE_INDEX = FONT_CYCLE_INDEX;
    } else {
        ITEMS_COUNT = COLOR_ITEMS_COUNT;
        CYCLE_INDEX = COLOR_CYCLE_INDEX;
    }
    list sublist = [];
    ITEMS_COUNT = llGetListLength(items);
    if(direction == PREV_BUTTON)
    {
        if(CYCLE_INDEX > 0)
            CYCLE_INDEX--;
    }
    else if(direction == NEXT_BUTTON)
        CYCLE_INDEX++;
    if(CYCLE_INDEX == 0)
    {
        if(ITEMS_COUNT <= MAX_DIALOG_BUTTONS)            
            sublist = llList2List(items, 0, ITEMS_COUNT - 1);
        else
        {
            sublist = llList2List(items, 0, MAX_DIALOG_BUTTONS - 2);
            sublist += [NEXT_BUTTON];
        }
    }
    else
    {
        integer start_index = 0;
        start_index = (MAX_DIALOG_BUTTONS - 1) + ((CYCLE_INDEX - 1) * (MAX_DIALOG_BUTTONS - 2));
        integer items_left = ITEMS_COUNT - start_index;
        if(items_left > MAX_DIALOG_BUTTONS - 2)
        {
            sublist = llList2List(items, start_index, start_index + (MAX_DIALOG_BUTTONS - 3));
            sublist = [PREV_BUTTON] + sublist + [NEXT_BUTTON];
        }
        else
        {
            sublist = llList2List(items, start_index, ITEMS_COUNT - 1);
            sublist = [PREV_BUTTON] + sublist;
        }
    }
    if (selection == "Font") {
        FONT_ITEMS_COUNT = ITEMS_COUNT;
        FONT_CYCLE_INDEX = CYCLE_INDEX;
    } else {
        COLOR_ITEMS_COUNT = ITEMS_COUNT;
        COLOR_CYCLE_INDEX = CYCLE_INDEX;
    }
    return sublist;
}

default
{
    state_entry()
    {
        // Reset the FURWARE text script.
        llMessageLinked(LINK_SET, 0, "", "fw_reset");
        com_channel = (integer) ("0x" + llGetSubString ((string) llGetKey (), -8, -1)) | 0x80000000;    
    }

    link_message(integer sender, integer num, string str, key id) {
        // The text script sends "fw_ready" when it has initialized itself.
        if (id == "fw_ready") {
            llMessageLinked(LINK_SET, 0, ccolor, "fw_var: ccolor");
            llMessageLinked(LINK_SET, 0, cfont, "fw_var: cfont");
            llMessageLinked(LINK_SET, 0, "style=ccolor;style=cfont;a=center;w=none", "fw_defaultconf");
            llMessageLinked(LINK_SET, 0, "-Default text-", "fw_data : Display");
            //llMessageLinked(LINK_SET, 0, "c=yellow; a=center; f=45a8e6f6-90e4-299d-d3bc-0bf4dbf170db", "fw_conf : Display");
        }
    }

    touch_start(integer num_detected)
    {
        
        
            llDialog(llDetectedKey(0), "What would you like to customize?",["Text","Font","Color"],com_channel);
            listener = llListen(com_channel, "", "", "");
       
    }

    listen(integer channel, string name, key id, string message)
    {
        llListenRemove(listener);
        // Listen from owner only.
        if (channel== com_channel && id=="") {
            // Check for message and do accordingly.
            if (message == "Text") {
                selection = "Text";
                listener = llListen(com_channel+1, "", "", "");
                llTextBox(owner, "Please enter the text you wish to display. (Single line)", com_channel+1);
            } else if (message == "Font") {
                selection = "Font";
                listener = llListen(com_channel, "", "", "");
                llDialog("","Choose a font.", GetMenuCycle(ALL_FONT_ITEMS, ""), com_channel);
            } else if (message == "Color") {
                selection = "Color";
                listener = llListen(com_channel, "", "", "");
                llDialog("","Choose a color.", GetMenuCycle(ALL_COLOR_ITEMS, ""), com_channel);
            } else if(message == NEXT_BUTTON && selection == "Font") {
                listener = llListen(com_channel, "", "", "");
                llDialog("", "Choose a font.", GetMenuCycle(ALL_FONT_ITEMS, NEXT_BUTTON), com_channel);
            } else if(message == PREV_BUTTON && selection == "Font") {
                listener = llListen(com_channel, "", "", "");
                llDialog("", "Choose a font.", GetMenuCycle(ALL_FONT_ITEMS, PREV_BUTTON), com_channel);
            } else if(message == NEXT_BUTTON && selection == "Color") {                
                listener = llListen(com_channel, "", "", "");
                llDialog("", "Choose a color.", GetMenuCycle(ALL_COLOR_ITEMS, NEXT_BUTTON), com_channel);
            } else if(message == PREV_BUTTON && selection == "Color") {
                listener = llListen(com_channel, "", "", "");
                llDialog("", "Choose a color.", GetMenuCycle(ALL_COLOR_ITEMS, PREV_BUTTON), com_channel);
            } else if (llListFindList(ALL_FONT_ITEMS,[message])>-1) {
                cfont=llList2String(ALL_FONT_MAP,llListFindList(ALL_FONT_MAP,[message])+1);
                llMessageLinked(LINK_SET, 0, cfont, "fw_var: cfont");
            } else if (llListFindList(ALL_COLOR_ITEMS,[message])>-1) {
                ccolor=llList2String(ALL_COLOR_MAP,llListFindList(ALL_COLOR_MAP,[message])+1);
                llMessageLinked(LINK_SET, 0, ccolor, "fw_var: ccolor");
            }
        } else if (channel== com_channel+1 && id=="") {
            selection = "";
            llMessageLinked(LINK_SET, 0, message, "fw_data : Display");
        }  
    }
}

 

Edited by Svenn007
Link to comment
Share on other sites

I may have been unclear.

9 hours ago, Svenn007 said:

if (channel== com_channel && id=="")

The above part is incorrect. Once you are inside a listen event, the key of the speaker (which in this case is contained in the id variable) will never be equal to null (which is what "" signifies). The statement, as currently written, will cause the test to always fail and prevent the rest of the code from being run. To fix, delete the part I highlighted in red. And do the same thing for the other IF statement at the bottom of the listen event.

 

9 hours ago, Svenn007 said:

llTextBox(owner, "Please enter the text you wish to display. (Single line)", com_channel+1);

You're still using the owner variable here, which is also incorrect. It's incorrect because ostensibly, that variable would have contained the key of the object's owner - which means the function would only ever send the text box to the owner. But in practice, that variable isn't actually being given any value now, since you've removed that bit of code as per Rolig's advice. I suggest you replace the highlighted section with the id variable. The id variable in the listen event will always contain the key of the speaker who triggered the listen event - which means you can use it to send the text box back to the person who sent the triggering message, regardless who it is.

 

9 hours ago, Svenn007 said:

llDialog("","Choose a font.", GetMenuCycle(ALL_FONT_ITEMS, ""), com_channel);

Similar to llTextbox, the first parameter needs to be the key of who you want to send the textbox/dialog to. If the value is empty (""), then you're literally sending it to nobody. As with the previous example, I suggest you use the id variable here, for the same reason. Repeat that for all the other instances of llDialog in the listen event.

Edited by Fenix Eldritch
typos
  • Thanks 1
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...