Hi guys!
I'm working on connecting LogicMachine with more devices via TCP. I need to store IP addresses of connected devices in LogicMachine database. First time I tried to store data to Lua table, but data removes after script ends.
The question is, how can I automatically add IP address of new connected device to Lua database?
I tried something like this with Lua tables:
So I need to make this thing with storage.set and insert new IP address to this DB. Can someone help me how to do it?
Thank you for every response
I'm working on connecting LogicMachine with more devices via TCP. I need to store IP addresses of connected devices in LogicMachine database. First time I tried to store data to Lua table, but data removes after script ends.
The question is, how can I automatically add IP address of new connected device to Lua database?
I tried something like this with Lua tables:
Code:
t = {}
id = string.format('%s:%d', ip, port)
me = string.find(id, ":", 1);
ipcut = string.sub(id, 1,me-1)
count = 0
for index, value in ipairs (t) do
if value == ipcut then
count = count + 1;
alert("IP in table just exists: %d -> %s ", index, t[index]);
end
end
if count == 0 then
table.insert(t, ipcut)
end
So I need to make this thing with storage.set and insert new IP address to this DB. Can someone help me how to do it?
Thank you for every response