func_button Toggle
Post Reply
Quote
Re: func_button Toggle
Posted by hexpunK on Sun Jun 29th at 6:39pm 2008


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.




Quote
Re: func_button Toggle
Posted by Riven on Sun Jun 29th at 10:34pm 2008


Accepted Answer

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.

  1. You can send an output from the func_button that looks like this:
    my output named: OnPressed
    Targets entities named: light (or whatever)
    Via this input: Toggle

    ^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.

  2. For entities that do not have a "toggle" input, you can use your 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

    -&-Another output that says:

    My output named: OnOut
    Targets entities named: light (or whatever)
    Via this input: TurnOff

    ^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.

Those are the easiest ways of using a single 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).







Quote
Re: func_button Toggle
Posted by hexpunK on Mon Jun 30th at 4:38pm 2008


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.




Quote
Re: func_button Toggle
Posted by hexpunK on Mon Jun 30th at 7:01pm 2008


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.




Quote
Re: func_button Toggle
Posted by Zein on Tue Jul 24th at 2:35am 2012


God I love Google, thanks for answering this question 4 years ago Riven! smiley




Post Reply