H2A Forge: Scripting Guide

Nov 2, 2014
34
8
23
32
#1
This is a work in progress - Please be patient while I attempt to transpose all my thoughts into this forum post.


Preface:

This is a guide to try and explain how scripting in H2A Forge works. Included is basic information and tutorials on the different scripts, switches, timers, and triggers, and how to set them up; plus some advanced tutorials for creating scripts that go above and beyond the standard ones.

The advanced tutorials will currently cover some complex scripts I have created; but, as time goes on , if other forum members come up with their own advanced scripts and post them here, then I will add them to the Advanced Tutorials section.

Contents:
  • Overview
  • Broadcasters
    • Broadcast Channel Activation Types
      • On
      • Off
      • Toggle
    • Activation Event Types
      • Switch
      • Timer
      • Proximity Trigger
      • On-Destroyed Trigger
    • "Specific Team Only Enabled" Option
  • Listeners
    • Listener Types
      • Special
        • Explosive
        • Animation
        • Emp
      • Power
      • Spawning
  • Scripting Bugs
  • Basic Tutorials
    • Providing player feedback
  • Advanced Tutorials
    • On-Destroyed: Off/Toggle
    • Switch/Trigger: On-Duration-Off
    • Switch/Trigger: On-ExtendableDuration-Off
Overview

Scripting is a feature new to H2A forge which allows forgers to setup player-driven and non player-driven, events, actions, and behaviours. For example, a forger could add a script to their map which allows a player to open a door whenever they press a button switch.​

Forum member Stevo has provided a brief video showing off some basic script functions. http://1drv.ms/1xkZhMu

Below is a summary of the three required components of a working forge script.

Broadcaster component

Only a broadcaster forge object is a broadcaster component; they are found under "Scripting" on the "Place Object" Menu (and there is also the "Garage Door Switch" broadcaster under "Map Gadgets").

This component's role is to change the activation state of a particular broadcast channel, based on a given activation event.

Example: The "Switch: On" broadcaster object, set to broadcast channel 1 - this turns on broadcast channel 1 when the player holds down the "Use" button on it.

A more in-depth look at broadcasters, their activation event types, and broadcast channel activation types, is detailed under the "Broadcasters" section of this guide.
Listener component

Any forge object can have a listener component (even broadcaster objects), and many can have multiple listeners. A forge object is assigned listeners via the "Scripting" properties under the object's "Object Options" Menu.

This component's role is to listen on a particular broadcast channel, and then respond with some kind of action, or behaviour, based on what type of listener it is and the activation state of the channel.

Example: The "Garage Door" forge object, with the "Animation" listener listening on broadcast channel 1 - the garage door is opened when broadcast channel 1 is on, and closed when that channel is off.

A more in-depth look at listeners, and their types, is detailed under the "Listeners" section of this guide.
Broadcast channel component

This component's role is to act as the link between any broadcasters and listeners set to it. The channel is represented as a number, from 0 to 63. If a broadcaster or listener is set to a channel of -1 then it means it is not set to any broadcast channel at all.

A broadcast channel can be in one of two activation states: "on" or "off". The default starting state of a broadcast channel is "off", until altered by an associated broadcaster.

Tip: Although a broadcast channel's starting state is "off", you can use a "Timer: On Once" broadcaster to set it to "on" at the start of a game. If you do this though, you should not set the timer's delay to 0 because this will cause issues for anyone who isn't the Host of the game; instead, set the timer's delay to somewhere around 5 seconds, as this allows for Non-Host players to load into the map before the timer activates - don't worry, the timer still activates long before anyone spawns onto the map itself thanks to the 10 second "deploying" countdown at the start of a game.

Broadcasters

Any given broadcaster object has a particular activation event and broadcast channel activation type.

Example: The "Switch: On" object uses the "Switch" activation event (requires a user to hold a button to activate the broadcaster), and is of the "On" channel activation type (it will turn on the associated broadcast channel).​

Note that all broadcasters will work while in Forge; this means you can test them without needing to load your map in Custom Games.​

Broadcast Channel Activation Types:

On

When activated, a broadcaster with this channel activation type will turn on its associated broadcast channel.
Off

When activated, a broadcaster with this channel activation type will turn off its associated broadcast channel.
Toggle

When activated, a broadcaster with this channel activation type will flip its associated broadcast channel between "on" or "off", i.e. if the associated broadcast channel is currently on then it will be turned off, and if it is currently off then it will be turned on.
Activation Event Types:

Switch

