Need help with owner only dialog
|
|
Basement Desade
Registered User
Join date: 14 Jul 2006
Posts: 91
|
06-04-2009 23:15
Okay, the following script works just dandy, except for one thing. If another avatar touches the prim it's in, they don't see the dialog menu, which is fine, and what I intended. The trouble is that the dialog menu pops up on my screen, just as if I had been the one touching it. They touch it repeatedly, I get multiple menus. Can anyone please tell me what painfully obvious thing I am missing?
list buttons = ["Red Tile", "Spanish Tile", "Transparent", "Grid", "Black Tile", "Grey Tile"]; string msg = "Texture choices:"; key Owner; integer channel_dialog; integer listen_id; default{ state_entry() { channel_dialog = ( -1 * (integer)("0x"+llGetSubString((string)llGetKey(),-5,-1)) ); } touch_start(integer total_number) { Owner = llGetOwner(); llDialog(Owner, msg, buttons, channel_dialog); listen_id = llListen( channel_dialog, "", Owner, ""); llSetTimerEvent(60); } listen(integer channel, string name, key id, string choice) { if (choice == "-") { llDialog(Owner, msg,buttons, channel_dialog); } else if (choice == "Red Tile") { llSetTexture("c3fc7a67-01ad-f47f-ae26-fc731d710d14",0); llMessageLinked(LINK_SET, 0, "Red Tile",""); llListenRemove(listen_id); } else if (choice == "Spanish Tile") { llSetTexture("2ef2d208-605a-6ce9-053b-9eff79de3b2d",0); llMessageLinked(LINK_SET, 0, "Spanish Tile",""); llListenRemove(listen_id); } else if (choice == "Transparent") { llSetTexture("f54a0c32-3cd1-d49a-5b4f-7b792bebc204",0); llMessageLinked(LINK_SET, 0, "Transparent",""); llListenRemove(listen_id); } else if (choice == "Black Tile") { llSetTexture("80e7c090-f74f-d639-a7dd-6d02a8e17d95",0); llMessageLinked(LINK_SET, 0, "Black Tile",""); llListenRemove(listen_id); } else if (choice == "Grey Tile") { llSetTexture("c97aa49e-f03a-810a-fb59-ccd0ab9e1af3",0); llMessageLinked(LINK_SET, 0, "Grey Tile",""); llListenRemove(listen_id); } else if (choice == "Grid") { llSetTexture("87dfd082-f83b-673b-e86b-5fa2d64bedf8",0); llMessageLinked(LINK_SET, 0, "Grid",""); llListenRemove(listen_id); } } timer() { llListenRemove(listen_id); llWhisper(0, "Sorry, Dialogue has timed out."); llSetTimerEvent(0.0); } }
|
|
Viktoria Dovgal
…
Join date: 29 Jul 2007
Posts: 3,593
|
06-04-2009 23:20
In your touch_start, you can use llDetectedKey to see who touched it. Skip the dialog unless it matches llGetOwner.
|
|
Basement Desade
Registered User
Join date: 14 Jul 2006
Posts: 91
|
In bonehead language, please?
06-05-2009 00:18
From: Viktoria Dovgal In your touch_start, you can use llDetectedKey to see who touched it. Skip the dialog unless it matches llGetOwner. Sorry, could you be a bit more specific? I know it's obvious to you, but it isn't to me.  I've tried several things using your suggestion, but I'm not using the proper syntax.
|
|
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
|
06-05-2009 00:35
From: Basement Desade Sorry, could you be a bit more specific? I know it's obvious to you, but it isn't to me.  I've tried several things using your suggestion, but I'm not using the proper syntax. touch_start(integer total_number) { Owner = llGetOwner(); // i would move that up to state entry -- pointless to check who owns me each time, since we know that already if(llDetectedKey(0)==Owner){//if my owner has touched me llDialog(Owner, msg, buttons, channel_dialog); listen_id = llListen( channel_dialog, "", Owner, ""); llSetTimerEvent(60); } }
This should do the trick, I hope.
|
|
Escort DeFarge
Together
Join date: 18 Nov 2004
Posts: 681
|
06-05-2009 00:39
This quick (untested) rewrite should work the way you wanted, save a few scripts, and may give you a few ideas too 
list buttons = [ "Red Tile", "Spanish Tile", "Transparent", "Grid", "Black Tile", "Grey Tile" ]; // in the same order as above list textures = [ "c3fc7a67-01ad-f47f-ae26-fc731d710d14", "2ef2d208-605a-6ce9-053b-9eff79de3b2d", "f54a0c32-3cd1-d49a-5b4f-7b792bebc204", "80e7c090-f74f-d639-a7dd-6d02a8e17d95", "c97aa49e-f03a-810a-fb59-ccd0ab9e1af3", "87dfd082-f83b-673b-e86b-5fa2d64bedf8" ];
string msg = "Texture choices:"; integer channel_dialog; integer listen_id; default{ state_entry() { channel_dialog = ( -1 * (integer)("0x"+llGetSubString((string)llGetKey(),-5,-1)) ); listen_id = llListen(channel_dialog, "", llGetOwner(), ""); llListenControl(listen_id, FALSE); }
touch_start(integer total_number) { if (llDetectedKey(0) == llGetOwner()) { llListenControl(listen_id, TRUE); llDialog(llGetOwner(), msg, buttons, channel_dialog); llSetTimerEvent(60.0); } } listen(integer channel, string name, key id, string choice) { llListenControl(listen_id, FALSE); integer index = llListFindList(buttons, [choice]); if (index != -1) { string texture = llList2String(textures, index); llSetLinkPrimitiveParams(LINK_SET, [PRIM_TEXTURE, 0, texture, <1.0, 1.0, 0.0>, ZERO_VECTOR, PI_BY_TWO]); } } timer() { llSetTimerEvent(0.0); llListenControl(listen_id, FALSE); llOwnerSay("Sorry, Dialogue has timed out."); } }
_____________________
http://slurl.com/secondlife/Together
|
|
Basement Desade
Registered User
Join date: 14 Jul 2006
Posts: 91
|
06-05-2009 00:50
From: Escort DeFarge This quick (untested) rewrite should work the way you wanted, save a few scripts, and may give you a few ideas too  Thanks, but this has the same problem as my original. I appreciate the effort, though. 
|
|
Basement Desade
Registered User
Join date: 14 Jul 2006
Posts: 91
|
06-05-2009 00:51
From: Innula Zenovka This should do the trick, I hope. Yep, it did! Thanks bunches! 
|
|
Basement Desade
Registered User
Join date: 14 Jul 2006
Posts: 91
|
Well, I thought it did...
06-05-2009 01:06
This one, however, doesn't work for the next owner. Sorry, I guess I should have mentioned that it needed to.
|
|
Escort DeFarge
Together
Join date: 18 Nov 2004
Posts: 681
|
06-05-2009 02:37
From: Basement Desade This one, however, doesn't work for the next owner. Sorry, I guess I should have mentioned that it needed to. on_rez(integer start_param) { llResetScript(); } I don't see how the script I posted could have the same problem as the original. It uses the same filter on touch as has been otherwise suggested. Are you sure you copied it right? 
_____________________
http://slurl.com/secondlife/Together
|
|
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
|
06-05-2009 06:31
From: Escort DeFarge on_rez(integer start_param) { llResetScript(); } I don't see how the script I posted could have the same problem as the original. It uses the same filter on touch as has been otherwise suggested. Are you sure you copied it right?  yep, looks fine to me,except, i would also turn off the timer in the listen event, otherwise you'll still get the timeout message
|
|
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
|
06-05-2009 07:22
From: Basement Desade This one, however, doesn't work for the next owner. Sorry, I guess I should have mentioned that it needed to. If you don't want to reset the script every time something's rezzed, which is sometimes a nuisance, you can use changed(integer change){ if (change & CHANGED_OWNER){ llResetScript(); } } which will only reset it -- thus changing the value of the variable, Owner -- if there is, in fact, a new owner.
|
|
Basement Desade
Registered User
Join date: 14 Jul 2006
Posts: 91
|
06-05-2009 11:57
From: Escort DeFarge Are you sure you copied it right?  Yup. I could tell because it also switched the textures around to be different than the button labels. 
|
|
Basement Desade
Registered User
Join date: 14 Jul 2006
Posts: 91
|
OK, finally got it.
06-05-2009 14:11
Thanks, everybody. Took me a bit to figure out WHERE to put the snippets, but I finally did. Out of curiosity, why does the reset command go at the end of the script? That just seems wrong to me. 
|
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
06-05-2009 14:21
From: Basement Desade Thanks, everybody. Took me a bit to figure out WHERE to put the snippets, but I finally did. Out of curiosity, why does the reset command go at the end of the script? That just seems wrong to me.  Unlike other programming languages that you may know, LSL doesn't execute in a linear way, starting at the beginning and pushing through to the end. Individual events can be listed in any order you like, because they only do something when they are triggered by some action (touch, sensor, time, etc.). So.... you put the llReset command in the event where you want it to be called ... on_rez, changed, whatever .... and don't give a thought to whether the event is at the "end" of the script.
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask....  Look for my work in XStreetSL at 
|