Forums / Games / Halo 5: Guardians

if/else function in Halo 5 Forge

OP CrimsonwolfDE

Hello fellow forgers,
I'm trying to build an armory at the moment and I'd like the weapon lockers to open as soon as someone enters the room. I've created a scriptbrain with a boundary about the size of the room. When a player is inside the boundary, the scriptbrain sets the power of a channel to ON, which opens the lockers.
Now the problem I've run into is, that there's now way (I know of) to set the power to OFF again as soon as there is no player inside the boundary. I could make it so the lockers open when a player enters the boundary and make them close as soon as a player exits the boundary. But If let's say there are two players in the room and one of them leaves, the lockers are supposed to stay open. Of course that wouldn't work with the Entry/Exit method.
When I set the 'Power set' function to TOGGLE the lockers open and close all the time when a player is inside the room. So that isn't working either.

What I need is a proper if/else function. It should look something like this:
If: Player is inside boundary
-> Set power to ON
Else: Set power to OFF

I have no idea how to imploment this in forge, any help (or alternative solutions) is (are) very much appreciated.
I'd recommend you to revise the script so that a pair of scripts keep count of how many players are inside the boundary. Then have two scripts checking this number:
One script checks if the variable is less than 1 and accordingly sets the channel power off.
Second script checks if the variable is greater than or equal to 1 and the accordingly sets the channel power on.

So
Script 1:
Boundary check: player enters
Number set: global, variable (your variable) operation: add, constant 1.
Script 2:
Boundary check: player exits
Number set: global, variable (your variable) operation: substract, constant 1.
Script 3:
Number check: variable (your variable), comparator: less than, constant 1
Power set: channel (your channel), off
Script 4:
Number check: variable (your variable), comparator: greater than or equal to, constant 1
Power set: channel (your channel), on

Now you have two scripts keeping count of the number of players inside the room and two scripts to react accordingly.
I'd recommend you to revise the script so that a pair of scripts keep count of how many players are inside the boundary. Then have two scripts checking this number:
One script checks if the variable is less than 1 and accordingly sets the channel power off.
Second script checks if the variable is greater than or equal to 1 and the accordingly sets the channel power on.

So
Script 1:
Boundary check: player enters
Number set: global, variable (your variable) operation: add, constant 1.
Script 2:
Boundary check: player exits
Number set: global, variable (your variable) operation: substract, constant 1.
Script 3:
Number check: variable (your variable), comparator: less than, constant 1
Power set: channel (your channel), off
Script 4:
Number check: variable (your variable), comparator: greater than or equal to, constant 1
Power set: channel (your channel), on

Now you have two scripts keeping count of the number of players inside the room and two scripts to react accordingly.
That's a great idea, thank you very much!