Skip to main content

calc_state

calc_state icon
Point entityPorted from Featureful

A calc_state combines the states of two masters with a logic operation such as AND or OR. It is a master itself, and it is on while the result is true.

Every time an entity checks whether its Master lets it work, a calc_state it names checks both of its operands again at that moment. When you trigger the calc_state, it also works out the result and fires its targets.

Attributes​

KeyDescriptionDefault
Nametargetname

Sets the name you put in another entity's Master key, and triggering the entity by this name works out the result and fires its targets. See Common keys.

Operand 1left_operand

Names the first master, such as an env_state, a multisource or another calc_state. With !activator, *locus or *player, it uses the entity that started the chain of triggers. A ~ in front of the name doesn't turn the state around, so use NAND or NOR for that.

If you leave this key empty, the entity has no result.

Operand 2right_operand

Names the second master, in the same way as Operand 1.

If you leave this key empty, the entity has no result.

Operationoperation

Picks how the two states give the result.

  • AND (0) - True when both operands are on
  • OR (1) - True when at least one operand is on
  • NAND (2) - True unless both operands are on
  • NOR (3) - True when both operands are off
  • XOR (4) - True when one operand is on and the other is off
  • NXOR (5) - True when both operands are on or both are off
Default AND (0)
Operand 1 missingleft_fallback

Sets what counts as the state of Operand 1 when no entity has that name.

  • Treat as error (0) - There is no result, so the master is off and the entity fires nothing
  • Treat as Off (1) - The operand counts as off
  • Treat as On (2) - The operand counts as on
Default Treat as error (0)
Operand 2 missingright_fallback

Sets what counts as the state of Operand 2 when no entity has that name.

  • Treat as error (0) - There is no result, so the master is off and the entity fires nothing
  • Treat as Off (1) - The operand counts as off
  • Treat as On (2) - The operand counts as on
Default Treat as error (0)
Target when triggeredtarget

Names the entities to trigger when you trigger the entity, with the use type On if the result is true and with Off if it is false.

Fire when falsefire_when_false

Names the entities to trigger when you trigger the entity and the result is false.

Fire when truefire_when_true

Names the entities to trigger when you trigger the entity and the result is true.

Flags​

2Debug Mode

When you trigger the entity, the console shows the state of each operand and the result, if developer 1 is set in the console

Notes​

  • An operand that names an entity which isn't a master counts as on
  • If the entity has no result, the master is off and the entity fires none of its targets, and with developer 1 set in the console, the console reports why
  • If calc_state entities use each other as operands in a loop, the check stops after 32 steps and the result is false, and with developer 1 set in the console, the console reports it

See also​

Changes since 1.38​

  • calc_state is new in SBO 2.0.0