Most voted "lua-table" questions
25 questions
Sort by count of
-
7
votes1
answer125
viewsLoop with array + string
I’m trying to do something like: a = {move1="oi", move2="oi2"} for x=1, #a do print(a.move..x) end I can’t explain it very well, but what I’m trying to do is this: print(a.move..x) getting…
-
6
votes1
answer206
viewsSort table by contained value
I want to sort such a table by a value contained in it. Ex: tabela = { {pessoa="Joao", idade=20}, {pessoa="Pedro", idade=22}, {pessoa="Lucas", idade=19}, {pessoa="Derp", idade=25} } I want to sort…
-
6
votes1
answer263
viewsInsert into an array between certain values
I have two values in time format, 20:03:02 and 20:03:35, who are in a array in Lua. hora_array={"20:03:02", "20:03:35"} The difference between the two values is 33 seconds (20:03:02 - 20:03:35 =…
-
5
votes1
answer680
viewsLua print(table) in string (taking all its values)
I created a system quickly to test a new variable, but I do not know how to print the users inserted in the table, and when I give print he shows it: table: 0035AE18 My code: Conta = {balance = 0}…
-
5
votes1
answer525
viewsLUA, Separate string with numbers in a table!
I have a code rescue system, in case I would put something like this in a text file: HFGD65,{2454,2454},1,1 would be: CODE to redeem -- string {items} -- items within the table in numbers points --…
-
4
votes1
answer946
viewsArray size
How do I get the size of an array with this structure: A = { ["b"] = {c=1, d=2}, ["e"] = {f=1, g=2}, } I want to take the size of A, in this case, 2.
-
4
votes2
answers729
viewsPOO tables in Lua!
I wonder why it is not returning a table in the code I made: TP = {} function TP:new(pos, newpos, effect) return setmetatable({pos = pos, newpos = newpos, effect = effect}, { __index = self }) end…
-
4
votes1
answer291
viewsHow to list variables within a table in Lua?
For example: minion = { hp = 1000, x = 10, y = 25 } Is there a function I can know how many variables there are within this table?
-
4
votes1
answer105
viewsList three-dimensional table
I have a table that I intend to print out all your values. Example: local table_2 = { ["tabela1"] = "360Mhz", "demo", "teste", ["tabela2"] = "360Mhz", "demo", "teste" } for k,v in pairs(table_2) do…
-
4
votes1
answer111
viewsHow to iterate with a table in Lua?
How to iterate with a table in Lua? Example: dados = { nome = 'Wallace', idade = 25 }
-
4
votes1
answer458
viewsHow to find the lowest value of a moon matrix?
I made this code that makes an Array (at least I think it’s doing) and then writes all the values in it. Obs: The values are random. I need to find the lowest matrix value, but the logic I’ve always…
-
4
votes2
answers341
viewsWhat would be the correct way to verify if a value exists in the table in Lua?
if not name in Namez do table.insert(Namez,name) end What would be the correct way to check if a name is not in the table?
-
3
votes1
answer82
viewsString (g)Match
Well, I’m looking to turn a string into a table. I tried so: toset = "nb = 10, gb = 20, sb = 0, sfb = 0, ub = 0;" toget = "nb = (.-), gb = (.-), sb = (.-), sfb = (.-), ub = (.-);" t =…
-
3
votes2
answers190
viewsDelete repeated values
How could I delete repeated values in a table? Ex: a = {1,2,3,4,3,2,1} How would you delete 3, 2 and 1, keeping only one of each? My table is one inside another: a = { {a=1, b=2}, {a=2, b=3}, {a=1,…
-
3
votes1
answer75
viewsReferencing a table through a string in Lua
I need to use a table in Lua, but I can only reference it through a string, example: tabelaA = { "qualquer coisa" } variavelA = "tabelaA" print(variavelA) resultado: "qualquer coisa" Bearing in mind…
-
3
votes1
answer111
viewsCreate reading of a bool function in lua
Well I’m learning moon and I’m having a doubt, I’m trying to create the reading of a bool function on moon. I have a function that disables or activates as I mark true or false. This function is…
-
2
votes1
answer190
viewsRead table in Lua through C++
I have a table in Lua this way: myTable={ one = {a=1, b=2, c=3}, two = {a=4, b=2, c=1} } The file has already been uploaded, as I do to read the table data through C++?…
-
2
votes0
answers73
viewstable change to your call in . moon?
have this table below tabela = { ["Maquina"] = { {name = "susu", level = 600}, {name = "camel", level = 600}, {name = "juju", level = 600}, }, ["bruno"] = { {name = "fada", level = 600}, {name =…
-
2
votes1
answer166
viewsConvert String to Tables
local items = {} local t = "7 2182, 4 2554, 5 9908" I wanted to convert using this string and let the table come out like this: local items = {{7,2182},{4,2554},{5,9908}} is there any way? using…
-
1
votes1
answer133
viewsPick Table in string form
I’m trying to get a string table. EX: tabela = {1, b=2, {c=3}} print(getTableString(tabela)) If this function existed, and functioned, it would return: -> tabela = {1, b=2, {c=3}} Is there any…
-
1
votes0
answers52
viewsMultidimensional Array in Lua
I’m trying to insert an array within a multidimensional... Example: local info = { [1] = {name = Felipe, idade = 21, rua = Alvorada}, [2] = {name = Carlos, idade = 23, rua = Lima}, [3] = {name =…
lua-tableasked 6 years, 2 months ago Flávio Carlos 17 -
1
votes1
answer66
viewsHow to decrease processing on the moon? or Muti hash?
I have a table with several 5 position Tables where the first two are the position in a Cartesian plane. --Table with water collors colors =…
-
1
votes0
answers38
viewsReferencing specific values in an array . lua
In that case I created a math.random with the values from 1 to 2 that will lead me to a coordinate of a specific delivery. I created a table with the corresponding values. But since then I can’t get…
-
0
votes0
answers337
viewsVector ordering
I’m learning about vectors and matrices, and I haven’t been able to solve a question in the right way for a long time. The statement says: Given some vector, sort it in sequential (numerical).…
-
0
votes1
answer29
viewsLua / Love2d: Error when trying to give require.Tree("code") : Attempt to index global 'require' (a Function value)
Error when trying to give require.Tree("code") : Attempt to index global 'require' (a Function value) function love.load() lib = require.tree("code") end being code a folder with files . moon inside…