The mod you are trying to view has ceased development and consequently been archived. If you are a member of this mod, can demonstrate that it is being actively developed and will be able to keep this profile up to date with the latest news, images, videos and downloads, please contact us with all details and we will consider its re-activation.

An Open Window is an experimental MOD for Half-Life 2, Episode 2. In this project I will attempt to bring the concept of different realities to life in a realistic scenario. Instead of being another Shooter, AnOpWi centers around the role of the player and his/her experience, emotion and memories. By interacting with the world the player will define his own reality within the story. For this project I chose an open development cycle, which means I will update very frequently and share every step I take in the process of creating this game. Next to the regular media updates, I will also share my thoughts on the different areas of game design in the form of articles. In every article I will also ask for your opinion with the Question of the Day. This MOD also functions as a knowledge base for new and experienced designers.

Report RSS How to toggle entities without toggle input

This tutorial shows you how to create a button that can toggle entities which have no toggle input.

Posted by on - Advanced Mapping/Technical

This tutorial shows you how to create a button that can toggle entities which have no toggle input. Note that this tutorial is for advanced users and I presume you understand Source's Input/Output system.

1. The Setup
Image you want to create a light switch. You set up a func_button, a light, a lamp prop model (func_dynamic) and an env_sprite. In the func_button's output you target the light and env_sprite to Toggle on pressed.

2. The Problem
The lamp prop you're using has a lit texture skin, which looks strange when the light is turned off. Luckily the lamp has a dark skin version, so you can simply toggle the skin when the button is pressed. Here is where the problem lies. The prop_dynamic has no "ToggleSkin" input. It can only set a skin by using the "Skin" input which then requires the number of the skin you want to use. To make it worse, the func_button has no "OnPressedOn" and "OnPressedOff" outputs which could help you determine which skin to show. You're going to need a work-around.

3. The Workaround
Change the func_button to a func_brush or func_detail, turning it into a dummy. Now create a small thin block (1 unit) in front of the button with the NODRAW texture on it and make it a func_door. Because of the NODRAW texture, it'll be invisible in game. Set the following properties for this func_door:

Speed: 99999
Delay before reset: 0.1
Check Flags: Toggle / Use Opens / Door Silent

Now you can use the "OnOpen" and "OnClose" outputs to set the skins of the lamp prop. If the light is on initially, make sure you use "OnOpen" to turn everything off and "OnClose" to turn everything back on. This could be the setup.

OnOpen - lamp - Skin 1 (if 1 is the dark skin)
OnOpen - light - TurnOff
OnOpen - sprite - HideSprite
OnClose - lamp - Skin 0 (if 0 is the lit skin)
OnClose - light - TurnOn
OnClose - sprite - ShowSprite

4. Final Notes
By using invisible func_doors you can pretty much toggle every entity input, which the func_button can't. Before I wrote this article, I used the "OnIn" and "OnOut" outputs of the func_button to make toggling work. "OnIn" and "OnOut" refer to the movement of the func_button, but when the button was set not to move, it worked as an On/Off output. It stopped worked out of a sudden, so I guess an update fixed the bug I was exploiting or another bug slipped in. This is another reason why I would advice you to use the func_door trick, so you can make sure your sequences won't break because of a future update.

Post comment Comments
Jokerme
Jokerme - - 1,170 comments

Nice one. This is why Source needs some improvements. func_door works better as a button than func_button. This shouldn't happen.

Reply Good karma Bad karma+1 vote
zonbie
zonbie - - 1,299 comments

as long as my level works the way i want it to, i dont care if i have to use func_marshmallow parented to a env_fartcloud. adapt and overcome :)

Reply Good karma Bad karma+4 votes
Jeek
Jeek - - 117 comments

Haha, nicely said.

Reply Good karma Bad karma+1 vote
SPY-maps
SPY-maps - - 2,906 comments

funny, i just came around the same issue last night and i too fixed it the way you did.
personally i use the func_door for nearly everything, you can parent stuff to it to let things move, and the in/outputs give much options.
good tut, but for the advanced mapper as you said!

succes
leon

Reply Good karma Bad karma+1 vote
Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: