Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Dilemma - Please Help *pouts* :(

Ryker Beck
Photographer & Designer
Join date: 23 Feb 2007
Posts: 57
09-28-2008 08:59
I could CRY. ugh.

This script below works perfectly for myself. I can see all the menu items, control everything fine, etc etc. But as soon as I hand it off to someone else... that's when hell breaks loose.

Basically, what this script is supposed to do is, upon clicking the item, display a menu of "Metals" and "Stones". The Metals menu has a choice of Gold and Silver. The Stones has a choice of 1-5. Choosing a metal will change the item to that metal. Choosing a stone number will display how many stones appear on the item. That all works great -- for the creator of the script/item.

When I hand the item to someone else though, they can click on the item and see the first menu... and that's it. They cannot navigate to the submenus (i.e. they can hit the "Metals" menu tab in the main menu, but it does not show the submenu where they can choose "Gold" or "Silver";). But to make this more interesting... If there are two of the items rezzed at once, one belonging to the CREATOR of the item, the other belonging to the other person... if the CREATOR of the item controls HER item (i.e. clicks the item and sees the main menu, then navigates to a submenu) the CREATOR's menu will control the OTHER person's menu as well.

So for example, if I am the creator, and I had two of these items rezzed (one belonging to my friend, the other belonging to me), and i were to click on MY item and select "Metals"... both MY menu and my FRIEND'S metal menu would display on MY screen, and HER metal menu would display on HER screen without her ever clicking anything at all.

I hope that's not too confusing... but if I could get some help deciphering why this is being such a pickle, I'd really appreciate it. Thanks!

CODE

key owner;
integer channel;
list MENU_MAIN = ["Metals", "Stones"]; // the main menu
list METALS = ["Gold", "Silver", "BACK"];
list STONES = ["1" , "2" , "3" , "4", "5", "BACK"];


default
{
state_entry()
{
owner = llGetOwner();
channel= (integer)(llFrand(-1000000000.0));
llListen(channel, "", owner, ""); // change to CHANNEL
}

touch_start(integer x)
{
owner = llGetOwner();
if (llDetectedOwner(0) == owner)
{
llDialog(llDetectedOwner(0), "..:: Genesis ::.. Jewlery Menu v1.0",MENU_MAIN,channel);
}
else
{
llSay(0,"You do not have permission to control this item.");
}
}

listen(integer chan, string name, key owner, string msg)
{
if (msg == "Metals")
{
llDialog(owner, "Choose the metal you would like.", METALS, channel);
}

if (msg == "Stones")
{
llDialog(owner, "Choose the number of stones you would like to display on the ring.", STONES, channel);
}

if (msg == "Gold")
{
llMessageLinked(LINK_SET, 0, "gold", NULL_KEY);
}

if (msg == "Silver")
{
llMessageLinked(LINK_SET, 0, "silver", NULL_KEY);
}

if (msg == "1")
{
llMessageLinked(LINK_SET, 0, "1", NULL_KEY);
}

if (msg == "2")
{
llMessageLinked(LINK_SET, 0, "2", NULL_KEY);
}

if (msg == "3")
{
llMessageLinked(LINK_SET, 0, "3", NULL_KEY);
}

if (msg == "4")
{
llMessageLinked(LINK_SET, 0, "4", NULL_KEY);
}

if (msg == "5")
{
llMessageLinked(LINK_SET, 0, "5", NULL_KEY);
}

if (msg == "BACK")
{
llDialog(owner, "..:: Genesis ::.. Jewlery Menu v1.0", MENU_MAIN, channel);
}

}
}
Alicia Sautereau
if (!social) hide;
Join date: 20 Feb 2007
Posts: 3,125
09-28-2008 09:15
Out of my head

reset the script on rez

owner = llGetOwner();
if (llDetectedOwner(0) == owner)
changed to:
if (llDetectedKey(0) == owner)

llDialog(llDetectedOwner(0), "..:: Genesis ::.. Jewlery Menu v1.0",MENU_MAIN,channel);
changed to:
llDialog(owner, "..:: Genesis ::.. Jewlery Menu v1.0",MENU_MAIN,channel);


From: Ryker Beck
CODE

key owner;
integer channel;
list MENU_MAIN = ["Metals", "Stones"]; // the main menu
list METALS = ["Gold", "Silver", "BACK"];
list STONES = ["1" , "2" , "3" , "4", "5", "BACK"];


default
{
on_rez()
{
llResetScript();
}
state_entry()
{
owner = llGetOwner();
channel= (integer)(llFrand(-1000000000.0));
llListen(channel, "", owner, ""); // change to CHANNEL
}

touch_start(integer x)
{
if (llDetectedKey(0) == owner)
{
llDialog(owner, "..:: Genesis ::.. Jewlery Menu v1.0",MENU_MAIN,channel);
}
else
{
llSay(0,"You do not have permission to control this item.");
}
}

listen(integer chan, string name, key owner, string msg)
{
if (msg == "Metals")
{
llDialog(owner, "Choose the metal you would like.", METALS, channel);
}

if (msg == "Stones")
{
llDialog(owner, "Choose the number of stones you would like to display on the ring.", STONES, channel);
}

if (msg == "Gold")
{
llMessageLinked(LINK_SET, 0, "gold", NULL_KEY);
}

if (msg == "Silver")
{
llMessageLinked(LINK_SET, 0, "silver", NULL_KEY);
}

if (msg == "1")
{
llMessageLinked(LINK_SET, 0, "1", NULL_KEY);
}

if (msg == "2")
{
llMessageLinked(LINK_SET, 0, "2", NULL_KEY);
}

if (msg == "3")
{
llMessageLinked(LINK_SET, 0, "3", NULL_KEY);
}

if (msg == "4")
{
llMessageLinked(LINK_SET, 0, "4", NULL_KEY);
}

if (msg == "5")
{
llMessageLinked(LINK_SET, 0, "5", NULL_KEY);
}

if (msg == "BACK")
{
llDialog(owner, "..:: Genesis ::.. Jewlery Menu v1.0", MENU_MAIN, channel);
}

}
}
Ryker Beck
Photographer & Designer
Join date: 23 Feb 2007
Posts: 57
09-28-2008 09:41
That was exactly what I needed. :) Thank you so very muchly.
Lightwave Valkyrie
Registered User
Join date: 30 Jan 2004
Posts: 666
09-28-2008 11:58
on_rez() should be on_rez(integer start_param)
:)
_____________________
L$ is the root of all evil
videos work! thanks SL :)
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
09-28-2008 14:55
you can also avoid resetting (it is needed in some scripts )