Activating a broadcaster with this event type always requires a player to hold down the "Use" button in the location where the broadcaster object has been placed.

All switch broadcaster objects are invisible outside of Forge, but will provide a user prompt of "Hold {use button} to use" when a player is close enough to the object.

List of broadcaster objects with this event type:
  • Place Object -> Scripting -> Switches:
    • Switch: On - When a player holds the "use" button near it, its associated broadcast channel turns on.
    • Switch: Off - When a player holds the "use" button near it, its associated broadcast channel turns off.
    • Switch: Toggle - When a player holds the "use" button near it, its associated broadcast channel flips between "on" or "off".
Switch Tutorial Video
Timer

Activating a broadcaster with this event type happens automatically, as soon as the broadcaster is created. Once the broadcaster has activated, it can be given a delay, via its "Timer/User data" in seconds, before it alters its associated broadcast channel. By default, a Timer will have no delay (it's set to 0).

All timer broadcaster objects are invisible outside of Forge, and will give no indication to the player that they exist.

Because a timer automatically activates when created, it will typically be used in conjunction with a broadcaster that does require player input, so that the activation of the timer can be controlled. Controlling the activation of a timer is done by assigning it a "Power" listener, which will then only enable the timer (and begin its delay, if any) when the broadcast channel of that listener is on.

There is also the "once" variant of timers. A standard timer, when its timer delay has expired, and it alters a broadcast channel, will then reset and countdown its delay time again. A "once" timer, however, will only countdown its delay one time; after its first delay has expired, and it alters a broadcast channel, it is no longer active; its delay can then only be started again by deactivating and reactivating its power channel, or if it is respawned.

List of broadcaster objects with this event type:
  • Place Object -> Scripting -> Timers:
    • Timer: On - When activated, after a set delay, its associated broadcast channel turns on, and then it loops.
    • Timer: On Once - When activated, after a set delay, its associated broadcast channel turns on one time.
    • Timer: Off - When activated, after a set delay, its associated broadcast channel turns off, and then it loops.
    • Timer: Off Once - When activated, after a set delay, its associated broadcast channel turns off one time.
    • Timer: Toggle - When activated, after a set delay, its associated broadcast channel flips between "on" or "off", and then it loops.
    • Timer: Toggle Once - When activated, after a set delay, its associated broadcast channel flips between "on" or "off" one time.
Timers are, in a way, the "magic sauce" that allow for more complicated and advanced scripts; this is because timers will allow you to affect multiple broadcast channels at once from one initial broadcaster, as well as add delays and durations to the activation of those channels. Timers may take a little more time for a forger to fully understand but, once he does, his scripts can become considerably more powerful.

Timer Tutorial Video
Proximity Trigger

Activating a broadcaster with this event type requires a player to enter/exit a trigger zone, which is created around the trigger object. This trigger zone's size and shape can be configured in the same way that, for instance, a hill marker's size and shape can be configured.

All proximity trigger broadcaster objects are invisible outside of forge, and will give no indication to the player that they exist.

There are three variants of a proximity trigger which alter how a player's interactions with its trigger zone activates the broadcaster:
  • On-Enter - This broadcaster activates when a player enters its trigger zone.
  • On-Exit - This broadcaster activates when a player leaves its trigger zone.
  • On-Stay - This broadcaster activates when the first player enters its trigger zone, and activates again when the last player leaves its trigger zone, e.g. 2 players enter the trigger zone - only the first player activates the trigger; then both players leave the trigger zone - only the second player activates the trigger again.
List of broadcaster objects with this event type:
  • Place Object -> Scripting -> Triggers:
    • On-Enter: On - When a player enters its trigger zone, its associated broadcast channel turns on.
    • On-Enter: Off - When a player enters its trigger zone, its associated broadcast channel turns off.
    • On-Enter: Toggle - When a player enters its trigger zone, its associated broadcast channel flips between "on" or "off".
    • On-Exit: On - When a player leaves its trigger zone, its associated broadcast channel turns on.
    • On-Exit: Off - When a player leaves its trigger zone, its associated broadcast channel turns off.
    • On-Exit: Toggle - When a player leaves its trigger zone, its associated broadcast channel flips between "on" or "off".
    • On-Stay: On - When first player enters its trigger zone, and again when last player leaves its trigger zone, its associated broadcast channel turns on.
    • On-Stay: Off - When first player enters its trigger zone, and again when last player leaves its trigger zone, its associated broadcast channel turns off.
    • On-Stay: Toggle - When first player enters its trigger zone, and again when last player leaves its trigger zone, its associated broadcast channel flips between "on" or "off".
Bug Warning: As detailed in the "Scripting Bugs" section, the power listener/power channel does not work on Proximity Trigger broadcasters.

Proximity Trigger Tutorial Video

Proximity Trigger "Broken Power Channel" Workaround Video
On-Destroyed Trigger

Activating a broadcaster with this event type requires the broadcaster object to be damaged in some way. Note that the object does not need to be damaged where it is lit up - it can be damaged anywhere on the object.

Methods of damaging the on-destroyed trigger object, to activate it:
  • A player shooting the trigger object.
  • A player performing a melee attack on the trigger object.
  • An explosion going off close enough to the trigger object.
  • A player or object smashing into the trigger object with enough speed/force.
For a player to damage this broadcaster, that player must be able to do damage. For example, if a player has a weapon damage modifier of 0% then shooting the broadcaster will not activate it, because the player is not dealing any damage to that broadcaster.

Unlike other broadcaster objects, on-destroyed objects are visible in both forge and custom games.

Unlike with other broadcasters, the only version of an on-destroyed trigger is one that turns on an associated broadcast channel; there are no "off" and "toggle" variants. It is still possible however to replicate "off" and "toggle(ish)" behaviour using timers as an intermediary between your trigger and the object you want to affect.

List of broadcasters with this event type:
  • Place Object -> Scripting -> Triggers:
    • On-Destroyed: When this broadcaster is damaged, its associated broadcast channel turns on.
  • Place Object -> Gadgets -> Map Gadgets:
    • Garage Door Switch: When this broadcaster is damaged, its associated broadcast channel turns on.
Note that the "Garage Door Switch" object behaves exactly the same as the "On-Destroyed" object; it just looks different.

On-Destroyed Trigger Tutorial Video
"Specific Team Only Enabled" Option

For the "Switch" and "Proximity Trigger" broadcasters, it is possible to configure them so that they are only enabled for a specific team and then disabled for all others.

To setup one of these broadcasters for a specific team, change its "Team" property from "Neutral" to the team you want that broadcaster to be enabled for, e.g. setting a "Switch: On" broadcaster's "Team" property to "Defenders" will mean that only the Red Team can activate that switch - for any other team that switch will be disabled.

For FFA gametypes this setting will have no effect - regardless of the "Team" property's setting, the broadcaster object will always be enabled. Note that the "Infection" gametype is classed as FFA as far as this property is concerned.

"Specific Team Only Enabled" Option Tutorial Video

Listeners

A listener is setup against a Forge Object via that object's channel properties. A particular type of listener is associated with a particular channel property. Setting a channel property to a valid broadcast channel is what activates a particular listener to listen to that broadcast channel. A Forge Object can then react to that broadcast channel being turned on or off.​

Example: A Mongoose has the "Spawn Channel" property, which is associated with the "Spawning" type of listener. Setting that Mongoose's spawn channel property to 0 means that the Mongoose will spawn onto the map when broadcast channel 0 is turned on.​

Listener Types:

Special

The "Special" category of listeners covers a set of listener types that are all configured on the same channel property, which is the "Broadcast Channel" property; note that this is the same property as used by Broadcaster objects, but for any Forge Objects that is not a Broadcaster this property instead configures its special listener.​

A Forge Object that has a special listener can only be one of the following special listener types:​

Explosive

Setting up a Forge Object with this listener type is done via that object's "Broadcast Channel" property under its "Scripting" object properties; setting that property's value to a valid broadcast channel activates the explosive listener.

Forge Objects with this listener react in the following way to the associated broadcast channel's state:
  • Broadcast channel turns on: The Forge Object explodes
  • Broadcast channel turns off: No reaction
Because all special listeners share the same channel property, not all Forge Objects with a "Broadcast Channel" property use the explosive listener.
List of Forge Objects with the explosive listener:
  • Place Object -> Gadgets -> Explosives:
    • Fusion Coil
    • Fusion Coil, EMP
    • Landmine
    • Landmine, EMP
    • Explosion Volume, Small
    • Explosion Volume, Small Inv
    • Explosion Volume, Large
    • Explosion Volume, Large Inv
Note that the landmines have a quirk to their behaviour. When a landmine with an explosive listener spawns onto the map, it actually forces the broadcast channel that it's listening on back to "off". No other object, outside of the broadcasters, can turn a broadcast channel on or off, but it would seem the landmines can.
Animation

Setting up a Forge Object with this listener type is done via that object's "Broadcast Channel" property under its "Scripting" object properties; setting that property's value to a valid broadcast channel activates the animation listener.​

Forge Objects with this listener react in the following way to the associated broadcast channel's state:
  • Broadcast channel turns on: The Forge Object animates to a new object state
  • Broadcast channel turns off: The Forge Object animates back to its original object state
Because all special listeners share the same channel property, not all Forge Objects with a "Broadcast Channel" property use the animation listener.

List of Forge Objects with the animation listener:
  • Place Objects -> Gadgets -> Lights:
    • All Lights under this category: The light turns off when the broadcast channel turns on, and the light turns back on again when the broadcast channel turns off
  • Place Objects -> Gadgets -> Map Gadgets:
    • Switch: Animates closed when the broadcast channel turns on, and opens back up when the broadcast channel turns off
    • Garage Door: Animates open when the broadcast channel turns on, and closes back up when the broadcast channel turns off
    • Console Switch: Shows a blue-screen when the broadcast channel turns on, and goes back to showing the ready screen when the broadcast channel turns off
EMP

Setting up a Forge Object with this listener type is done via that object's "Broadcast Channel" property under its "Scripting" object properties; setting that property's value to a valid broadcast channel activates the EMP listener.

Forge Objects with this listener react in the following way to the associated broadcast channel's state:
  • Broadcast channel turns on: An EMP detonates around the Forge Object, and it animates to a new object state
  • Broadcast channel turns off: The Forge Object animates back to its original object state
Because all special listeners share the same channel property, not all Forge Objects with a "Broadcast Channel" property use the EMP listener.

List of Forge Objects with the EMP listener:
  • Place Objects -> Gadgets -> Map Gadgets:
    • EMP Device, Blue: Gives off a blue coloured EMP, and animates closed, when the broadcast channel turns on, and animates back to open, with a blue glowing orb, when the broadcast channel turns off
    • EMP Device, Red: Gives off a red coloured EMP, and animates closed, when the broadcast channel turns on, and animates back to open, with a red glowing orb, when the broadcast channel turns off
"Special" Listeners Tutorial Video
Power

Setting up a Forge Object with this listener type is done via that object's "Power Channel" property under its "Scripting" object properties; setting that property's value to a valid broadcast channel activates the power listener.

Forge Objects with this listener react in the following way to the associated broadcast channel's state:
  • Broadcast channel is on: Certain scripting functionality on the Forge Object is enabled
  • Broadcast channel is off: Certain scripting functionality on the Forge Object is disabled
List of Forge Objects with the power listener:
  • Place Objects -> Scripting:
    • All Scripting Broadcasters under this category: Broadcasting ability is enabled when the broadcast channel is on, and disabled when the broadcast channel is off
  • Place Objects -> Gadgets:
    • All Forge Objects with special listeners under this category: The object's special listener is enabled when the broadcast channel is on, and disabled when the broadcast channel is off
Bug Warning: As detailed in the "Scripting Bugs" section, the power listener/power channel does not work on Proximity Trigger broadcasters.

"Power" Listener Tutorial Video
Spawning

Setting up a Forge Object with this listener type is done via that object's "Spawn Channel" property under its "Scripting" object properties; setting that property's value to a valid broadcast channel activates the spawning listener.

In addition to the "Spawn Channel" property, the spawning listener has another piece of configuration, which is its "Can Despawn" property - also under its "Scripting" object properties; by default this property is set to "false".

Forge Objects with this listener react in the following way to the associated broadcast channel's state, and the "Can Despawn" property setting.
  • Can Despawn: False, Broadcast channel is on: The Forge Object tries to spawn onto the map
  • Can Despawn: False, Broadcast channel is off: No reaction
  • Can Despawn: True, Broadcast channel is on: The Forge Object tries to spawn onto the map
  • Can Despawn: True, Broadcast channel is off: The Forge Object despawns off of the map
In addition to this configuration, we also need to disable the normal spawning mechanics that the Forge Object would use if it wasn't being scripted; this is because the normal spawning mechanics interfere with the spawning listener. The changes we need to make, to disable those mechanics, are as follows:
  • Object Properties:
    • Spawn Time: Set this to "Never", so that the Forge Object doesn't try to respawn itself every x seconds
  • Object Properties -> Advanced:
    • Place At Start: Set this to "False", so that the Forge Object doesn't spawn itself in at the beginning of the game - otherwise this would override the scripting, which says an object should not be spawned onto the map unless its associated broadcast channel is on
    • Min Count: Make sure to keep this number below the number of instances of this object type that are involved in spawning scripts. If you're unsure what this means, just keep it at 0. If you set this number too high, it will force the object to spawn onto the map, regardless of the spawn scripting behaviour on that object.
Note that Halo's spawning rules still apply to Forge Object's being spawned via the spawning listener. For example, any object that is not a weapon will not spawn onto the map if a player or vehicle is too close that object's spawn location. As long as the spawn listener's broadcast channel remains on however, then the object will spawn in as soon as it has "room".

Every Forge Object in the game has the spawning listener configuration. However...

Bug Warning: As detailed in the "Scripting Bugs" section, there are a number of Forge Objects which, despite having a "Spawn Channel" and "Can Despawn" property, cannot actually have their spawning controlled via their spawning listener. For these objects, they will always be spawned onto the map regardless of their configuration.

"Spawning" Listener Tutorial Video
Scripting Bugs
  • The "Power Channel" property on Proximity Trigger broadcasters does not work: No matter what broadcast channel this broadcaster's power channel is set to, and regardless of whether that broadcast channel is "on" or "off", this broadcaster will always be enabled.
  • The "Spawn Channel" property of the "Trait Zone" object does not work: No matter what broadcast channel this object's spawn channel is set to, and regardless of whether that broadcast channel is "on" or "off", this object will always be spawned onto the map at the beginning of the game, and it cannot be despawned.
  • A "Timer: On Once" broadcaster, set to turn on a Broadcast Channel at the start of a game, will not work for Off-Host players if its delay is set to "0": For any player who isn't the host, this broadcaster will not appear to be turned on - most likely due to the timer activating as soon as the Host has entered the game, which happens before any other player has entered the game. To resolve this, give this broadcaster a delay of around 5 seconds, so that the timer activates after everyone has entered the game, but before any players have spawned onto the map.
More content coming soon.
 
Last edited:

Stevo

The Grinchmind
Dec 31, 2012
248
116
108
28
United Kingdom
#5
Looking good buddhachops.

For FFA gametypes this setting will have no effect - regardless of the "Team" property's setting, the broadcaster object will always be enabled. Note that the "Infection" gametype is classed as FFA as far as this property is concerned.
Ohhh... How we know this... :(
 
Feb 8, 2013
1,307
723
173
Germany
www.youtube.com
#6
Yo Buddha.

So I already posted this on the Forge Disc. thread, but it seems like nobody knows a solution to this. You seem to be much into scripting, so I thought I'd post this here and ask you:

I want to make it so if I shoot a garage door switch, a hard object (for example any type of block, decoratives, etc. | NO interactive objects) despawns itself (like an opening door if you know what I mean). What do I need to do to set this up? Or is it even possible?
 
Nov 2, 2014
34
8
23
32
#7
Yo Buddha.

So I already posted this on the Forge Disc. thread, but it seems like nobody knows a solution to this. You seem to be much into scripting, so I thought I'd post this here and ask you:

I want to make it so if I shoot a garage door switch, a hard object (for example any type of block, decoratives, etc. | NO interactive objects) despawns itself (like an opening door if you know what I mean). What do I need to do to set this up? Or is it even possible?

Hey Buddy. Yeah, sure, this is possible.

Initially, the thing to be aware of with the Garage Door Switch is that it can only ever turn on a broadcast channel. On its own it cannot turn off, or toggle, a broadcast channel; and it's turning off a broadcast channel that we need to do, to despawn an object. Using the on-destroyed triggers, which can only turn on broadcast channels, as a way to also turn off and toggle channels is something I'm going to cover in my guide; I just haven't gotten around to it yet. Anyway, this is what you do:

So you basically want to turn on one broadcast channel, so that you can turn off another broadcast channel (to despawn the object).

Setup the garage door switch so that it will broadcast to a particular channel, let's say 0. Shooting this will then turn on that channel.

Setup a Timer: Off Once so that its power channel is the same as the one on your switch (e.g. 0). Then set that timer's broadcast channel to another channel, let's say 1. So now whenever broadcast channel 0 is turned on, broadcast channel 1 will turn off.

Go to your object you want to have despawn, and set its Spawn Time to Never, its Place at Start to False, and then set its spawn channel to that of the Timer (e.g. 1), and also its Can Despawn property to True. This will now make it so that whenever broadcast channel 1 is turned off, the object will despawn.

By default a broadcast channel is initially off at the start of a game, which would mean our object would already be despawned at the beginning. So what we finally need is a Timer: On Once, set to the same broadcast channel as the other timer (e.g 1). Don't give this a power channel - we want this to trigger at the beginning of the game, but do give it a timer delay of about 5 seconds (this will solve an issue where timers don't trigger at the beginning of a game for Non-Host players). So now, at the beginning of the game, broadcast channel 1 will be on, and our object will be spawned into the map.

And that's pretty much your basic setup: The object will be there at the start, but once you shoot the switch, it will despawn.

Now, if you left it like this then your garage door switch would be a one-time deal. Once you'd shot it and despawned the object, you wouldn't be able to bring it back in again, unless you setup some more timers. I don't know if you need it to "reset" so I won't go into detail about how you would do that unless you want me to, but the basic premise would be to somehow turn the switch's broadcast channel back off, and the timer's broadcast channel back on - this would put it back to its initial starting state.

Hope that helps!

Also, FYI guys, I've not given up on this guide. It's just taking me a while to get it all down. I've made my life harder by adding videos to the guide, which while I believe makes the guide more useful, and digestible, it does also mean that it's taking me a lot longer to finish (since I only have Upload Studio as a means to make these videos, and my internet is terrible). But I am still working on it!
 
Last edited:
Oct 2, 2013
11
0
6
24
#10
Hey there, so I've been experimenting A LOT with the new scripting system in forge. I've been trying to replicate logic systems (AND gates, inverted switches ect.) with little to no avail. I've primarily been using power channels and timers to manipulate broadcast channels. I've made a few basic systems this work, like a inverted switch and even "pausing" broadcast channels( picture a garage door stopping midway), although I can't figure out a way to get larger to work. Does anyone have any ideas?
 

Stevo

The Grinchmind
Dec 31, 2012
248
116
108
28
United Kingdom
#11
Hey there, so I've been experimenting A LOT with the new scripting system in forge. I've been trying to replicate logic systems (AND gates, inverted switches ect.) with little to no avail. I've primarily been using power channels and timers to manipulate broadcast channels. I've made a few basic systems this work, like a inverted switch and even "pausing" broadcast channels( picture a garage door stopping midway), although I can't figure out a way to get larger to work. Does anyone have any ideas?
Make a flowchart, bro.
Start with the user interaction, and what you want your end result to be, and then plan out the links in between. It's easier seeing everything in one place, and visible at the same time. You sometimes miss things looking in the properties of each scripting item individually.
 
Nov 2, 2014
34
8
23
32
#12
Hey there, so I've been experimenting A LOT with the new scripting system in forge. I've been trying to replicate logic systems (AND gates, inverted switches ect.) with little to no avail. I've primarily been using power channels and timers to manipulate broadcast channels. I've made a few basic systems this work, like a inverted switch and even "pausing" broadcast channels( picture a garage door stopping midway), although I can't figure out a way to get larger to work. Does anyone have any ideas?
If you're asking how to represent Logic Gates in Halo's Scripting then I can do that. I wasn't going to cover that in my guide until I'd done some other stuff first, but I can give you some of the basics now.

First, read this: http://www.electronics-tutorials.ws/boolean/bool_7.html. Unless you understand this, there's no point in continuing to read my post.

All caught up? Good. So what we want to do is represent these Logic Gate Functions in Halo's scripting. I'm going to stick with the 2-input functions as shown in the link. In all my examples, the inputs will be Switch: On broadcasters, and the output's True value representation will be opening a Garage Door, and the output's False value representation will be closing a Garage Door. Naturally you can switch out the inputs for any other Broadcaster with an "On" activation type, and the output for any other Listener and Forge Object that you want to have react to the True/False value. I'm just going to stick with the Switch and Garage Door for consistency.

Please be aware that some of these functions are going to be more complicated to represent than others.

Important Note: I'm not showing you how to script in reset behaviour on these logic gates, because frankly, it would take me way too long to write it all out; but the basic idea is to use De Morgan's Laws of negation to create the opposite logic gate, which instead of turning the end channel on, needs to turn it off. You can use a concept I call the "Smart Toggle" (It's the next thing I'm adding to the guide, I already have a video) to put both of these pieces of logic into one set of switches. To briefly explain just how much extra work would be involved: if I wanted to take the AND gate, and fully represent its logic using Off states as well as On states, then instead of the 1 Timer that I need to represent it using only On states, I would need to use 11 Timers to represent it for both On and Off states; so yeah, I'm not writing all that out. :p

2-input AND Gate
For the AND gate, we want to make it so that both switches have to be activated for the garage door to open.

1st Input - Switch: On - Broadcast Channel 0
2nd Input
- Switch: On - Broadcast Channel 1

Output - Garage Door - Broadcast Channel 2

Extra Scripting Logic
Timer: On Once - Spawn Channel 0, Can Despawn True, Power Channel 1, Broadcast Channel 2

The Timer: On Once here is making it so that both broadcast channels 0 and 1 have to be on for the timer to turn on broadcast channel 2 .
2-input OR (Inclusive OR) Gate
For the OR gate, we want to make it so that activating either switch opens the garage door.

1st Input - Switch: On - Broadcast Channel 0
2nd Input
- Switch: On - Broadcast Channel 1

Output - Garage Door - Broadcast Channel 2

Extra Scripting Logic
Timer: On Once - Power Channel 0, Broadcast Channel 2
Timer: On Once -
Power Channel 1, Broadcast Channel 2

Yes, we could just stick everything on the same broadcast channel, but I'm trying to replicate the logic here, so we need to treat each switch as its own input
NOT Gate
Unlike the other logic gates, this is actually only a single input gate, and its job is to basically flip the channel - so if the input's on then the output's off, and if the input's off then the output's on.

Now, the problem here is that while you can use a Timer to turn a channel off, based on another channel being on (via its power channel), you cannot however use a Timer to turn that channel on, based on the other channel being off.

Obviously we have normal Toggle broadcasters, and that's fine, but if you want a true NOT gate in Halo - essentially Inversion Logic - then you'll need to create a "Smart Toggle" - see this video for a full tutorial on how to do this. What you will then have is one broadcast channel always in the inverse state of the other broadcast channel - one channel is always the NOT of the other.
2-input NAND (Not AND) Gate
For the NAND gate, we want to make it so that the garage door is open, unless both switches are activated.

1st Input - Switch: On - Broadcast Channel 0
2nd Input
- Switch: On - Broadcast Channel 1

Output
- Garage Door - Broadcast Channel 2

Extra Scripting Logic
Timer: On Once - Broadcast Channel 2
Timer: Off Once
- Spawn Channel 0, Can Despawn True, Power Channel 1, Broadcast Channel 2

Similar to the AND gate, except we initially have the Garage Door open, and then we're triggering a Timer: Off Once from the two switches, instead of a Timer: On Once.
2-input NOR (Not OR) Gate
For the NOR gate, we want to make it so that the garage door is open, unless either switch is activated.

1st Input - Switch: On - Broadcast Channel 0
2nd Input
- Switch: On - Broadcast Channel 1

Output
- Garage Door - Broadcast Channel 2

Extra Scripting Logic
Timer: On Once - Broadcast Channel 2
Timer: Off Once
- Power Channel 0, Broadcast Channel 2
Timer: Off Once -
Power Channel 1, Broadcast Channel 2

Similar to the OR gate, except we initially have the Garage Door open, and then we're triggering Timer: Off Once's from the switches, instead of Timer: On Once's.
2-input EX-OR (Exclusive OR) Gate
For the EX-OR gate, we want to make it so that activating either switch opens the garage door, but then activating both of them closes the door.

1st Input - Switch: On - Broadcast Channel 0
2nd Input
- Switch: On - Broadcast Channel 1

Output
- Garage Door - Broadcast Channel 2

Extra Scripting Logic
Timer: On Once - Power Channel 0, Broadcast Channel 2
Timer: On Once -
Power Channel 1, Broadcast Channel 2
Timer: Off Once -
Spawn Channel 0, Can Despawn True, Power Channel 1, Broadcast Channel 2

What we have here is kind of a blend of the OR and NAND gates Timers.
2-input EX-NOR (Exclusive NOR) Gate
For the EX-NOR gate, we want to make it so that garage door is open unless either switch is activated, but then when both switches are activated, the door closes.

1st Input - Switch: On - Broadcast Channel 0
2nd Input
- Switch: On - Broadcast Channel 1

Output
- Garage Door - Broadcast Channel 2

Extra Scripting Logic
Timer: On Once - Broadcast Channel 2
Timer: Off Once
- Power Channel 0, Broadcast Channel 2
Timer: Off Once -
Power Channel 1, Broadcast Channel 2
Timer: ON Once
- Spawn Channel 0, Can Despawn True, Power Channel 1, Broadcast Channel 2

Very similar to the EX-OR, except we now have a Timer: On Once at the beginning, plus the other timers that were On's are now Off's and vice-versa.

And to finish up. For more advanced scripts, the idea is to combine these different logic gates together. See this link for an example of how you take an over all "idea" and then realise that you can break it up into its individual logic gates, and use one gate's output for another gate's input: http://www.electronics-tutorials.ws/boolean/bool_8.html.

In fact, to be honest, it's probably worth reading almost all the articles on that website if you're serious about creating advanced scripts.

Just so you realise that this isn't the whole picture though; as well as the logic functions themselves, you also need to be aware of other Scripting concepts, such as looping behaviour (iterating through logic on a loop), and reset behaviour (being able to reset your logic back to its starting state).

I've not shown it yet, but it's these kinds of concepts and ideas that allow me to create more complicated switches, such as a "Combination Lock Puzzle" switch (requires you to hit switches in a particular order to "open"), without needing to create more Timer's/Logic than is necessary; while also being highly configurable for any number of switches in the puzzle, plus any length of combination required to "open" the lock.
 
Last edited:
Dec 30, 2012
1,174
213
101
24
#16
Berb is looking to make a RNG system in scripting, any ideas of how he could do it Buddha?

Currently I'm thinking it would require the random spawning of an object, like a fusion coil with edited min/max settings falling down to set off a trigger - destroyed.
 
Nov 2, 2014
34
8
23
32
#17
Berb is looking to make a RNG system in scripting, any ideas of how he could do it Buddha?

Currently I'm thinking it would require the random spawning of an object, like a fusion coil with edited min/max settings falling down to set off a trigger - destroyed.
The thought of adding randomness into scripts has only ever briefly passed over my mind. Naturally you cannot really create true randomness, but there might be a way of adding enough "complexity" to the system that it would appear random to some degree.

I don't think the min/max settings trick with spawning objects, as a way of creating random behaviour, actually works in H2A. I'm sure I've had a number of people tell me that it no longer works, although I have not tested it myself.

You'll have to leave the thought with me, I'll mull it over and let you know if I come up with anything. It might help if you tell me what it is you want to be random, and how many elements should be a part of this random behaviour - like should 1 of 5 items spawn, 1 of 10 items, 3 of 20 items, how "random" are we talking?
 
Dec 30, 2012
1,174
213
101
24
#18
The thought of adding randomness into scripts has only ever briefly passed over my mind. Naturally you cannot really create true randomness, but there might be a way of adding enough "complexity" to the system that it would appear random to some degree.

I don't think the min/max settings trick with spawning objects, as a way of creating random behaviour, actually works in H2A. I'm sure I've had a number of people tell me that it no longer works, although I have not tested it myself.

You'll have to leave the thought with me, I'll mull it over and let you know if I come up with anything. It might help if you tell me what it is you want to be random, and how many elements should be a part of this random behaviour - like should 1 of 5 items spawn, 1 of 10 items, 3 of 20 items, how "random" are we talking?
Well I'm making a Slenderman map where people have to collect 5 pages in sequence. Currently I have a set sequence for testing purposes, but ideally I want a random sequence.

So it would be like this:

At the beginning of the round, a timer connected to a RNG (which can roll 1-5), will choose a spawn for the initial page. After it is collected, it will cycle again, choosing a new location from 1-4 (well, the first location being removed as a possibility). This will cycle until all 5 pages have been collected.
 
Nov 2, 2014
34
8
23
32
#19
Berb is looking to make a RNG system in scripting, any ideas of how he could do it Buddha?
OK, so it took me a little while, and a few failed attempts, but I finally got there.

Your best bet is to use teleporters, because they already incorporate randomness into their behaviour. The basic idea is to have a Sender Node, and then as many Receivers on the same channel as that Sender for the number of possible outcomes you want; so you said you wanted 1 of 5 possibilities, so that's 5 receivers.

Next, place On-Enter: On proxy triggers over each of the receivers, with each trigger set to a different broadcast channel. So whichever receiver you come out of, you will trigger a specific broadcast channel. You can then hook into those broadcast channels to handle the outcome.

To have this randomisation happen at the beginning of the game, just place 1 initial spawn point over that Sender Node, so that only one player activates the randomising mechanism, while everyone else just spawns into the map.

You may then went to have more teleporters to take the player out of your little randomising teleporters structure, and back into the map.

If you want to re-roll the randomisation during the game, then you just need a switch/trigger/whatever that can get a player teleported back into that randomising mechanism of teleporters.

Hope that helps!