“Tabele Lua” Kod odpowiedzi

Tabele Lua

local favoritefoods_table = {"hamburger", "spaghetti", "pizza", "potato chips"}
--the table--

for i, v in pairs(favoritefoods_table) do --loop through the table-- 
	print(i) --print the number--
  	print(v) --print the value--
end
Confused Cheetah

LUA Wydrukuj wszystkie elementy

local people = {
   {
       name = "Fred",
       address = "16 Long Street",
       phone = "123456"
   },
   {
       name = "Wilma",
       address = "16 Long Street",
       phone = "123456"
   },
   {
       name = "Barney",
       address = "17 Long Street",
       phone = "123457"
   }
}

for index, data in ipairs(people) do
    print(index)

    for key, value in pairs(data) do
        print('\t', key, value)
    end
end
Cook's Tree Boa

Jak zrobić stół w Lua

--You need to use this {} and put them in a varible
local Table = {13,"1hihihi",
-- u can even do tis
{122,222}}
Tense Turkey

Tabela lua

    a = {}
    x = "y"
    a[x] = 10                 -- put 10 in field "y"
    print(a[x])   --> 10      -- value of field "y"
    print(a.x)    --> nil     -- value of field "x" (undefined)
    print(a.y)    --> 10      -- value of field "y"
Famous Flamingo

Funkcje tabeli LUA

Note: [var] -> means var is optional 

table.concat(table, [separator], [start index], [end index (inclusive)])
	Concatenates the strings in the table based on the parameters given.
   	
table.insert(table, [pos], value)
	Inserts a value into the table at specified position.

table.remove(table, [pos])
	Removes the value from the table.

table.sort (table ,[comp])
	Sorts the table based on optional comparator argument.
Classy Answer

Odpowiedzi podobne do “Tabele Lua”

Pytania podobne do “Tabele Lua”

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu