Page MenuHomeFeedback Tracker

Boolean "OR" or "||" is acting as "AND"
Closed, ResolvedPublic

Description

The boolean check "OR" or "||" is not working as it should. The "OR" check is working as an "AND" check in triggers. When using three triggers, trigger A and trigger B to check two different variables, and trigger C checks if either trigger A or B is true, trigger C won't activate until both A and B are true.

Details

Severity
Major
Resolution
Open
Reproducibility
Always
Operating System
Windows 10 x64
Category
General
Steps To Reproduce

Place three triggers. Place two units. In trigger A, set Activation as "!alive unit_1". In trigger B, set activation as "!alive unit_2". In triggers A and B, place different variables ("unit1Dead=true" and "unit2Dead=true"). In trigger C, set activation as "unit1Dead || unit2Dead". Trigger C won't activate until BOTH A and B are true.

Event Timeline

This isn't a problem with the OR operator. This is happening because the variables unit1Dead and unit2Dead aren't defined at all until you set them as true. Trigger C is attempting to reference at least one undefined variable - and silently failing - until both variables are defined as a result of their units dying. Then the trigger can actually run its check without encountering an error.

Repeat your test, but this time do unit1Dead = false; unit2Dead = false in the debug console before murdering one of the units. This will define the variables ahead of time, so the trigger can successfully run its check before both units are dead, and the trigger will activate when one of them is dead.

Well that is embarrassing. You are absolutely correct. I just don't remember having to set the variables to false in the past. I withdraw the submission.

dedmen closed this task as Resolved.Aug 18 2023, 11:00 AM
dedmen claimed this task.