Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Dialog help!

shenanigan Oh
Registered User
Join date: 28 Apr 2007
Posts: 13
07-19-2007 18:57
Hello,

I'm trying make a dialog where it turns on and off a light. But way I want it to work is when you click the object the dialog pops ups and says one of other like first light on then after I click it, it will switch the light on too light off. Here script I'm working on if anyone can help me out.

Thanks for help.



string light = "light off";
list main_menu = [light];
default
{
state_entry()
{
llListen(5666,"",llGetOwner(),"";);
}
listen(integer channel,string name,key id,string message)
{

if(message == "light on";)
{
light =(string) "light off";
llOwnerSay("test 1";);
}
if(message == "light off";)
{
light =(string) "light on";
llOwnerSay("test";);
}
}


touch_start(integer total_number)
{
if(llDetectedKey(0) == llGetOwner())
{
llDialog(llDetectedKey(0),"Main Menu",main_menu, 5666);
}
}
}
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
07-19-2007 19:12
This is really close, I think. The problem is that the script is changing the value of the "light" variable, but that doesn't affect the "main_menu" list because it gets the value of "light" *at the time of assignment*. So, where there's assignments like:

light = (string) "light on";

what's needed is more like:

main_menu = [ "light on" ] ;

(It's not necessary to typecast a literal string to ";(string)", by the way.)

To actually turn the light on and off, llSetPrimitiveParams() will probably be useful, using the PRIM_POINT_LIGHT parameter settings.
Shadow Subagja
Registered User
Join date: 29 Apr 2007
Posts: 354
07-19-2007 19:12
Try something like this

CODE

integer menuChannel = 5666;
integer LIGHT_ON=TRUE;
default
{
state_entry()
{
llListen(menuChannel,"",llGetOwner(),"");
}
listen(integer channel,string name,key id,string message)
{

if(message == "light on")
{
LIGHT_ON=TRUE;
llOwnerSay("test 1");
}
if(message == "light off")
{
LIGHT_ON=FALSE;
llOwnerSay("test");
}
}


touch_start(integer total_number)
{
if(llDetectedKey(0) == llGetOwner())
{
string lightButton = "light ";
if(LIGHT_ON)
lightButton = lightButton + "off";
else
lightButton = lightButton + "on";
llDialog(llDetectedKey(0),"Main Menu",lightButton, menuChannel);
}
}
}
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
07-19-2007 19:41
(except I think the buttons have to be in a list for llDialog)
Shadow Subagja
Registered User
Join date: 29 Apr 2007
Posts: 354
07-19-2007 20:26
oh yeah :P

change this line:
llDialog(llDetectedKey(0),"Main Menu",lightButton, menuChannel);

to

llDialog(llDetectedKey(0),"Main Menu",[lightButton], menuChannel);
shenanigan Oh
Registered User
Join date: 28 Apr 2007
Posts: 13
07-19-2007 21:52
Sweet thanks for help :)