"test/foo/bar"into this table
test = { foo = { bar = {} } } .
Posted 08 March 2017 - 09:31 PM
"test/foo/bar"into this table
test = { foo = { bar = {} } } .
Posted 08 March 2017 - 10:40 PM
Posted 09 March 2017 - 07:20 PM
function getTable(words)
local newTable = {}
if #words > 1 then
newTable[words[1]] = getTable({unpack(words, 2, #words)})
else
newTable[words[1]] = {}
end
return newTable
end
function makeTable(string)
local words = {}
for w in (string .. "/"):gmatch("([^/]*)/") do table.insert(words, w) end
return getTable(words)
end
assert(makeTable("test/foo/bar"), {test = { foo = { bar = {} } } })
nameOfVariable = "test" _G[nameOfVariable] = "value"
test = "value"
0 members, 1 guests, 0 anonymous users