Tagged Questions
5
votes
2answers
58 views
Lua hierarchy string to table
Is there a way that I can convert a hierarchy string into table form?
Suppose the input is A.B.C.D
ouput should be a table which traverses above input:
A = {}
A.B = {}
A.B.C = {}
A.B.C.D = {}
...
2
votes
1answer
48 views
Lua Table Memory?
This might be sort of a strange question, but curiosity got the best of me when I ended up getting a memory error after filling up a table with 14 million+ items.
Is there a sort-of set memory limit ...
2
votes
3answers
212 views
lua 5.2 changes the order of elements in the table
In lua 5.1 the code:
sums = {
["LD1"] = { },
["LD2"] = { },
["LD3"] = { },
["LD4"] = { },
["I1"] = { },
["I2"] = { },
["I3"] = { }
}
for fld = 1, 22, 1 do
...
0
votes
3answers
77 views
Is there a PHP foreach equivelent in Lua?
I have gotten used to programming in PHP with the foreach statement:
Is there an equivalent to this in Lua?
Thanks!
Relevant sections:
function renderobjects()
o1 = object:new{x = 30, y = 30, ...
1
vote
1answer
74 views
Convert formatted string to table of tables
In Lua, is there any way to split this string:
etc3=1336,etc2=14477,etc4=1335,etc1=1337
into this table?
tbl = {
{ 'etc3', 1336 },
{ 'etc2', 14477 },
{ 'etc4', 1335 },
{ 'etc1', ...
4
votes
1answer
70 views
Lua Metatable Inconsistency
I'm having trouble understanding why there is a difference in behavior of the __index metamethod between these to examples:
A = { __index = A }
function A:speak()
print("I'm an A")
end
An_A = ...
1
vote
1answer
97 views
Reading Lua nested tables in C++
I'm creating a C/C++ function which will be called from Lua. My function must call a library function who's signature is like this:
void libFunction( int val1, int val2, tSETTINGS * pSettings );
...
0
votes
2answers
79 views
Attempt to index global 'LM' (a nil value)
I am working on a some code in Lua and I keep getting this error although it is defined.
It is saying that 'LM' is a nil value when it's clearly not as LM = {} is the first thing I have in my code. I ...
-1
votes
4answers
47 views
Assign table to table in Lua
In Lua, I can add an entry inside table with table.insert(tableName, XYZ). Is there a way I can add already existing table into table? I mean a directly call rather then traversing and add it.
Thanks
-2
votes
1answer
43 views
Lua dont allow table append
I already have a lua-table A={}, A.B={} under global variable. I have a function on the call of what creates lua table D1={}, D1.D2={}, but the porblem is this function places the table in global ...
2
votes
2answers
63 views
Lua : Storing values in string array
I want to store some values for each string element in Lua array.
-- Emulating different Browsers
local user_agent = {
"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) ...
4
votes
4answers
61 views
How to prefix a Lua table?
I have a lua file whose content is lua Table as below:
A={},
A.B={},
A.B.C=0;,
The problem is I want to add prefix XYZ before each above statements. So after the parse the database should have ...
0
votes
1answer
34 views
bad argument #1 to 'pairs' (table expected, got nil)
So I'm trying to program a space invaders like game in lua using löve2d, the first wave of enemies runs smoothly but once i try adding another wave to the levelctrl table i get this error: bad ...
1
vote
3answers
43 views
Adding table as a EventListener
How can I add tables as a EventListener?
I'm working on a breakout game as a hello-world project and i would like to add the effect of "double ball". so basically i want to add balls to balls table ...
0
votes
1answer
34 views
Clearing a table in corona
I'm having problems with clearing the data in a LUA table. I use the Scene plugin and as soon as the player advances to the next scene, then I'd like to reset the data in a table.
I use this function ...