Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Menu providing links to multiple URLs

Niko Bromberg
Registered User
Join date: 30 May 2008
Posts: 14
07-25-2008 02:57
Hello!
Sorry if this has been explained before,
I am trying to build an object which when touched displays a menu listing a set of choices that link to external websites (so when an avatar touches the option the url is loaded). Ive written a script with llDialog, however when I test it a "cannot find avatar" message appears when a choice is selected.

Any help would be super duper. Thanks
Urrong Urnst
Registered User
Join date: 12 Jul 2008
Posts: 49
07-25-2008 03:04
It would help if u would poste the script here. U can change web sites or just use hhtp://www.herewillbewebsite.com or something so that we know. Then i think we could help. Otherwise its just asking did u do that? and that? and that?
Niko Bromberg
Registered User
Join date: 30 May 2008
Posts: 14
07-25-2008 03:23
Ok, here it is:

integer CHANNEL = 42;
list MENU_MAIN = ["website1", "website2"];

default {
state_entry() {
llListen(CHANNEL, "", NULL_KEY, "";);
}

touch_start(integer total_number)
{
llDialog(llDetectedKey(0), "What do you want to access?", MENU_MAIN, CHANNEL);
}

listen(integer channel, string name, key id, string message)
{
if (message == "website1";)
llLoadURL(llDetectedKey(0), "Link to..", "www.bbc.co.uk";);
else if (message == "website2";)
llLoadURL(llDetectedKey(0), "Link to..", "www.testsite.co.uk";);
}
}

Thanks
Urrong Urnst
Registered User
Join date: 12 Jul 2008
Posts: 49
07-25-2008 03:28
try instead of llListen(CHANNEL, "", NULL_KEY, "";);
use llListen(CHANNEL, "", "", "";);
Niko Bromberg
Registered User
Join date: 30 May 2008
Posts: 14
07-25-2008 03:33
Thanks, I changed it but the same thing happened again. Bummer.
Kaluura Boa
Polygon Project
Join date: 27 Mar 2007
Posts: 194
07-25-2008 03:34
The answer is easy: llDetectedKey(0) has a meaningful value only in detection events like touch*() or sensor() but NOT in a listen() event.

integer CHANNEL = 42;
list MENU_MAIN = ["website1", "website2"];

key AVATAR;
integer HANDLE;

default {
state_entry() {
// llListen(CHANNEL, "", NULL_KEY, "";); // Please, remove that ugly thing!
}

touch_start(integer total_number)
{
AVATAR = llDetectedKey(0);
HANDLE = llListen(CHANNEL, "", AVATAR, "";); // Better this way.
llDialog(AVATAR, "What do you want to access?", MENU_MAIN, CHANNEL);
llSetTimerEvent(30.0); // 30 seconds timeout.
}

listen(integer channel, string name, key id, string message)
{
llTimerEvent(0.0); // Disable the timeout.
llListenRemove(HANDLE); // Stop listening.
if (message == "website1";)
llLoadURL(AVATAR, "Link to..", "www.bbc.co.uk";);
else if (message == "website2";)
llLoadURL(AVATAR, "Link to..", "www.testsite.co.uk";);
}

timer()
{
llTimerEvent(0.0); // Disable the timeout.
llListenRemove(HANDLE); // Stop listening.
llInstantMessage(AVATAR, "Time out! The dialog is disabled.";);
}
}
Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
07-25-2008 07:41
Change your calls to llDetectedKey(0) to 'id'. The listen event provides with the ID of the avatar in that variable.

So your listen event would look like:

CODE
listen(integer channel, string name, key id, string message) 
{
if (message == "website1")
llLoadURL(id, "Link to..", "www.bbc.co.uk");
else if (message == "website2")
llLoadURL(id, "Link to..", "www.testsite.co.uk");
}


As mentioned; llDetected*() functions only work in touch*() events, collision*() events and sensor(). In all other events they don't return any useful value (at this time).
_____________________
Computer (Mac Pro):
2 x Quad Core 3.2ghz Xeon
10gb DDR2 800mhz FB-DIMMS
4 x 750gb, 32mb cache hard-drives (RAID-0/striped)
NVidia GeForce 8800GT (512mb)
Niko Bromberg
Registered User
Join date: 30 May 2008
Posts: 14
07-28-2008 01:07
Thanks so much for this, works perfectly :)