llDialog help needed
|
Montecore Babcock
Registered User
Join date: 20 May 2006
Posts: 48
|
10-23-2009 10:45
Can llDialog only be called from a touch_start event? I seem to be having problems calling it from anywhere else.
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
10-23-2009 11:01
You can call llDialog from anywhere you like. To make the function work, of course, you do need to be sure than you have a listen event set up to get the messages it sends. That's where the actual work will take place.
_____________________
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 
|
Montecore Babcock
Registered User
Join date: 20 May 2006
Posts: 48
|
10-23-2009 11:05
I've tried calling it from a few different places in my code and the dialog box doesn't pop up. I do have the lllListen and listen parts set.
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
10-23-2009 11:23
Can you post the script or at least a part that's troublesome?
_____________________
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 
|
Montecore Babcock
Registered User
Join date: 20 May 2006
Posts: 48
|
10-23-2009 11:29
The code is rather large and hard to show without giving away something important.
|
Montecore Babcock
Registered User
Join date: 20 May 2006
Posts: 48
|
10-23-2009 11:32
I used the same line of code under areas of on_rez and state entry and I know those portions are executing, but if i put the line there it just will not cause the blue dialog box to pop up. So I put it in a touch_start where it does.
|
Viktoria Dovgal
…
Join date: 29 Jul 2007
Posts: 3,593
|
10-23-2009 11:47
Then one guess would be that at on_rez and state_entry it is too early, or maybe you need to reorder something. How are you getting the key for sending the dialog? If it is a variable, is it set by then?
|
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
|
10-23-2009 11:55
A frequent problem people encounter is making sure llDialog knows to whom to present the menu. llDetectedKey(0) works fine in events where you can detect stuff, but that obviously isn't the case in a listen event. Fortunately, listen events detect the uuid of whoever they hear. So, something like listen(integer channel, string name, key id, string msg) { if(channel == av_channel){ llDialog(id,"please choose one",buttons,menu_channel); } }
should give a menu to anyone who says something on whatever av_channel is, assuming you've set up av_channel and menu_channel.
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
10-23-2009 11:57
It's kinda hard to help, then. The best I can do is write a generic model... integer CHAN = -3456; list buttons = ["1","2","3","4","5"]; list newbuttons = ["6","7"]; default { state_entry() { llListen(CHAN,"","",""); llSetTimerEvent(60); }
on_rez(integer start_param) { llDialog(llGetOwner(),"Pick a number", buttons, CHAN); }
touch_start(integer num) { llDialog(llDetectedKey(0), "Pick a number", buttons, CHAN); }
collision_start(integer another_num) { llDialog(llDetectedKey(0), "Pick a number", buttons, CHAN); }
attach(key attached) { llDialog(attached,"Pick a number", buttons, CHAN); }
sensor(integer count) { llDialog(llDetectedKey(0), "Pick a number", buttons, CHAN); }
timer() { llSensor("", NULL_KEY, AGENT, 10, PI); }
listen (integer chan, string name, key id, string message) { if (message == "1") { // Do button #1 stuff } else if (message == "2") { // Do button #2 stuff } else if (message == "3") { // Do button #3 stuff } else if (message == "4") { // Do button #4 stuff } else if (message == "5") { llDialog(id,"OK, Pick another number", newbuttons, CHAN); } else if (message == "6") { //Do newbutton #6 stuff } else if (message == "7") { //Do newbutton #7 stuff } } }
Unless I really screwed up ... I can't get in world to test ... you should get a dialog box from any of those events.
_____________________
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 
|
Montecore Babcock
Registered User
Join date: 20 May 2006
Posts: 48
|
10-23-2009 13:30
Rolig, I tried
on_rez(integer start_param) { llDialog(llGetOwner(),"Pick a number", buttons, CHAN); }
and it works now. Why do the other ones use llDetectedKey(0) but this one has llGetOwner? That was my problem.
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
10-23-2009 13:44
Because there's no detection in an on_rez event, so llDetectedKey(0) is not defined. llDetectedKey only works in sensor, collision, and touch events, so you have to find some other way to identify the person you want to address. In the case of on_rez, state_entry, or attach events, for example, it makes sense to address the owner, since nobody else can rez or wear the object.
_____________________
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 
|
Montecore Babcock
Registered User
Join date: 20 May 2006
Posts: 48
|
10-23-2009 13:52
This is an excellent reference. Thank you all for responding.
|