Hi,
Lua scipting just got more powerful!
Some objects have events like on_value_changed or on_aspect_changed, this is very useful for building scripts, but also limited as it is only possible to act on changes for events that existed.
Traintastic now supports the on_changed on every object! With a single line of Lua it is now possible to act on the changes of one, multiple of all properties of an object ![]()
A few examples:
-- Single property:
signal.on_changed("aspect", function(aspect)
log.debug("Signal aspect: ", aspect)
end)
-- Multiple properties:
turnout.on_changed({"position", "reserved_position"}, function(value, object, name)
log.debug(object.name, name, value)
end)
-- All properties:
block.on_changed(function(value, object, name)
log.debug(object.name, name, value)
end)
See the Lua events manual page for more detailed information.
Happy hacking!
Reinder