Skip to content

Commit

Permalink
Add safeguards so comp_relays still run if ctrl_type or value is miss…
Browse files Browse the repository at this point in the history
…ing.

This fixes BEEmod/BEE2-items#4044.
  • Loading branch information
TeamSpen210 committed Jan 13, 2022
1 parent 321da89 commit 1010744
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion transforms/comp_relay.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,18 @@ def comp_relay(ctx: Context):
)
# If ctrl_type is 0, ctrl_value needs to be 1 to be enabled.
# If ctrl_type is 1, ctrl_value needs to be 0 to be enabled.
enabled = conv_bool(relay['ctrl_type']) != conv_bool(relay['ctrl_value'])
if 'ctrl_type' in relay:
enabled = conv_bool(relay['ctrl_type'], False) != conv_bool(relay['ctrl_value'], True)
else:
# Missing, assume true if ctrl_value also isn't present.
enabled = conv_bool(relay['ctrl_value'], True)

extra_delay = conv_float(relay['delay'])

LOGGER.debug(
'relay "{}", enabled={}, delay={}, remove={}, {} outputs',
relay_name, enabled, extra_delay, should_remove, len(relay.outputs),
)
for out in relay.outputs:
try:
inp_name = out_names[out.output.casefold()]
Expand Down

0 comments on commit 1010744

Please sign in to comment.