30.08.2023, 07:51
(04.12.2015, 07:26)admin Wrote: Or you can make a script to save/recall values of all objects mapped to a certain tag. Map this script to a binary object, where ON saves tagged object values and OFF recalls saved values.Sorry, Can you tell me more about the above code? I don't understand how to apply it yet.
Code:value = event.getvalue()
-- save states
if value then
objects = grp.tag('my_object_tag')
store = {}
for _, object in ipairs(objects) do
store[ object.address ] = object.data
end
storage.set('my_objects', store)
-- restore states
else
store = storage.get('my_objects', {})
for addr, value in pairs(store) do
grp.write(addr, value)
end
end
Thanks!