leave the state entry as it is and add a changed event. and leave out the on_rez event

this should work, you may need to add/remove a bracket somewhere as i'm not in world to check if it compiles

edit: realized the listen was in the state entry. moved it to the touch event, and added a timer to remove it after 30 seconds

From: someone

key owner;
integer listener;
integer channel;
list MENU_MAIN = ["Metals", "Stones"]; // the main menu
list METALS = ["Gold", "Silver", "BACK"];
list STONES = ["1" , "2" , "3" , "4", "5", "BACK"];


default
{
state_entry()
{
owner = llGetOwner();

}

touch_start(integer x)
{
if (llDetectedKey(0) == owner)
{
channel= (integer)(llFrand(-1000000000.0));
listener = llListen(channel, "", owner, "";); // change to CHANNEL
llSetTimerEvent(30);
llDialog(owner, "..:: Genesis ::.. Jewlery Menu v1.0",MENU_MAIN,channel);
}
else
{
llSay(0,"You do not have permission to control this item.";);
}
}

listen(integer chan, string name, key owner, string msg)
{
if (msg == "Metals";)
{
llDialog(owner, "Choose the metal you would like.", METALS, channel);
}

if (msg == "Stones";)
{
llDialog(owner, "Choose the number of stones you would like to display on the ring.", STONES, channel);
}

if (msg == "Gold";)
{
llMessageLinked(LINK_SET, 0, "gold", NULL_KEY);
}

if (msg == "Silver";)
{
llMessageLinked(LINK_SET, 0, "silver", NULL_KEY);
}

if (msg == "1";)
{
llMessageLinked(LINK_SET, 0, "1", NULL_KEY);
}

if (msg == "2";)
{
llMessageLinked(LINK_SET, 0, "2", NULL_KEY);
}

if (msg == "3";)
{
llMessageLinked(LINK_SET, 0, "3", NULL_KEY);
}

if (msg == "4";)
{
llMessageLinked(LINK_SET, 0, "4", NULL_KEY);
}

if (msg == "5";)
{
llMessageLinked(LINK_SET, 0, "5", NULL_KEY);
}

if (msg == "BACK";)
{
llDialog(owner, "..:: Genesis ::.. Jewlery Menu v1.0", MENU_MAIN, channel);
}

changed(integer change)
{
if (changed & CHANGED_OWNER)
{
owner = llGetOwner();
}
timer()
{
llListenRemove(listener);
llSetTimerEvent(0.0);
}
}
}
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369
Bloodsong Termagant
Manic Artist
Join date: 22 Jan 2007
Posts: 615
09-29-2008 07:23
heyas;

when you store the owner key as a global variable, you need to reset the script (and the owner variable!) on change & CHANGED_OWNER. (or on rez, if you like.)


alternately, you could NOT store the owner key, but simply use llGetOwner() in the body of the script. (unless you use it more than a handful of times.)


for example, in the touch event, you could do...

key toucher = llDetectedKey(0);
if(toucher != llGetOwner()) return;

then use 'toucher' where you use owner.


in the listen event, the key of whoever was 'heard' is already passed into the event. (btw, does that compile when you use key owner inside the listen event parameters, when you already defined owner as a globar variable? it shouldn't let you do that.)

so...
listen(integer ch, string n, key id, string s)

then in whatever message...
llDialog(id,....
_____________________
Why Johnny Can't Rotate:
http://forums.secondlife.com/showthread.php?t=94705
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
09-29-2008 09:23
that's true, you can leave the state entry and the owner change events out altogether.

From: someone

integer listener;
integer channel;
list MENU_MAIN = ["Metals", "Stones"]; // the main menu
list METALS = ["Gold", "Silver", "BACK"];
list STONES = ["1" , "2" , "3" , "4", "5", "BACK"];


default
{
touch_start(integer x)
{
if (llDetectedKey(0) == llGetOwner())
{
channel= (integer)(llFrand(-1000000000.0));
listener = llListen(channel, "",llDetectedKey(0), "";); // change to CHANNEL
llSetTimerEvent(30);
llDialog(llDetectedKey(0), "..:: Genesis ::.. Jewlery Menu v1.0",MENU_MAIN,channel);
}
else
{
llSay(0,"You do not have permission to control this item.";);
}
}

listen(integer chan, string name, key id, string msg)
{
if (msg == "Metals";)
{
llDialog(id, "Choose the metal you would like.", METALS, channel);
}

if (msg == "Stones";)
{
llDialog(id, "Choose the number of stones you would like to display on the ring.", STONES, channel);
}

if (msg == "Gold";)
{
llMessageLinked(LINK_SET, 0, "gold", NULL_KEY);
}

if (msg == "Silver";)
{
llMessageLinked(LINK_SET, 0, "silver", NULL_KEY);
}

if (msg == "1";)
{
llMessageLinked(LINK_SET, 0, "1", NULL_KEY);
}

if (msg == "2";)
{
llMessageLinked(LINK_SET, 0, "2", NULL_KEY);
}

if (msg == "3";)
{
llMessageLinked(LINK_SET, 0, "3", NULL_KEY);
}

if (msg == "4";)
{
llMessageLinked(LINK_SET, 0, "4", NULL_KEY);
}

if (msg == "5";)
{
llMessageLinked(LINK_SET, 0, "5", NULL_KEY);
}

if (msg == "BACK";)
{
llDialog(id, "..:: Genesis ::.. Jewlery Menu v1.0", MENU_MAIN, channel);
}

timer()
{
llListenRemove(listener);
llSetTimerEvent(0.0);
}
}
}
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369