1
0
зеркало из https://github.com/mt-mods/homedecor_modpack.git synced 2025-08-04 04:20:21 +02:00

allow chaining of on_construct instead of overwriting in registration function

Этот коммит содержится в:
Tim
2015-08-19 17:30:37 +02:00
родитель 2d433f9652
Коммит 8a91865d82
2 изменённых файлов: 7 добавлений и 8 удалений

Просмотреть файл

@ -61,16 +61,13 @@ function homedecor.handle_inventory(name, def)
if not inventory then return end
def.inventory = nil
local infotext = def.infotext
def.on_construct = def.on_construct or function(pos)
local meta = minetest.get_meta(pos)
if infotext then
meta:set_string("infotext", infotext)
end
local on_construct = def.on_construct
def.on_construct = function(pos)
local size = inventory.size or default_inventory_size
local meta = minetest.get_meta(pos)
meta:get_inventory():set_size("main", size)
meta:set_string("formspec", inventory.formspec or get_formspec_by_size(size))
if on_construct then on_construct(pos) end
end
def.can_dig = def.can_dig or default_can_dig

Просмотреть файл

@ -24,10 +24,12 @@ function homedecor.register(name, def)
local infotext = def.infotext
--def.infotext = nil -- currently used to set locked refrigerator infotexts
if infotext and not def.on_construct then
if infotext then
local on_construct = def.on_construct
def.on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("infotext", infotext)
if on_construct then on_construct(pos) end
end
end