Lua gsub

lua gsub s = string.gsub(“Lua is cute”, “cute”, “great”) print(s) –> Lua is great s = string.gsub(“all lii”, “l”, “x”) print(s) –> axx xii s = string.gsub(“Lua is great”, “perl”, “tcl”) print(s) –> Lua is great

Lua gsub Read More

Lua for loops

lua for loops –[[ There are two types of lua for loops. There is the generic definition, (pseudo-)expression, increment, and there is one that allows the use of iterators. ]] — The first kind can be used like this: for a = 0 –[[Define a as 0]], 10 –[[Continue until a reaches 10]], 2 –[[Increment […]

Lua for loops Read More

Lua dump table

lua dump table function dump(o) if type(o) == ‘table’ then local s = ‘{ ‘ for k,v in pairs(o) do if type(k) ~= ‘number’ then k = ‘”‘..k..'”‘ end s = s .. ‘[‘..k..’] = ‘ .. dump(v) .. ‘,’ end return s .. ‘} ‘ else return tostring(o) end end

Lua dump table Read More

Lua concatenation

lua concatenation — to concatenate use two dots like this => .. — Example: text1 = “Hello” text2 = “World” print(text1..”, “..text2) lua Concatenation “string” .. “other string” — returns: stringother string

Lua concatenation Read More