This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Backup/restore object values with storage.set/get?
#3
Thanks, this is very helpful.

I am using an event script, sometimes it's called with value 'on' and sometimes 'off' - in this case, I assumed I'll need to store the backuplist in storage, is something like the below the correct approach?

Code:
backuplist = { '1/1/1', '1/1/2' }

-- save current values
values = {}
for _, addr in ipairs(backuplist) do
  values[ addr ] = grp.getvalue(addr)
end
storage.set('backuplist', values)
...

-- restore values
values = storage.get('backuplist')
for addr, value in pairs(values) do
  grp.write(addr, value)
end
Thank you!
Morkov
Reply


Messages In This Thread
RE: Backup/restore object values with storage.set/get? - by morkovka - 21.09.2021, 19:31

Forum Jump: