Control output on world run/stop
This examples monitors the world state and controls an output based on the RUN
flag. If the world is in RUN
state the output is off, if the world is stopped the output is on, e.g. for controller a red lamp.
-- get the output to control
output = world.get_object('loconet_1').get_output(enum.output_channel.ACCESSORY, 1)
-- world event handler
function world_event(state)
-- check if the RUN flag is set in the world state
if world.state.contains(set.world_state.RUN) then
output.set_value(enum.output_pair_value.SECOND)
else
output.set_value(enum.output_pair_value.FIRST)
end
end
-- register the event handler
world.on_event(world_event)