Questions tagged as 'lua-table'

1
answer

Order table by contained value

I want to sort this 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 the table by age. Something like: table.sor...
asked by 08.10.2014 / 07:54
1
answer

Loop 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 not explain very well, but what I'm trying to do is this: print(a.move..x) getting print(a.move1) and next print(a.move2...
asked by 02.11.2014 / 02:20
1
answer

Insert in an array between certain values

I have two values in the time format, 20:03:02 and 20:03:35 , which 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 = 33). I want to inser...
asked by 06.02.2015 / 23:23
1
answer

LUA, Separate string with numbers in a table!

I have a system to retrieve codes, 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 - numbers days - number there I ope...
asked by 10.03.2017 / 14:33
1
answer

Array 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 get the size of A, in this case, 2.     
asked by 21.09.2014 / 08:04
1
answer

List three-dimensional table

I have a table that I want to print all its values. Example: local table_2 = { ["tabela1"] = "360Mhz", "demo", "teste", ["tabela2"] = "360Mhz", "demo", "teste" } for k,v in pairs(table_2) do print(k,v) end How can I print the 4...
asked by 20.08.2015 / 12:16
2
answers

POO Tables on Moon!

I would like to know why you are 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 function TP:setNewPos(po...
asked by 30.05.2015 / 18:51
1
answer

Moon 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 it shows this: table: 0035AE18 My code: Conta = {balance = 0} Contas = {} Senhas = {} Ini...
asked by 26.01.2015 / 22:13
1
answer

How do you find the smallest 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: Values are random. I need to find the lowest value in the array, but the logic I've always used gives me a predictable result. Exam...
asked by 04.07.2016 / 04:44
2
answers

Erase repeated values

How could I do to delete repeated values in a table? Ex: a = {1,2,3,4,3,2,1} How would you erase 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, b=2}, } In this case, the la...
asked by 30.10.2014 / 17:06