forked from Mineclonia/Mineclonia
40 lines
869 B
Lua
40 lines
869 B
Lua
mcl_formspec = {}
|
|
|
|
function mcl_formspec.get_itemslot_bg(x, y, w, h)
|
|
local out = ""
|
|
for i = 0, w - 1, 1 do
|
|
for j = 0, h - 1, 1 do
|
|
out = out .."image["..x+i..","..y+j..";1,1;mcl_formspec_itemslot.png]"
|
|
end
|
|
end
|
|
return out
|
|
end
|
|
|
|
-- From the Minetest Lua API doc, "Migrating to Real Coordinates"
|
|
local padding, spacing = 3/8, 5/4
|
|
|
|
function mcl_formspec.size2r(w, h)
|
|
return (((w-1)*spacing) + (padding*2) + 1)..","..(((h-1)*spacing) + (padding*2) + 1)
|
|
end
|
|
|
|
local function i2r(i)
|
|
return (i*spacing)+padding
|
|
end
|
|
mcl_formspec.i2r=i2r
|
|
|
|
function mcl_formspec.xy2r(x, y)
|
|
return i2r(x)..","..i2r(y)
|
|
end
|
|
|
|
function mcl_formspec.get_itemslot_bgv2(x, y, w, h)
|
|
local out = ""
|
|
x=i2r(x)-padding
|
|
y=i2r(y)-padding
|
|
for i = 0, w - 1, 1 do
|
|
for j = 0, h - 1, 1 do
|
|
out = out .."image["..x+i2r(i)..","..y+i2r(j)..";1,1;mcl_formspec_itemslot.png]"
|
|
end
|
|
end
|
|
return out
|
|
end
|