Snarkpit Articles


This tutorial will describe how to make a button turn a light on and off- obviously with a bit of intelligence it can easily be extended to make a button do anything!

First of all, create the thing you want to turn on and off- in this case, a light entity. Simply give it a name (e.g. light1) and set any other visual properties you want.

Now, we will use a model as our button base. Make a prop_dynamic, set its name to button_model, and find a nice world model for it- this tutorial will use models/props_combine/CombineButton.mdl. This button does nothing on its own, so we need some sort of trigger.

Create a func_button brush entity "inside" your button model, and cover it in the toolsinvisible texture:



As the button is invisible, we don't really want it to move when used, so tick the Don't Move flag (and the Use Activates flag). And as this is a funky Combine button, we want a decent Combine-ish sound (e.g. combine blip growl).

If you want something simple like a light switch you will want to be able to "toggle" the button- i.e. switch it on and off whenever you want- by ticking the toggle flag. If instead you want a button that takes some time before you can press it again, give it a delay before reset value (set this to -1 if you can only press the button once!).

Finally, we need to set the Outputs of the func_button (so it does something when we use it!). Click 'Add', and you want an Output named OnPressed targeting entities named light1 via input toggle. See the image below if you get stuck. And note there are other input types (TurnOff and TurnOn, for example) which are explained in that entitys help guide.

We could finish here, but oh no, we want the button to look like its doing something when pressed! Go back to the prop_dynamic button, and click on the "Model" tab at the top of its properties. Look through the sequences there- we want the press animation for when its pressed. So go back to the func_button and add a new output: when OnPressed, target button_model via the SetAnimation input, with a parameter override of press. Done!



Post ReplyView Topic
Discussion
0 starsPosted by Blargdaniel on Thu Dec 20th 2007 at 6:24am

How do you make a func button brush?
0 starsPosted by mapzor on Sun Nov 13th 2005 at 1:44pm

Nice tut dude smiley gonna use that on my mapping smiley 10/10
0 starsPosted by Pureferret on Thu May 26th 2005 at 3:04pm

Simple but good. smiley
0 starsPosted by Bash on Tue Feb 22nd 2005 at 11:42am

Thanks, will check that out
[author]
Posted by Leperous on Tue Feb 22nd 2005 at 12:03am

You need to have the button output to a logic_branch entity:
<a href="http://www.snarkpit.com/editing.php?page=entity&amp;game=HL2&amp;name=logic_branch" target="_blank">http://www.snarkpit.com/editing.php?page=entity&amp;game=HL2&amp;name=logic_branch</a>
0 starsPosted by Bash on Mon Feb 21st 2005 at 10:26pm

Hey, just started hl2 mapping, just registered here, and just doin my first post: Hi everyone!

@topic:
Nice tutorial, I like the output handling of the hammer compared to hl1. I combined this button tutorial with cbk's dynamic light tutorial to make a toggle lightswitch and came to one problem/question:

Cbk's tutorial consists of two light entitys: a light_dynamic and a point_spotlight. The light_dynamic has a toggle input, but the point_spotlight has only turn on/off; you can't toggle it.

So do you have to put an extra entity between button and point_spotlight to fake/create a toggle function? How'd you make that? Or is there another way?

Best regards

Bash
0 starsPosted by g0tm*/k on Thu Jan 20th 2005 at 6:34am

Cool, good intro to the new i/o
0 starsPosted by Random on Fri Jan 7th 2005 at 8:13pm

Nice i was loooking for this
0 starsPosted by Yesurbius on Fri Jan 7th 2005 at 6:55am

Good tutorial. Need some proofreading: we want the button to do look like its doing something when pressed! (Got an extra 'do' in there).

I am going to reference this tutorial in the new one I am making .. I am so lazy smiley

Good job again.
0 starsPosted by Forceflow on Thu Jan 6th 2005 at 5:40pm

Good tut
Post ReplyView Topic