llDialog and non-owner input
|
|
Ashes Arizona
Registered User
Join date: 2 Mar 2006
Posts: 9
|
06-01-2006 06:53
I've been working on a script and everything works. The problem is I can't get the dialog menu to reappear to the person who clicked on it after they've made a choice and why its not reappearing isn't very clear to me. Heres the basic code. integer CHANNEL = 7; list MENU_TEST = [ //List options here ]; default { touch_start(integer total_number) { llListen(CHANNEL, "", llDetectedKey(0), ""); llDialog(llDetectedKey(0),"Test Menu", MENU_TEST, CHANNEL); llOwnerSay(llDetectedName(0) + "message"); } on_rez(integer total_number) { llResetScript(); } listen(integer channel, string name, key id, string message) { if (llListFindList(MENU_TEST, [message]) != -1) { if (message == "Option"); { //Do Stuff } else (message == "Option"); { llDialog(llDetectedKey(0), "Test Menu", MENU_TEST, CHANNEL); } llDialog(llDetectedKey(0), "Test Menu", MENU_TEST, CHANNEL); } } }
Everything in the script functions correctly, the only problem is, when the person who has clicked on the object chooses a dialog option, the dialog menu is not brought back up automatically...causing them to have to click on the object again to get the dialog menu...but I thought having the dialog called at the end of the script would re-present the menu...but its not. Any help would be appreciated here.
|
|
nand Nerd
Flexi Fanatic
Join date: 4 Oct 2005
Posts: 427
|
06-01-2006 07:20
In the listen event you'll want to use the key id instead of llDetectedKey(0), as the llDetected* functions do not work with listen and are only applicable to touch, sensor and possible a few other events. listen(integer channel, string name, key id, string message) { if (llListFindList(MENU_TEST, [message]) != -1) { if (message == "Option"); { //Do Stuff } else (message == "Option"); { llDialog(id, "Test Menu", MENU_TEST, CHANNEL); } llDialog(id, "Test Menu", MENU_TEST, CHANNEL); } }
|
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
06-01-2006 08:04
nand is quite right about the need to use id.
Just for completeness you can use the llDetected* functions in the collision family of events too.
|
|
Nexus Nash
Undercover Linden
Join date: 18 Dec 2002
Posts: 1,084
|
06-01-2006 08:28
listen(integer channel, string name, key id, string message){ if (llListFindList(MENU_TEST, [message]) != -1) {
if (message == "Option") { llDialog(id, "Test Menu 0", MENU_TEST, CHANNEL); } else { llDialog(id, "Test Menu 1", MENU_TEST, CHANNEL); }
llDialog(id, "Test Menu 2", MENU_TEST, CHANNEL); } }
Try this. Semi colons arn't suppose to be after the if / else if / else and the else doesn't have a condition. Also another suggestion, make a variable for the person using the listen. If the key is used don't let anyone else use it. If it's not, start new session.
|
|
nand Nerd
Flexi Fanatic
Join date: 4 Oct 2005
Posts: 427
|
06-01-2006 08:37
Doh! *slaps head*, I didn't even see that.
|
|
Nexus Nash
Undercover Linden
Join date: 18 Dec 2002
Posts: 1,084
|
06-01-2006 08:41
Something I just wrote, it may have errors because i'm doing this off the top of my head. But it's a basic dialog script with a timeout. key gUUID = NULL_KEY; integer gListener; integer gChannel; float gTimerDelay = 60.0;
killListen() { gUUID = NULL_KEY; llListenRemove(gListener); }
default { state_entry() { } on_rez(integer num) { llResetScript(); } touch_start(integer num) { if(gUUID == NULL_KEY) { gUUID = llDetectedKey(0); gChannel = llRound((llFrand(1.0) * llPow(2,30)) + 1.0); gListener = llListen(gChannel,"",gUUID,""); llSetTimerEvent(gTimerDelay); } else { llDialog(llDetectedKey(0),"Sorry, someone is using the dialog", ["Ok"],1); } }
listen(integer channel, string name, key id, string message) { llSetTimerEvent(0.0); llSetTimerEvent(gTimerDelay);
if (message == "Option1") { llDialog(gUUID, "Test Menu 1", MENU_TEST, CHANNEL); } else if(message == "Option2") { llDialog(gUUID, "Test Menu 2", MENU_TEST, CHANNEL); } else if(message == "Exit") { killListen(); } else { llDialog(gUUID, "Test Menu else", MENU_TEST, CHANNEL); } } //timeout on the script. timer() { llSetTimerEvent(0.0); killListen(); } }
|
|
Ashes Arizona
Registered User
Join date: 2 Mar 2006
Posts: 9
|
06-01-2006 11:22
Hrrm the original suggestion appeared to work, but now if there are two items using the dialog, and I touch one...and make an option choice, and get a response, then touch the other and make another option choice...I end up touching them both on the response from the second one. This goes on ad infinitum. Let me see if I can explain more clearly. Touch - Object #1 Choose Dialog Option Object #1: Response to Option Touch Object #2 Choose Dialog Option Object #2 Response to Option Object #1 Response to Option What I want is these two objects to respond individually. But something in how I've got it scripted at the moment is causing a response from both items. Heres the updated code (yes I removed the semi colons), and Nexus your alternative seems like a good idea but the dialog locks the user out after one option and doesn't restart the dialog either. integer CHANNEL = 7; list MENU_TEST = [ //List options here ]; default { touch_start(integer total_number) { llListen(CHANNEL, "", llDetectedKey(0), ""); llDialog(llDetectedKey(0),"Test Menu", MENU_TEST, CHANNEL); llOwnerSay(llDetectedName(0) + "message"); } on_rez(integer total_number) { llResetScript(); } listen(integer channel, string name, key id, string message) { if (llListFindList(MENU_TEST, [message]) != -1) { if (message == "Option") { //Do Stuff } llDialog(id, "TEST MENU", MENU_TEST, CHANNEL); } else if (message == "menu") { llDialog(id, "TEST MENU", MENU_TEST, CHANNEL); } } }
|
|
Ashes Arizona
Registered User
Join date: 2 Mar 2006
Posts: 9
|
06-01-2006 14:16
Okay the more I mess with this the more I realize I need to use llFrand to generate a random chat channel for the script to us on rez. Problem is, I do that and the script compiles but it seems to be trying to use channel 0 now for messages whereas the responses are on whatever random channel the object has selected. This is bad because it spams text into open chat. This is really starting to get on my nerves, its just one problem after another. I really need some help here, the Wiki's reference information on llFrand is very vague in reference to its application with llListen. Heres what I'm doing. integer listen_handle; list MENU_TEST = [ "TEST1", "TEST2" ]; default { on_rez(integer total_number) { llResetScript(); listen_handle = llListen((integer)llFrand(60000 - 1), "", llDetectedKey(0), ""); } touch_start(integer total_number) { llListen(listen_handle, "", llDetectedKey(0), ""); llDialog(llDetectedKey(0),"Test Menu", MENU_TEST, listen_handle); llOwnerSay(llDetectedName(0) + " is using the test menu."); } listen(integer channel, string name, key id, string message) { if (llListFindList(MENU_TEST, [message]) != -1) { if (message == "TEST1"); { //Do Stuff } if (message == "TEST2") { //Do Stuff } llDialog(id, "Test Menu", MENU_TEST, listen_handle); } else if (message == "menu") { llDialog(id, "Test Menu", MENU_TEST, listen_handle); } } }
For some reason, when I use this, everything works and I think the llFrand has made it to where objects won't crosstalk each other but NOW when you select a Dialog Option...it spams the message into open chat. llYankOutHair
|
|
Ashes Arizona
Registered User
Join date: 2 Mar 2006
Posts: 9
|
06-01-2006 17:23
Am I simply not asking the questions right here?
I'm dying for some help...Live Help told me that doing llFrand was the right thing to do but wouldn't go much further into it.
I'm way up a creek without a paddle here and I really need some help....please.
|
|
carol Wombat
Registered User
Join date: 29 Jan 2006
Posts: 16
|
06-01-2006 18:24
Hi Ashes
I set the listen channel in a separate routine - state_entry - i think. Not sure that the stuff after reset script gets executed, but i could be wrong about that.
I also usually have a global variable to hold the listen value so I can reset it to the same value when I go to different states.
When you do generate the listen channel number, use llOwnerSay to show you the number (for diagnostic purposes only - delete later)
hth
ed
|
|
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
|
06-01-2006 18:43
listen_handle = llListen((integer)llFrand(60000 - 1), "", llDetectedKey(0), is in the on rez event so unless you have rezed the prim since the last time the script was saved / reset your chat channel is 0 put in a state entry if your gonna reset the script  edit, for what you want you should probally have it in the touch event...
|
|
Nexus Nash
Undercover Linden
Join date: 18 Dec 2002
Posts: 1,084
|
06-02-2006 05:51
From: Ashes Arizona Heres the updated code (yes I removed the semi colons), and Nexus your alternative seems like a good idea but the dialog locks the user out after one option and doesn't restart the dialog either. If should lock someone out only if they pick ignore, for 60 seconds. This prevents others from using the dialog while someone is using it. What exactly does my example NOT accomplish (that you think is missing from your script?). Trying to figure it out so I can help ya 
|
|
Ashes Arizona
Registered User
Join date: 2 Mar 2006
Posts: 9
|
06-02-2006 09:39
From: Nexus Nash If should lock someone out only if they pick ignore, for 60 seconds. This prevents others from using the dialog while someone is using it. What exactly does my example NOT accomplish (that you think is missing from your script?). Trying to figure it out so I can help ya  Well its working, but the problem is I don't want the object locked out from multiple users. I've gone through and removed the timers and it works, but still locks out all other users once one person has touched it. Switching the gUUID to DetectedKey(0) instead stops the entire system from working...none of the dialog options return a response. But...on the upside, your use of llFrand is alot better than mine and if I leave the timers in everything works beautifully except the multi-user lock out which I'm having trouble getting around.
|