Files
jailsadventure2/data/switches.lua

33 lines
755 B
Lua

switches={
list={},
col=0,
reset=function()
switches.list={}
end,
add=function(switch)
if not switch.w then switch.w=1 end
if not switch.h then switch.h=1 end
table.insert(switches.list, switch)
end,
search=function(x,y)
for i,v in ipairs(switches.list) do
if x>=v.x and x<v.x+v.w and y>=v.y and y<v.y+v.h then
return v
end
end
return nil
end,
draw=function()
text(#switches.list,1,25,8)
if switches.col<16 then
for i,v in ipairs(switches.list) do
draw.rect(v.x*8, v.y*8, (v.w+1)*8, (v.h)*8, 8);
end
end
switches.col=(switches.col+1)%32
end,
}