menu button toggles between to messages?
|
|
Lunar Tripsa
Registered User
Join date: 2 Feb 2007
Posts: 38
|
01-06-2008 18:29
Hi, I'm working with a dialog menu script and I know how to make 2 buttons which do the opposite of each other, but what I'd really like to do is have one button that when clicked in the dialog menu does one thing, then when clicked again does the opposite.
I'm really not sure how to set it up. I've blindly tried a few things, but I know I'm way off.
I'd like it to send this message on the first click: llMessageLinked(LINK_SET, 0, "up", NULL_KEY);
then this on the second click: llMessageLinked(LINK_SET, 0, "down", NULL_KEY);
then on the third click it would send the first message again.
Any tips would be greatly appreciated.
Also is it possible to change the text on the doalog button after it is clicked?
|
|
Alicia Sautereau
if (!social) hide;
Join date: 20 Feb 2007
Posts: 3,125
|
01-06-2008 18:41
could add a simple check and set an integer integer dialog_state = FALSE; //FALSE = down, TRUE = up if (dialog_state) { llMessageLinked(LINK_SET, 0, "up", ""  ; dialog_state = TRUE; } else { llMessageLinked(LINK_SET, 0, "down", ""  ; dialog_state = FALSE; } just an idea to for an approach 
|
|
Lunar Tripsa
Registered User
Join date: 2 Feb 2007
Posts: 38
|
01-06-2008 18:56
Thanks, I'll play with it a bit but, That works for the "up message, but it doesn't send the down message, just resends the up message. if ("Open"  { llMessageLinked(LINK_SET, 0, "up", ""  ; dialog_state = TRUE; displayDialog(id, "Up", FishTank, 1); } else { llMessageLinked(LINK_SET, 0, "down", ""  ; dialog_state = FALSE; displayDialog(id, "Down", FishTank, 1); }
|
|
Borat Kungler
Registered User
Join date: 13 Apr 2007
Posts: 33
|
01-06-2008 19:16
From: Lunar Tripsa Thanks, I'll play with it a bit but, That works for the "up message, but it doesn't send the down message, just resends the up message. if ("Open"  { llMessageLinked(LINK_SET, 0, "up", ""  ; dialog_state = TRUE; displayDialog(id, "Up", FishTank, 1); } else { llMessageLinked(LINK_SET, 0, "down", ""  ; dialog_state = FALSE; displayDialog(id, "Down", FishTank, 1); } That is because the if ("Open"  will always return true (because "Open" is going to equal "Open"  As Alicia said, replace if ("Open"  with if (dialog_state) and it should work 
|
|
Deanna Trollop
BZ Enterprises
Join date: 30 Jan 2006
Posts: 671
|
01-06-2008 19:27
From: Borat Kungler That is because the if ("Open"  will always return true (because "Open" is going to equal "Open"  More specifically, the string "Open" is a non-zero value, hence it evaluates as true. An empty string would evaluate as false.
|
|
Alicia Sautereau
if (!social) hide;
Join date: 20 Feb 2007
Posts: 3,125
|
01-06-2008 19:33
integer dialog_state = FALSE; integer CHANNEL = 42; default { state_entry() { llListen(CHANNEL, "", "", ""  ; } touch_start(integer usr) { if (dialog_state) { llMessageLinked(LINK_SET, 0, "up", ""  ; dialog_state = FALSE; llDialog(llDetectedKey(0), "We can only go Up!", ["Up", "exit"], CHANNEL); } else { llMessageLinked(LINK_SET, 0, "down", ""  ; dialog_state = TRUE; llDialog(llDetectedKey(0), "We can only go Down!", ["Down", "exit"], CHANNEL); } } } as said abouve, just replace the dialog_state to anything but used 
|
|
Lunar Tripsa
Registered User
Join date: 2 Feb 2007
Posts: 38
|
01-06-2008 20:32
Okay well that works great, but it also works great for all my other buttons in the menu too...
Thanks for your help though, very much appricated
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
01-06-2008 21:40
integer gBooSwitch
touch_start( integer vIntTouches ){ if (gBooSwitch){ //-- button code A }else{ //-- button code b } gBooSwitch = !gBooSwitch; }
and if you can incorporate the boolean into your code to get the action you want it could be even simpler
//-- some code that acts oppositely when fed TRUE(1) vs when fed FALSE(0) gBooSwitch = !gBooSwitch
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
01-06-2008 22:08
Another way you could do this that might allow you to avoid changing state between dialogs is to issue the same dialog on two different channels. If you have listens on both channels, you can test which one a message is issued on.
|
|
Lunar Tripsa
Registered User
Join date: 2 Feb 2007
Posts: 38
|
01-06-2008 22:12
thank you all. I finally got it working. No idea why exactly it works lol, but it does!
woot!
|