1
0
mirror of https://github.com/mt-mods/homedecor_modpack.git synced 2024-12-23 00:20:17 +01:00

only set main list size if size field is given, to allow using the locked/lockable features with different listnames

This commit is contained in:
Tim 2015-08-19 22:02:04 +02:00
parent 088269a85e
commit 9773d63e8e

View File

@ -5,7 +5,6 @@ local default_can_dig = function(pos,player)
return meta:get_inventory():is_empty("main") return meta:get_inventory():is_empty("main")
end end
local default_inventory_size = 32
local background = default.gui_bg .. default.gui_bg_img .. default.gui_slots local background = default.gui_bg .. default.gui_bg_img .. default.gui_slots
local default_inventory_formspecs = { local default_inventory_formspecs = {
["4"]="size[8,6]".. background .. ["4"]="size[8,6]".. background ..
@ -63,13 +62,15 @@ function homedecor.handle_inventory(name, def, original_def)
if not inventory then return end if not inventory then return end
def.inventory = nil def.inventory = nil
local on_construct = def.on_construct if inventory.size then
def.on_construct = function(pos) local on_construct = def.on_construct
local size = inventory.size or default_inventory_size def.on_construct = function(pos)
local meta = minetest.get_meta(pos) local size = inventory.size
meta:get_inventory():set_size("main", size) local meta = minetest.get_meta(pos)
meta:set_string("formspec", inventory.formspec or get_formspec_by_size(size)) meta:get_inventory():set_size("main", size)
if on_construct then on_construct(pos) end meta:set_string("formspec", inventory.formspec or get_formspec_by_size(size))
if on_construct then on_construct(pos) end
end
end end
def.can_dig = def.can_dig or default_can_dig def.can_dig = def.can_dig or default_can_dig