Questions tagged [lua-table]

This tag refers to the table type in Lua that implements associative arrays.

The table type implements associative arrays. An associative array is an array that can be indexed not only with numbers, but also with strings or any other value of the language, except nil. Moreover, tables have no fixed size; you can add as many elements as you want to a table dynamically.

Tables in Lua are neither values nor variables; they are objects.

Creating table

t = {5, 10, 15, apple="red", banana="yellow" }

Short note about keys

Lua stores all elements in tables generically as key-value pairs. Lua does not differentiate between arrays and dictionaries. All Lua tables are actually dictionaries.

Note that keys are references to objects so you must use the same reference to get the same key into the table.

Useful Link

1403 questions
-3
votes
1 answer

I want treat `variable..'['..i..']'` as a indexing attempt

here my code blows up: love.graphics.print(jugador..'['..i..']', i * 100, 10) I tried 'jugador'..'['..i..']' so i want help to get this jugador[1], jugador[2], jugador[n] treated a an indexing attempt not a text or something else...
-3
votes
1 answer

Lua's Table Equivalent In Python

Is there a python table equivalent to lua's? -- Lua's Table a = {} a.x = 10 a.y = 10 print(a.x) print(a.y) -- OUTPUT 10 10
flawy
  • 57
  • 8
-3
votes
1 answer

facing issue in lua code

How can I match "words" mixed parenthesis delimited strings, on the basis that they are separated by whitespaces. EG: split_words_and_parenthesis("1791 (AR6K Async) S 2 ") --> {"1791","AR6K Async","S","2"} Here's my attempt: str = "1791 (AR6K…
-3
votes
2 answers

Text File to Lua Array Table

I need to transfer a text from a text file/string to a Table with a 2 positions vector. Like this: Text File: Gustavo 20 Danilo 20 Dimas 40 Table Names = {{Gustavo,20},{Danilo,20},{Dimas,40}} Need help to do this.
-3
votes
1 answer

Why doesn't this code function?

local data={} eventNewPlayer=function(n) data[n]={tab="none"} end function eventChatCommand(n,c) if c == "foo" then data[n].tab = c if data[n].tab == c then ui.removeTextArea(90,n) else …
-3
votes
2 answers

How do I serialize a table for insertion into a database?

I would like to serialize a table so that I can insert it into a database and retrieve it later on. How would I do this?
Tom F
  • 807
  • 6
  • 20
-4
votes
1 answer

Character creation program in LUA

I have an assignment that requires me to create a simple character design program that takes in five characteristics and stores them. At the end of the character creation the program needs to ask if the user wants to view, edit, or create a…
-4
votes
1 answer

Table elements executing a function

I have this table: maps = {4707191, 4747722, 1702169, 3994471, 4708958, 4008546, 4323335, 4516043, 4612295, 3469987, 4337892, 238378, 3088188, 329627, 3526384, 433483} How can I make a script so if 1702169 (for example) is picked from the table, it…
Gelu
  • 121
  • 1
  • 2
  • 9
1 2 3
93
94