Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

I need a little help with this script...

XYZ Zsun
Registered User
Join date: 30 Dec 2008
Posts: 2
12-30-2008 04:53
I'm scripting my very first magic wand and im having trouble with it. Here is the script:

showoffense()
{
key av = llDetectedKey(0);
string message = "Choose an offense spell!";
list buttons = ["Flippindo", "Argnus", "Traparsk", "Leviosa", "Leviosa Maximus"];
integer channel = -1337;
llDialog(av, message, buttons, channel);
}

showdefense()
{
key av = llDetectedKey(0);
string message = "Choose a defense spell!";
list buttons = ["Protecto", "Repulso", "Expecto Potronum", "Cloak", "Astral Projectum"];
integer channel = -1337;
llDialog(av, message, buttons, channel);
}

showmisc()
{
key av = llDetectedKey(0);
string message = "Choose an misc spell!";
list buttons = ["Lumos", "Accio", "---"];
integer channel = -1337;
llDialog(av, message, buttons, channel);
}

default
{
state_entry()
{
llSay(0, "If you need help with the usage of this staff, please read the notecard that came with it.";);
llListen(-1337, "", NULL_KEY, "";);
}

touch_start(integer total_number)
{
key av = llDetectedKey(0);
llSay(0, "Choose a Spell to Inflict upon your friends and foes!";);
string message = "Choose what type of spell";
list buttons = ["Offense", "Defense", "Misc"];
integer channel = -1337;
llDialog(av, message, buttons, channel);
}

listen( integer channel, string name, key id, string message )
{
if(message == "Offense";)
{
showoffense();
}
}
}

When I click the wand, the first menu comes up, when I click offense, it doesnt come up. The script compiles perfectly.
Very Keynes
LSL is a Virus
Join date: 6 May 2006
Posts: 484
12-30-2008 05:12
llDetectedKey is only valid in the Touch function.
Try this:

CODE

key av;

showoffense()
{
string message = "Choose an offense spell!";
list buttons = ["Flippindo", "Argnus", "Traparsk", "Leviosa", "Leviosa Maximus"];
integer channel = -1337;
llDialog(av, message, buttons, channel);
}

showdefense()
{
string message = "Choose a defense spell!";
list buttons = ["Protecto", "Repulso", "Expecto Potronum", "Cloak", "Astral Projectum"];
integer channel = -1337;
llDialog(av, message, buttons, channel);
}

showmisc()
{
string message = "Choose an misc spell!";
list buttons = ["Lumos", "Accio", "---"];
integer channel = -1337;
llDialog(av, message, buttons, channel);
}

default
{
state_entry()
{
llSay(0, "If you need help with the usage of this staff, please read the notecard that came with it.");
llListen(-1337, "", NULL_KEY, "");
}

touch_start(integer total_number)
{
av = llDetectedKey(0);
llSay(0, "Choose a Spell to Inflict upon your friends and foes!");
string message = "Choose what type of spell";
list buttons = ["Offense", "Defense", "Misc"];
integer channel = -1337;
llDialog(av, message, buttons, channel);
}

listen( integer channel, string name, key id, string message )
{
if(message == "Offense")
{
showoffense();
}
}
}
XYZ Zsun
Registered User
Join date: 30 Dec 2008
Posts: 2
12-30-2008 11:35
thank you!!!