Jump to content

Trouble creating multiple rezzers


AdminGirl
 Share

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

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

Recommended Posts

Hi

I've been trying to set up rezzers for decor purposes so I can change to different scenes via clicking, and I've been working with this script, most of which was from the sl forum archive.

The problem I'm having is that when I have more than one rezzer, touching one  seems to affect the others. For example, if I had two rezzers, and I click on rezzer 1, rezzer 2 will somehow recognise that it has been touched (when it has not), and it will run the dialog menu and try and rezz out the object as well. How can I make this script work independently regardless of how many other rezzers are present?

What I'm trying to do is have one rezzer for a table, another for the deck, etc.

 

list MENU1 = [];
list MENU2 = [];
integer listener;
integer MENU_CHANNEL = 1000;

string mainMenuDialog = "\nWhich settings would you like to access?\nClick \"Close\" to close the menu.\n\nYou are here:\nMainmenu";
list mainMenuButtons = ["sub 01", "sub 02", "Close"];
 
string subMenu_01_Dialog = "\nClick \"Close\" to close the menu.\nClick \"-Main-\" to return to the main menu.\n\nYou are here:\nMainmenu > sub 01";
list subMenu_01_Buttons = ["action 01a", "action 01b", "Close", "-Main-"];
 
string subMenu_02_Dialog = "\nClick \"Close\" to close the menu.\nClick \"-Main-\" to return to the main menu.\n\nYou are here:\nMainmenu > sub 02";
 
list subMenu_02_Buttons = ["action 02a", "action 02b", "Close", "-Main-"];
 
integer dialogChannel;
integer dialogHandle;
 
 
Dialog(key id, list menu)
{
    llListenRemove(listener);
    listener = llListen(MENU_CHANNEL, "", NULL_KEY, "");
    llDialog(id, "Select one object below: ", menu, MENU_CHANNEL);
}

open_menu(key inputKey, string inputString, list inputList)
{
    dialogChannel = (integer)llFrand(DEBUG_CHANNEL)*-1;
    dialogHandle = llListen(dialogChannel, "", inputKey, "");
    llDialog(inputKey, inputString, inputList, dialogChannel);
    llSetTimerEvent(30.0);
}

close_menu()
{
    llSetTimerEvent(0.0);// you can use 0 as well to save memory
    llListenRemove(dialogHandle);
}
 
default
{
    on_rez(integer num)
    {
        llResetScript();
    }
 
    touch_start(integer total_number)
    {
        integer i = 0;
        MENU1 = [];
        MENU2 = [];
        integer c = llGetInventoryNumber(INVENTORY_OBJECT);
        if (c <= 12)
        {
            for (; i < c; ++i)
                MENU1 += llGetInventoryName(INVENTORY_OBJECT, i);
                llShout(-193245,"Clean_Your_Room"); //Tell Rezzed prim to Go Away
                llSleep(0.5); //Give Prim A chance to go Away
                close_menu();
        }
        else
        {        
            for (; i < 11; ++i)
                MENU1 += llGetInventoryName(INVENTORY_OBJECT, i);
            if(c > 22)
                c = 22;
            for (; i < c; ++i)
                MENU2 += llGetInventoryName(INVENTORY_OBJECT, i); 
            MENU1 += ">>";
            MENU2 += "<<";
            llShout(-193245,"Clean_Your_Room"); //Tell Rezzed prim to Go Away
            llSleep(0.5); //Give Prim A chance to go Away
            close_menu();                          
        }
        Dialog(llDetectedKey(0), MENU1);
    }
 
    listen(integer channel, string name, key id, string message) 
    {
        if (channel == MENU_CHANNEL)
        {
            llListenRemove(listener);  
            if (message == ">>")
            {
                Dialog(id, MENU2);
            }
            else if (message == "<<")
            {
                Dialog(id, MENU1);
            }        
            else                    
            {
                // todo add offsets so box sites perfect on rezzer 
                llRezAtRoot(message, llGetPos(), ZERO_VECTOR, llGetRot(), 0);
            }      
        }
    }  
}

 

Link to comment
Share on other sites

change the menu channel for the different rezzers..:)

after the touch_start you can run

  MENU_CHANNEL= (integer)(llFrand(-1000000000.0) - 1000000000.0);

This will generate a new random channel every time the object is touched, and so there will be no cross talk between devices.

enjoy...

Dargs

Edited by Kardargo Adamczyk
  • Thanks 1
Link to comment
Share on other sites

The menu listener is always listening - so every rezzer in range will get and excute a menu choice. Changing the channel for every listener "solves" your problem but still leaves an unnecessary listener open for every rezzer.

Minimal solution (I am too lazy to rewrite that thing):

put into the "Dialog" function:

llSetTimerEvent(30);

and add a timer event with:

close_menu();

 

  • Thanks 1
Link to comment
Share on other sites

you might want to narrow the dialog listener down to the person who touched the rezzer

otherwise if I came to your parcel and saw you with your rezzer then as wrote I could type in chat: /1000 >>

which would change the page on a multi-page dialog menu on your screen. And then freak you out totally by typing /1000 <<. and then /1000 >> again. Flip flip flip 😸

in the Dialog function change to:

listener = llListen(MENU_CHANNEL, "", id, "");

with MENU_CHANNEL then as has been mentioned already, pick a channel number for each rezzer yourself, where every rezzer you make has its own unique channel.  I would not recommend use llFrand to generate a channel for your rezzers, as using a random function creates a potential for your rezzer scripts to collide. The same colliding problem which led to your OP question

Edited by Mollymews
typ
  • Thanks 1
Link to comment
Share on other sites

  • 2 weeks later...
You are about to reply to a thread that has been inactive for 1200 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...