I know this must be rediculously simple but scripting boggles me.
I wish to have a button on a hud that when pushed tells another object to either show or hide.
Any help or advice is appreciated.
These forums are CLOSED. Please visit the new forums HERE
show/hide object from a hud? |
|
|
Cheewha Palen
Registered User
Join date: 27 Nov 2007
Posts: 78
|
05-01-2008 04:24
I know this must be rediculously simple but scripting boggles me.
I wish to have a button on a hud that when pushed tells another object to either show or hide. Any help or advice is appreciated. |
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
05-01-2008 09:01
You'll want probably a 'touch_start' handler in the script within your HUD (button). That will send a message on a non-zero channel telling the other object to show/hide itself. The show/hide object will start a listen with llListen() on that channel. Inside its 'listen' event handler it will possibly test which message it received before hiding/showing itself, probably with llSetLinkAlpha() or llSetLinkTexture(). See the following documentation pages:
http://www.lslwiki.net/lslwiki/wakka.php?wakka=touch_start http://www.lslwiki.net/lslwiki/wakka.php?wakka=chat http://www.lslwiki.net/lslwiki/wakka.php?wakka=llListen http://www.lslwiki.net/lslwiki/wakka.php?wakka=listen http://www.lslwiki.net/lslwiki/wakka.php?wakka=llSetLinkAlpha http://www.lslwiki.net/lslwiki/wakka.php?wakka=llSetLinkTexture Good luck, and be sure to post follow-ups when you have questions about specific pieces! |
|
Cheewha Palen
Registered User
Join date: 27 Nov 2007
Posts: 78
|
05-01-2008 14:13
Hi thanks for the references.
This is what I have so far: CODE
simple enough and it works! but only in one direction...lol. Based on this how would I go about getting the script to turn on when touched and off by the next touch? The easy/lazy way would be to have two buttons on my hud...lol. But I know that isnt the answer. Thank you again for your help! |
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
05-01-2008 15:38
simple integer switch:
CODE integer on = 1; Explanation: TRUE = 1 & FALSE = 0 in integers So the if tests to see if on = TRUE Whichever one it is, at the end you are changing on to it's opposite FALSE becomes TRUE and vice versa everytime it is touched. _____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum |
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
05-01-2008 15:41
simple enough and it works! but only in one direction...lol. Based on this how would I go about getting the script to turn on when touched and off by the next touch? The easy/lazy way would be to have two buttons on my hud...lol. But I know that isnt the answer. Two buttons would work. You could also keep a global variable that tracks the state of visibility the object is SUPPOSED to have (either currently or next), and send a message that is appropriate to that state. For example: CODE
EDIT: Oops. IOW what Jesse said. Don't cross the beams! ![]() |
|
Shadow Subagja
Registered User
Join date: 29 Apr 2007
Posts: 354
|
05-01-2008 15:41
instead of sending 'on' in your llSay, say 'toggle', then configure your listener object to listen for 'toggle' and alternatively hide/show itself. Like this;
integer VISIBLE = true; CODE
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
05-01-2008 15:46
instead of sending 'on' in your llSay, say 'toggle', then configure your listener object to listen for 'toggle' and alternatively hide/show itself. That's another great solution. That way you don't duplicate state data between the object and the HUD script, and the button will always work instead of occasionally missing a beat (e.g. if one chat message is missed, the next one will also be messed up; if the object has multiple controllers, they don't have to synchronize their states; etc.). |
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
05-01-2008 15:51
EDIT: Oops. IOW what Jesse said. Don't cross the beams! ![]() LMAO! This is the 3rd integer switch we have done in a few days for people. Guess I am going to have to get off of my butt one of these days and add it to the wiki touch_start entry. I do remember how miraculous it was when I first saw it and understood what was happening. I said bye bye that day to a lot of unnecessary state changes. _____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum |
|
Cheewha Palen
Registered User
Join date: 27 Nov 2007
Posts: 78
|
05-04-2008 07:12
Hi to all who contributed!
I wanted to thank all of you for your help and support to my thread, the advice given not only answered my questions but taught me a bit about how this particular scripting works. I am sure glad for the help. Prims and textures sing to me but scripts generally yell at me...hehe. Thanks again Cheewha |
|
Very Keynes
LSL is a Virus
Join date: 6 May 2006
Posts: 484
|
05-04-2008 07:42
Just for fun, here is my take on it
//switch.lsl CODE
//target.lsl CODE
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
05-04-2008 08:57
Just for fun, here is my take on it //switch.lsl CODE
ooooooooo! Nice one Very! _____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum |