Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Strange dialog box error in changed event

Niklas Trilam
Registered User
Join date: 2 May 2006
Posts: 2
01-16-2007 22:25
Hi, I'm running into a little problem when I'm running this script. Everything compiles nicely, and seems to run almost exactly the way it should, except for the very first dialog box isn't showing up the way I think it's supposed to when I sit on the prim.

CODE

// Global variables

integer CHANNEL = 37;
string firstDialog = "Choose one set of poses from the list below:";
list list1 = ["Drink","Chat","Work","Cancel"];
list DrinkList = ["Drink Animation","Toast","Laugh","Cancel"];
list ChatList = ["Talk 1","Talk 2","Talk 3","Cancel"];
list WorkList = ["Draw","Stand and Look","Lean Forward","Cancel"];

default
{

state_entry()
{
llSitTarget(<0,0,.5>, ZERO_ROTATION); // Sit here
llListen(CHANNEL, "", NULL_KEY, ""); // Listen for answers
}

changed(integer change) // When somebody sits on the prim
{
if (change & CHANGED_LINK)
{
if (llAvatarOnSitTarget() != NULL_KEY)
{
llSleep(1.0);
llDialog(llDetectedKey(0), firstDialog, list1, CHANNEL); // Launches dialog window
llSay(0, "Yes, I know you're sitting on me."); // Debugging chat line
}
}
}

listen(integer channel, string name, key id, string message)
{
if (llListFindList(list1, [message]) != -1) // handles first dialog box
{
if (message == "Drink")
{

llDialog(id, "Choose a pose:", DrinkList, CHANNEL); //Drink submenu

}
else if (message == "Chat")
{
llDialog(id, "Choose a pose:", ChatList, CHANNEL); // Chat submenu
}
else if (message == "Work")
{
llDialog(id, "Choose a pose:", WorkList, CHANNEL);
}
else if (message == "Cancel")
{
return;
}
}

if (llListFindList(DrinkList, [message]) != -1) // DrinkList submenu
{
if (message == "Drink Animation")
{
llSay(0, "Drink animation goes here");
}
else if (message == "Toast")
{
llSay(0, "Toast animation goes here");
}
else if (message == "Laugh")
{
llSay(0, "Laugh animation goes here");
}
}

if (llListFindList(ChatList, [message]) != -1) // ChatList submenu
{
if (message == "Talk 1")
{
llSay(0, "Talk 1 animation goes here");
}
else if (message == "Talk 2")
{
llSay(0, "Talk 2 animation goes here");
}
else if (message == "Talk 3")
{
llSay(0, "Talk 3 animation goes here");
}
}

if (llListFindList(WorkList, [message]) != -1) //WorkList submenu
{
if (message == "Draw")
{
llSay(0, "Draw animation goes here");
}
else if (message == "Stand and Look")
{
llSay(0, "Stand and Look animation goes here");
}
else if (message == "Lean Forward")
{
llSay(0, "Lean Forward animation goes here");
}
}
}
}


What's odd is that if I type into channel 37 the dialog message that I want to send, it works as though I had selected it from the box itself - that is, it looks like the dialog box is running, but not showing up on the screen. Any idea what I'm doing wrong?

This is my first script, so it's more than likely that I'm making some horrible rookie mistake. :)

EDIT - oh, and the "Yes, I know you're sitting on me." line does indeed appear in chat channel 0, just in case that wasn't clear.
Silje Russell
lsl geek
Join date: 2 Oct 2005
Posts: 63
01-16-2007 22:36
Hey i see you use a lote of

CODE
llListFindList(list1, [message]) != -1)


i found it not always works for me so i changed ower to use

CODE
llListFindList(list1, [message]) > -1)

insted. dont know if that can have somting to do
_____________________
Yes i know i got typos..
I got writing and reading problems.
but i am still a humen!!
Anti Antonelli
Deranged Toymaker
Join date: 25 Apr 2006
Posts: 1,091
01-16-2007 23:01
I don't think llDetectedKey (or DetectedAnything) picks up an avatar on a sit target. Either way, you already have that value right there when you check llAvatarOnSitTarget, so either set a variable (key) to llAvatarOnSitTarget and use that or just replace llDetectedKey with another call to llAvatarOnSitTarget (slightly more resource-intensive).
Niklas Trilam
Registered User
Join date: 2 May 2006
Posts: 2
01-16-2007 23:12
Ah, that worked. Thanks, Anti.
Silje Russell
lsl geek
Join date: 2 Oct 2005
Posts: 63
01-17-2007 00:46
From: Anti Antonelli
I don't think llDetectedKey (or DetectedAnything) picks up an avatar on a sit target. Either way, you already have that value right there when you check llAvatarOnSitTarget, so either set a variable (key) to llAvatarOnSitTarget and use that or just replace llDetectedKey with another call to llAvatarOnSitTarget (slightly more resource-intensive).


lol i diden see that one my self :s
_____________________
Yes i know i got typos..
I got writing and reading problems.
but i am still a humen!!