lua-table Questions

1

Solved

Excerpt from Lua 5.3 manual: _G A global variable (not a function) that holds the global environment (see §2.2). Lua itself does not use this variable; changing its value does not affect any envir...
Amp asked 10/3, 2016 at 7:24

2

Solved

I came across tables that have square brackets around keys: local commands_json = { ["request"] = { ["application"] = PW_APPLICATION, ["push_token"] = deviceToken ...
Preadamite asked 8/1, 2016 at 22:58

1

I need to use Redis HMGET from a Lua script and extract specific values in following code. But redis.call('HMGET', table_key, hkey1, hkey2, ...) return a flat array of {hkey1, val1, hkey2, val2, .....
Kinata asked 16/12, 2015 at 13:41

1

Solved

I'm not sure how, but we managed to create a table with two keys exactly same. When performing for loop over pairs of the table and printing keys and values we get: 1 true 1 true and we thought ...
Decurion asked 3/12, 2015 at 9:55

3

Solved

I have this array, with some values (int) and I want to check if a value given by the user is equal to a value in that string. If it is, output a message like "Got your string". Example of the lis...
Unstrap asked 3/11, 2015 at 23:2

2

Solved

I'm learning Lua to build scripts for a flight simulator. I have a CSV file that appear like this: Poti city, Poti,red,-295731.42857144,617222.85714285 Lanchhuti city, Poti,red,-299217.14285715,...
Mackenie asked 17/1, 2014 at 1:41

2

I've been trying to find a way to remove a string from a table kind of like this: myTable = {'string1', 'string2'} table.remove(myTable, 'string1') but I haven't been able to find anyway to do i...
Vagary asked 27/9, 2015 at 5:40

2

Solved

Is there a shorter way to do this: local thisismytable = { non = sequitur } thisismytable.whatismytable = thisismytable Any help would be appreciated. I don't want to re-create pre-existing fun...
Try asked 12/9, 2015 at 14:0

2

Solved

Could somebody explain to me why table.unpack() returns the first table element only when it is used in a function call with additional parameters after table.unpack()? Here is some demo cod...
Munitions asked 7/9, 2015 at 13:16

2

Solved

Is there any way to loop trough a table like the one below in the same order as it's written? local tbl = { ["hello"] = 1, [2] = 2, [50] = 3, ["bye"] = 4, [200] = 5 } What I mean is that wh...
Unamuno asked 21/6, 2015 at 22:40

6

I need to check if a member exists in a table that isn't at the next level, but along a path of members. foo = {} if foo.bar.joe then print(foo.bar.joe) end this will cast an attempt to index f...
Redouble asked 7/6, 2015 at 1:31

2

Solved

How does lua handle a table's growth? Is it equivalent to the ArrayList in Java? I.e. one that needs continuous memory space, and as it grows bigger than the already allocated space, the internal ...
Bondon asked 28/4, 2015 at 19:37

1

Solved

I'm trying to iterate over a table of tables in Lua and output: The key of each table. The key / value pair of each entry in each table. Here is the code: void print_table(lua_State *L) { lua...
Xanthous asked 26/3, 2015 at 20:16

2

Solved

I'm aware of the weak tables functionality in Lua, however I would like to have a weak reference with a single variable. I've seen this proposal which suggests an API as follows: -- creation ref ...
Louvain asked 17/3, 2015 at 21:6

3

Solved

I want to create a table like myTable = { [0] = { ["a"] = 4, ["b"] = 2 }, [1] = { ["a"] = 13, ["b"] = 37 } } using the C API? My current approach is lua_createtable(L, 0, 2); int c = lua_get...
Adenoidal asked 27/10, 2009 at 11:24

4

Example: table1 = {2,3,1} table2 = {a,b,c} to table1 = {1,2,3} table2 = {c,a,b}
Velate asked 10/2, 2015 at 22:26

3

Solved

I would want to sort a table alphabetically. Except numbers. The code below shows how the table is sorted with comparator function: function( a,b ) return a.N < b.N end Gives me: obj = { ...
Nibelungenlied asked 12/1, 2015 at 19:59

2

Solved

How can I split a Lua table containing few sub-tables into two tables without changing the original table. e.g. split tbl = {{tbl1}, {tbl2}, {tbl3}, {tbl4}} into subtbl1 = {{tbl1}, {tbl2}}, subtbl...
Fortdefrance asked 9/1, 2015 at 16:42

3

Solved

I'm wondering if anyone can confirm whether you can trust ipairs() to; return all indices in order, for a table that's index-complete but unsorted. We have code all over our project that clones ta...
Babita asked 18/12, 2014 at 14:55

3

Solved

I'm trying to figure out the equivalent of: foo = [] foo << "bar" foo << "baz" I don't want to have to come up with an incrementing index. Is there an easy way to do this?
Weekday asked 11/12, 2014 at 23:10

2

Solved

If I have a list (table): local list = {'foo', 'bar', 'baz', 'qux'} How do I get the n-th item from the end? (e.g., the last or second to last)
Satin asked 11/12, 2014 at 19:59

1

Solved

below is the lua table i need to read from C: listen = { { port = 1234, address = "192.168.1.1", userdata = "liunx" }, { port = 1235, address = "192.168.1.2", userdata = "liunx1" }, { port = 12...
Bobbette asked 20/11, 2014 at 10:56

1

In Lua, I know there is table.remove(array, index) Is there a fast way to remove and return X elements from the array (without just repeated calls to table.remove)?
Ratiocinate asked 17/11, 2014 at 3:45

2

I have a project that calls for a relational database like structure in an environment where an actual database isn't possible. The language is restricted to Lua, which is far from being my stronge...
Pineapple asked 14/11, 2014 at 21:29

2

Solved

How can I get a size of a Lua table in C? static int lstage_build_polling_table (lua_State * L) { lua_settop(L, 1); luaL_checktype(L, 1, LUA_TTABLE); lua_objlen(L,1); int len = lua_tointeger(L...
Dunaway asked 30/10, 2014 at 0:57

© 2022 - 2024 — McMap. All rights reserved.