love-cellular-automata/util.lua

24 lines
474 B
Lua

function printt(t, prefix, maxdepth)
prefix = prefix or ''
maxdepth = maxdepth or 2
for k, v in pairs(t) do
if prefix ~= '' then
k = prefix .. "." .. k
end
if type(v) == "table" then
if maxdepth > 1 then
print(k .. ":")
printt(v, k, maxdepth - 1)
else
print(k .. ": <table>")
end
else
print(k .. ": " .. tostring(v))
end
end
end
function round2even(num)
return 2 * math.floor(num / 2)
end