28.01.2026, 09:25
Hi everyone!
I try to create a global variable, a table, so that several scripts insert new records. But everytime a script adds a new record, next time, I find the table empty.
In a library declare the tables (withouth the local modificator)
---------------------------------------------------------------
tablaknx = {}
devices = {
{ DIRETS = '1xx', VALOR = '17east' },
{ DIRETS = '2xx', VALOR = '27west' },
{ DIRETS = '3xx', VALOR = '37mid' }
}
---------------------------------------------------------------
The other scripsts would be like this:
function add_tablaknx(direts, nombre, valor)
log(tablaknx)
table.insert(tablaknx, {DIRETS = direts, NOMBRE = nombre, VALOR = valor})
table.insert(tablaknx, {DIRETS = direts, NOMBRE = nombre, VALOR = valor})
log(tablaknx)
return 1
end
function add_devices(direts, valor)
log(devices)
table.insert(devices, 1, 11111111111)
log(devices)
return 1
end
add_tablaknx('10/www0/0', 'fghqwrewehsg', 'twwwrue')
add_devices('10/www0/0', 'twwwrue')
It works, the register is added, but the next time it tries to add a new register the table it's empty.
Obviously I'm doing it the wrong way. It's possible to implement this with permanent changes? I don't want to use storage becouse the info in this table is going to change quickly and I don't want to destroy the SD Card
Thanks!!!
Kike
I try to create a global variable, a table, so that several scripts insert new records. But everytime a script adds a new record, next time, I find the table empty.
In a library declare the tables (withouth the local modificator)
---------------------------------------------------------------
tablaknx = {}
devices = {
{ DIRETS = '1xx', VALOR = '17east' },
{ DIRETS = '2xx', VALOR = '27west' },
{ DIRETS = '3xx', VALOR = '37mid' }
}
---------------------------------------------------------------
The other scripsts would be like this:
function add_tablaknx(direts, nombre, valor)
log(tablaknx)
table.insert(tablaknx, {DIRETS = direts, NOMBRE = nombre, VALOR = valor})
table.insert(tablaknx, {DIRETS = direts, NOMBRE = nombre, VALOR = valor})
log(tablaknx)
return 1
end
function add_devices(direts, valor)
log(devices)
table.insert(devices, 1, 11111111111)
log(devices)
return 1
end
add_tablaknx('10/www0/0', 'fghqwrewehsg', 'twwwrue')
add_devices('10/www0/0', 'twwwrue')
It works, the register is added, but the next time it tries to add a new register the table it's empty.
Obviously I'm doing it the wrong way. It's possible to implement this with permanent changes? I don't want to use storage becouse the info in this table is going to change quickly and I don't want to destroy the SD Card
Thanks!!!
Kike