Allow prebaked chests to have an x and/or y offset

This commit is contained in:
luk3yx 2018-03-24 17:07:34 +13:00
parent b058e21b77
commit 0561ee99dc
1 changed files with 20 additions and 16 deletions

View File

@ -52,27 +52,31 @@ end)
-- --
-- formspeclib:chest - Most useful with chest touchscreens. -- formspeclib:chest - Most useful with chest touchscreens.
-- --
-- Syntax: width(?), height(?) -- Syntax: x(?), y(?), width(?), height(?)
-- --
formspeclib.register_object('formspeclib:chest', function(obj, safe_mode) formspeclib.register_object('formspeclib:chest', function(obj, safe_mode)
local r = not obj.x and not obj.y
if type(obj.x) ~= 'number' then obj.x = 0 end
if type(obj.y) ~= 'number' then obj.y = 0 end
if type(obj.width) ~= 'number' then obj.width = 8 end if type(obj.width) ~= 'number' then obj.width = 8 end
if type(obj.height) ~= 'number' then obj.height = 4 end if type(obj.height) ~= 'number' then obj.height = 4 end
return { return {
width = obj.width, width = r and obj.width,
height = obj.height + 5, height = r and obj.height + 5,
{ {
type = 'formspeclib:node_inventory', type = 'formspeclib:node_inventory',
x = 0, x = obj.x,
y = 0.3, y = obj.y + 0.3,
width = obj.width, width = obj.width,
height = obj.height, height = obj.height,
name = obj.name, name = obj.name,
}, },
{ {
type = 'formspeclib:player_inventory', type = 'formspeclib:player_inventory',
x = (obj.width / 2) - 4, x = obj.x + (obj.width / 2) - 4,
y = obj.height + 0.82, y = obj.y + obj.height + 0.82,
}, },
} }
end) end)