2022-06-03 21:09:45 +02:00
|
|
|
local oldprint = print
|
|
|
|
function print(t,x,y,col1,col2)
|
|
|
|
if col2 then
|
|
|
|
for i=-1,1 do
|
|
|
|
for j=-1,1 do
|
|
|
|
oldprint(t, x+i, y+j, col2)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
oldprint(t, x, y, col1)
|
|
|
|
end
|
|
|
|
|
|
|
|
function str_width(str)
|
|
|
|
return print(str,0,-8)
|
|
|
|
end
|
|
|
|
|
|
|
|
function print_shade(t,x,y,col1,col2)
|
|
|
|
print(t,x,y+1,col2)
|
|
|
|
print(t,x+1,y+1,col2)
|
|
|
|
print(t,x,y,col1)
|
|
|
|
end
|
|
|
|
|
|
|
|
function set_state(state, ...)
|
|
|
|
local args = {...}
|
|
|
|
if gs and gs._leave then gs._leave() end
|
|
|
|
gs = state
|
|
|
|
if gs and gs._enter then gs._enter(unpack(args)) end
|
2022-06-03 23:31:26 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Returns the indices of found occurences of `o` within `tbl`
|
|
|
|
--
|
|
|
|
function find(tbl, o)
|
|
|
|
local indices = {}
|
|
|
|
for k,v in ipairs(tbl) do
|
|
|
|
if v == o then add(indices, k) end
|
|
|
|
end
|
|
|
|
return indices
|
|
|
|
end
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Makes a shallow table copy
|
|
|
|
--
|
|
|
|
function copy(tbl)
|
|
|
|
return map(tbl, function (o) return o end)
|
|
|
|
end
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Table equality - shallow comparison
|
|
|
|
--
|
|
|
|
function equal(tbl1, tbl2)
|
|
|
|
for k, _ in ipairs(tbl1) do
|
|
|
|
if tbl1[k] ~= tbl2[k] then return false end
|
|
|
|
end
|
|
|
|
return true
|
2022-06-03 21:09:45 +02:00
|
|
|
end
|