func_button Toggle

func_button Toggle

Re: func_button Toggle Posted by hexpunK on Sun Jun 29th 2008 at 6:39pm
hexpunK
15 posts
Posted 2008-06-29 6:39pm
hexpunK
member
15 posts 12 snarkmarks Registered: Mar 24th 2008 Occupation: Student, paperboy, Web Master, Amatuer M Location: England
Ok, if you've read the description you'll know my question. I want to know how to make a func_button turn something on, then off after the second press.

Thanks for any help anyone gives me. And sorry if this has already been asked, but I could'nt find a topic or tut on it.
Re: func_button Toggle Posted by Riven on Sun Jun 29th 2008 at 10:34pm
Riven
1640 posts
Posted 2008-06-29 10:34pm
Riven
Wuch ya look'n at?
super admin
1640 posts 1266 snarkmarks Registered: May 2nd 2005 Occupation: Architect Location: Austin, Texas, USA
Well, seeing that you used the word "toggle" in your question then you must have noticed the option for it when sending outputs to other entities. There are two easy ways I can think of ATM on how to do this.


<OL type=1>
[*] You can send an output from the [color=limegreen]func_button
that looks like this:
my output named: OnPressed
Targets entities named: light (or whatever)
Via this input: Toggle[/color]

^That will give you a light that can be turned on or off with a single button. If you select the flag to tell the light to start off, then when you press the button, it will turn on. So, for instance, this method would work if you had several light switches in a room, and all gave them this output to the same light; they should function like a real set of light switches.



[*] For entities that do not have a "toggle" input, you can use your [color=limegreen]func_button
to perform these two (2) outputs to get the same effect of the previous method:
My output named: OnIn
Targets entities named: light (or whatever)
Via this input: TurnOn[/color]

-&-Another output that says:

[color=blue]My output named:
OnOut
Targets entities named: light (or whatever)
Via this input: TurnOff[/color]

^And that would give you the same effect as the "toggle" output. But this version really only works for one button, unless you don't mind your buttons having to be specified to an "on" or "off" state (just make sure the player realizes it, or it may frustrate them), rather than just a switch that will 'toggle' between the two modes.

</LI></OL>


Those are the easiest ways of using a single [color=limegreen]func_button, but if you think about it, you can create much more elaborate versions that can give you some flexibility by adding in criteria that may need to be met before a switch can work (from the light's end of the I/O system). BTW, I too did a quick forum search to no avail on this topic. I'm surprised it's never been posted before, this is a beginner?s topic, but one that eludes many people, (including myself once).[/color]
Blog: www.playingarchitecture.net
LinkedIn: Eric Lancon
Twitter:@Riven202
Re: func_button Toggle Posted by hexpunK on Mon Jun 30th 2008 at 4:38pm
hexpunK
15 posts
Posted 2008-06-30 4:38pm
hexpunK
member
15 posts 12 snarkmarks Registered: Mar 24th 2008 Occupation: Student, paperboy, Web Master, Amatuer M Location: England
ah, thanks for the help with that, the second bit is the one im looking for, I have tried doing that, but because the buttons automatically reset themselves it causes a problem with mine. I should have added this on the first post but I am making a switch to toggle a force field (func_brush) on and off. I set the reset time to -1 to see if that would help but it just made the switch turn it on but not off leaving you stick inside the building XD. Is there a better entity for this by any chance.
I have tried the two button system, I even used lights to say on or off and entity that displays text at a certain point, I forget the name, but it was tiresome an gave away the buttons position, they are meant to be a little bit hidden.
Re: func_button Toggle Posted by hexpunK on Mon Jun 30th 2008 at 7:01pm
hexpunK
15 posts
Posted 2008-06-30 7:01pm
hexpunK
member
15 posts 12 snarkmarks Registered: Mar 24th 2008 Occupation: Student, paperboy, Web Master, Amatuer M Location: England
ok my problem is fixed mow, for future reference I think I might make a smallish tutorial for it, or just post it here for someone else to sort out a tutorial.

When making a single button to toggle entities that don't support the toggle input, go into "flags" and check "Toggle", then just set the first thing you want to do in the toggle to "OnIn" then the second thing to "OnOut" rather like what Riven said.
Re: func_button Toggle Posted by Zein on Tue Jul 24th 2012 at 2:35am
Zein
167 posts
Posted 2012-07-24 2:35am
Zein
member
167 posts 517 snarkmarks Registered: Sep 1st 2006 Occupation: Computer fixing Location: United States
God I love Google, thanks for answering this question 4 years ago Riven! :hee: