Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llDialog help

Laurence Corleone
Registered User
Join date: 12 Oct 2006
Posts: 126
11-13-2007 13:40
I am trying to put in the first dialog the option of calling the second dialog but can't seem to get it right. Maybe somebody here can see what I am doing wrong?

First Dialog:

CODE

integer MENU_CHANNEL = 1024;
integer TIMEOUT_SECS = 20;
key detectedkey;

default
{
touch_start(integer total_number)
{
detectedkey = llDetectedKey(0);
llDialog(detectedkey, "What do you want to do?", ["A1", "A2", "Help", "Reset"], MENU_CHANNEL);
llSetTimerEvent(TIMEOUT_SECS);
}

listen(integer channel, string name, key id, string str)
{
if (channel == MENU_CHANNEL)
{
if (str == "A1")
{
detectedkey = llDetectedKey(0);
llMessageLinked(LINK_SET, 0, "1OPTIONS", detectedkey);
llOwnerSay("I did my side of things");
}
if (str == "A2")
{
detectedkey = llDetectedKey(0);
llMessageLinked (LINK_SET, 0, "2OPTIONS", detectedkey);
}
if (str == "Help")
{
llMessageLinked(LINK_SET, 0, "helpcard", detectedkey);
llOwnerSay("Giving Help Notecard");
}

else if (str == "Reset")
{
llMessageLinked(LINK_SET, 0, "reset", detectedkey);
}
}
}

timer()
{
llOwnerSay("Timed Out");
}

on_rez(integer start_param)
{
llResetScript();
}
}



Second Dialog:

CODE

integer MENU_CHANNEL = 1025;
integer TIMEOUT_SECS = 20;
key detectedkey;


default
{
link_message(integer sender_num, integer num, string str, key id)
{
if (str == "1OPTIONS")
{
detectedkey = id;
llDialog(detectedkey, "What do you want to do?", ["On", "Off", "List", "Clear"], MENU_CHANNEL);
llOwnerSay("I heard the linked message");
llSetTimerEvent(TIMEOUT_SECS);
}
}

listen(integer channel, string name, key id, string str)
{
if (channel == MENU_CHANNEL)
{
if (str == "On")
{
llMessageLinked(LINK_SET, 0, "On", detectedkey);
}
if (str == "Off")
{
llMessageLinked(LINK_SET, 0, "Off", detectedkey);
}
if (str == "List")
{
llMessageLinked(LINK_SET, 0, "list", detectedkey);
}
else if (str == "Clear")
{
llMessageLinked(LINK_SET, 0, "clear", detectedkey);
}
}
}

timer()
{
llOwnerSay("Timed Out");
}

on_rez(integer start_param)
{
llResetScript();
}
}
_____________________
There are no stupid questions, just stupid people.
Monica Balut
Beam-Me
Join date: 18 Feb 2007
Posts: 311
11-13-2007 14:54
The one obvious thing that strikes me is that you call llDetectedKey a second time from the listen event in the first script. llDetectedKey() works in the touch event where there's actually a touch to detect. There is no touch to detect in the listen event. Take out those lines in the listen event. You have already set the key in a global in the touch event. Just use that.

A couple of other comments not related to why it doesn't work. I assume there's a good reason for having the second dialog in a second script. It's a lot simpler to have them both in the same script. I usually will call the second dialog using a different channel. You should read up on how to set random channels so not all your objects are listening on the same channel. Finally, it's more efficient to identify your linked messages by a unique integer rather than by a string. Integer comparisons are faster and use less sim resources.