
So it's a bug that's being exploited to store custom strings. It also suggests that predefined variables are for storing words (strings) but are supposed to "limit the content of the variables" to a value in the drop down box. site does suggest standard (global) variables are for storing numbers. Please login or register to see this link.

What I have found that, the global variables are good for numbers and predefined variable work excellent with strings. Please login or register to see this code. Please login or register to see this image.
#Lua table insert table code
I want it to be populated with each month and the value.Īlso, the scene is started multiple times per day so the code should check if that month is already in the array and if it is just rewrite the value, otherwise insert the month and the value in the array. The problem is that every time the scene restarts the array will be empty again. Storing the data is the problem: I'd like to store the data in an array like above. The scene has as trigger the UBS value that reads the meter - every time the UBS is 1 it increments the global variable by 0.1 I've got the code that reads the meter and increments the global variable by 0.1 sorted out. The number after the equal sign is taken from a global variable that changes as a water meter runs every 100 liters. emoticons/default_smile.png" alt=":)" srcset=" 2x" width="20" height="20" />īasically what i'm trying to achieve is store some values in an array like array =. Table.I have a problem with a piece of LUA code and i'd like to ask for help from the LUA gurus

Now let’s make use of the insert function that takes three arguments, the third argument (or actually the second one) is the position(index), where we want to insert our element. Now when we iterate over the array using the generic for we should see all the values printing to the terminal. In the above example, I am calling the insert function three times to insert values 11, 12 and 13 into our array. Nothing fancy is happening in the above code, now let’s say we want to insert an element into the above array, the approach is to make use of the insert function that Lua library provides us. Consider the example shown below −įor i,v in ipairs(a) do print(v) end Output 1 Let’s consider a simple example where we are printing all the values present in an array. In the above example, the x represents the table identifier, the pos represents the position at which we want to insert the element at, and lastly the element denotes the value that we want to insert. Let’s explore different examples of the insert function. If there are three arguments passed to the insert function then the second argument denotes the position in the table where we want to insert the element at. The insert function usually takes two arguments, the first argument is usually the name of the table from which we want to insert the element to, and the second argument is the element that we want to insert. In Lua, the table library provides functions to insert elements into the table.

There are cases when we want to insert elements into a table.
