garden/util.lua

24 lines
356 B
Lua

local m = {}
local function rext(a, i)
i = i - 1
local v = a[i]
if v then
return i, v
end
end
function m.ipairs_rev(a)
return rext, a, (#a + 1)
end
function m.between(x, a, b)
return a <= x and x <= b
end
function m.inside(px, py, x, y, w, h)
return m.between(px, x, x+w) and
m.between(py, y, y+h)
end
return m