sprites/util/lua-ext.lua
Christopher Monsanto 1c071214b5 Use utf8.char, tup supports lua 5.3 after all
Did it gain support in a later version? Or, was I imagining it only
supporting 5.1 from the start?
2020-04-13 02:16:31 -04:00

22 lines
413 B
Lua

-- Allow `for v in iter(table)` instead of `for _, v in ipairs(table)`
function iter(table)
local i = 1
return function ()
local v = table[i]
i = i + 1
return v
end
end
function astable(table)
local t = type(table)
if t == 'table' then
return table
elseif t == 'string' then
return {table}
elseif t == 'nil' then
return {}
end
end