Can you use an array in a plugin and can it be adressed as an normal array
i would like to have something like this


for x = 1 to 24 step 1
value (x) = 100 + x
next x

and can i use luup.variable_set to save the array

thanks in advance

An array in Lua is called a Table. The syntax is different, but the principal is the same.

Note that [tt]luup.variable_set(…)[/tt] needs a String, not a Table, so you’ll need to write code to convert back-n-forth (serialize/deserialize) between the Table form and the String form when using Vera/Luup for persistence.

Can you be so kind to give me an example


The syntax examples are in the link above. Beyond that, Tables are used extensively in nearly all of the plugins on

Between the two, you should be set for examples.

can you give me a idea to look for

I have a array DailyLow{} with i want to save in to DailyLow

If an change has been in DailyLow[21] i want to update DailyLow

If the veralite reboots it must upload the data back from DailyLow

Can you advice how to procerd
I have tried table.concat but invain


You’ll want to break the problem up into smaller pieces that you can experiment with, and then piece back together.

The key pieces are:
a) A function that takes a Table parameter, and returns a String.
The key Lua functions here are [tt]pairs()[/tt] and the string concatenation operation “[tt]…[/tt]”

To test this, you can pass in a table value like:
[tt] local testTableData = {“first value”, “second value”, “third value”}[/tt]

b) A function that takes a String parameter, parses it, and returns a Table.
The key Lua functions here are [tt]string.match[/tt], or maybe [tt]string.gmatch[/tt]

To test this, you can pass in a string value like:
[tt] local testStringData = “first value, second value, third value”[/tt]

Once you have those, you’ll be set. There’s TONs of code on that does this stuff, you’ll need to roll up your sleeves to experiment with it.

If you need extra examples, checkout the Tutorials over at:
lua-users wiki: Tutorial Directory

Develop the above components using the command line Lua, it’ll save you all the restarts that you’d have to develop it under Vera. Command line Lua’s are available for All platforms… and Google will help you find examples of ALL of this as well.

I have got it working

You’ll want to post your results. In turn, this will help others when they need to do something similar…