Questions tagged as 'lua'

1
answer

Run code in the Lua language

I downloaded the Lua interpreter, I created a hello.lua file with the following code: print("Hello World") But I can not compile this code and display the output. I downloaded version 5.3.3 and executed the file lua.exe , the c...
asked by 13.11.2016 / 20:49
1
answer

Get array name inside array

Well, what I want is this: get the name of an array inside another array, just the name. EX: local a = { ["oi"] = {sim=1, nao=2}, ["tchau"] = {sim=2, nao=1} } local falas = {} table.insert(falas, a) - I would add the "hi" and "bye" values...
asked by 21.08.2014 / 11:29
1
answer

String (g) Match

Well, I'm trying to transform a string into a table. I tried this way: toset = "nb = 10, gb = 20, sb = 0, sfb = 0, ub = 0;" toget = "nb = (.-), gb = (.-), sb = (.-), sfb = (.-), ub = (.-);" t = toset:gmatch(toget) for a,b,c,d,e in pairs(t) do...
asked by 22.09.2014 / 00:57
2
answers

Separate the bytes that form an integer?

Assuming I have this positive number: local uint = 2000; How can I get the bytes that compose it separately? For example: print(sepbytes(uint)); -- 7, 208 My attempt: local function sepbytes(cur) local t = {}; repeat cur =...
asked by 05.01.2017 / 19:10
2
answers

Scroll through LUA tables

I have two tables created in LUA. I want to go through if there is an equal value between the two. Something like this. table1={5,10,30,40,50,60,40} table2={10,30,40} for i=1,#table1 do if table1[i]==table2[i] then print("valor igual")...
asked by 05.06.2015 / 01:06
1
answer

How to list the variables inside a table in Lua?

For example: minion = { hp = 1000, x = 10, y = 25 } Is there any function that I can know how many variables exist within this table?     
asked by 08.08.2015 / 13:15
1
answer

How to replace certain letters in a sentence?

I want to replace these letters: local words = {"v", "s ", "#@#", "s", "รง", "b", "mp", "t"} When they were in a sentence they would be replaced, or it could be a table like that too: local words = { ["v"] = "d", ["s"] = "k" } Ass...
asked by 29.05.2015 / 13:16
2
answers

Can you create variables within a block and use them later?

do local a2 = 2*a local d = sqrt(b^2 - 4*a*c) x1 = (-b + d)/a2 x2 = (-b - d)/a2 end -- scope of 'a2' and 'd' ends here print(x1, x2)     
asked by 28.08.2018 / 15:30
1
answer

Print does not return table values

pokecatches = { ["Bulbasaur"] = {chance = 150, corpse = 5969}, ["Ivysaur"] = {chance = 275, corpse = 5982}, ["Venusaur"] = {chance = 400, corpse = 5962}, } print(table.maxn(pokecatches)) corpses = {} for x=1, table.maxn(pokecatches) do table.inse...
asked by 03.09.2014 / 04:24
1
answer

Referencing a table with a string in Lua

I need to use a table in Lua, but I can only reference it through a string, for example: tabelaA = { "qualquer coisa" } variavelA = "tabelaA" print(variavelA) resultado: "qualquer coisa" Keeping in mind that I can not reference this table...
asked by 04.06.2016 / 07:05