lua-table Questions

1

Solved

I'm trying to pass a Lua table to my C program but I don´t know how to do it. My Lua code: local stages = {} stages[1] = stage1 stages[2] = stage2 stages[3] = stage3 lstage.buildpollingtable(sta...
Jillayne asked 29/10, 2014 at 1:19

1

Solved

I have a question about accessing data in a Lua table. Say, there is a large Lua table like following: tbl = { { blockIdx = 5, key1 = "val1", key2 = "val2", ... }, { blockIdx = 30, key1 ...
Bridgework asked 24/4, 2014 at 2:11

1

Solved

Today i was working some with lua,with that "oldesh" for me language,and did find what you can get arguments as array,like soo: function foo(someting,...) local arrayofargs = arg -- code here en...
Dustindustman asked 10/3, 2014 at 18:21

1

Solved

I'm using the Redis client from ServiceStack. I have a Lua script that fills up a Lua table with results from several Redis calls. I want to return this table in some way. My thought was to use the...
Breadthways asked 9/3, 2014 at 19:55

4

Solved

I'm trying to think of an easy way to make all elements in a table shift up one. It is for a game I am playing, attempting to switch between all targets in a table! For example, let's say I'm surr...
Linnlinnaeus asked 4/3, 2014 at 23:50

3

Solved

Why isn't t:insert(9) working in Lua? (I want to append a value of 9 to the end of the table) t = {1,2,3} table.insert(t, 9) -- works (appends 9 to end of table t) t:insert(9) -- does NOT work I...
Friction asked 25/5, 2011 at 15:27

3

I'm trying to load tables from Lua to C++ but I'm having trouble getting it right. I'm getting through the first iteration just fine but then at the second call to lua_next it crashes. Any ideas? ...
Wellworn asked 17/9, 2009 at 13:18

1

Solved

I have a table: Table = { button = {}, window = {}, label = {}, edit = {}, error = {} } How I can get keys and values of the table? I tried to get as: for key, value in ipairs(Table) do ...
Mitra asked 20/1, 2014 at 5:26

3

I have the below program code which tries to sort a given list. I have tried various options and it still doesn`t work. local List = {} List[143] = "143" List[145] = "145" List[120] = "120" L...
Roguery asked 14/1, 2014 at 14:5

4

Solved

I want to convert string text to table and this text must be divided on characters. Every character must be in separate value of table, for example: a="text" --converting string (a) to table (b) ...
Gaffe asked 6/12, 2013 at 12:2

1

Solved

I have a memory leak issue about the usage of lua table, the code is below: function workerProc() -- a table holds some objects (userdata, the __gc is implememted correctly) local objs = {create...
Justus asked 22/11, 2013 at 7:27

2

Solved

I'm wondering how I you can create and register a function from the C++-side that returns a table when called from the Lua-side. I've tried a lot of things but nothing did really work. :/ (sorry ...
Valtin asked 7/11, 2013 at 2:15

2

Solved

I am new to lua, I have a table foo and I want to convert it to bar like following: foo:{key1,value2,key2,value2} ==> bar:{key1=value1,key2=value2} Does lua have a built-in method to do that ...
Nagual asked 12/11, 2013 at 7:5

2

Solved

I want to get the most frequent k-sized substring in a string. To achieve this, I'm using a table to store the number of occurrences for each substring. Here's the code: function frequentWords(seq...
Marylnmarylou asked 5/11, 2013 at 11:10

2

Solved

Here is a Lua 5.2.2 transcript, showing the declaration and indexing of a table: > mylist = {'foo', 'bar'} > print(mylist[1]) foo Why isn't the following statement legal? > print({'foo...
Harry asked 12/10, 2013 at 6:25

3

I am learning Lua from a book, and I am NOT a programmer. I am trying to save a table of data to a file using the following functions (that were copied directly from the book), but the function is ...
Tuchman asked 10/10, 2013 at 19:53

3

Here's an example local query = {} query['count'] = 1 query['query'] = 2 for k,v in pairs(query) do print(k) end The above will print first query then count. How can I make sure without adding...
Darrin asked 8/10, 2013 at 23:37

2

Solved

I have a new question for you all. I am wondering if you're able to do enumerations within Lua (I am not sure if this is the correct name for it). The best way I can explain this is if I show you a...
Mraz asked 24/9, 2013 at 11:57

1

Solved

I am making a game using Lua and I need to use Breadth-first search to implement a fast path-finding algorithm which finds the shortest path between the enemy AI and the player. I will have up to...
Xeric asked 17/9, 2013 at 7:18

3

Solved

Suppose I am inserting a string into a table as follows: table.insert(tbl, mystring) and that mystring is generated by replacing all occurrences of "a" with "b" in input: mystring = string.gsub...
Hourigan asked 24/4, 2010 at 14:22

2

I'm going to implement a function with C language and which will be called by Lua script. This function should receive a lua table(which even contains an array) as the argument, so I should read t...
Restore asked 5/9, 2013 at 13:11

1

Solved

I'm going to implement a function with C language and which will be called by Lua script. This function should receive a lua table as the argument, so I should read the fields in the table.I try t...
Curnin asked 28/8, 2013 at 2:19

1

Solved

Lua has the # operator to compute the "length" of a table being used as an array. In a language such as C, after you've computed the length of something, you typically don't compute it again. e.g. ...
Pennate asked 13/8, 2013 at 4:50

2

Solved

I'm curious what algorithm Lua's default table.sort uses, only because it's slower than some other sorting algorithms I've come across. I'm also curious if Lua's table.sort is written in the Engine...
Narcolepsy asked 4/8, 2013 at 14:8

2

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 = {} T...
Endgame asked 11/7, 2013 at 5:27

© 2022 - 2024 — McMap. All rights reserved.