mirror of
https://git.minetest.land/Mineclonia/Mineclonia.git
synced 2024-11-28 06:03:06 +00:00
More robust initialization of chests of structs
This commit is contained in:
parent
1daf9b7a59
commit
19b1cf5986
1 changed files with 15 additions and 2 deletions
|
@ -15,6 +15,18 @@ mcl_structures.get_struct = function(file)
|
|||
return allnode
|
||||
end
|
||||
|
||||
-- Call on_construct on pos.
|
||||
-- Useful to init chests from formspec.
|
||||
local init_node_construct = function(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
local def = minetest.registered_nodes[node.name]
|
||||
if def and def.on_construct then
|
||||
def.on_construct(pos)
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
-- The call of Struct
|
||||
mcl_structures.call_struct = function(pos, struct_style, rotation)
|
||||
if not rotation then
|
||||
|
@ -185,9 +197,9 @@ mcl_structures.generate_igloo_basement = function(pos, orientation)
|
|||
}}, pr)
|
||||
|
||||
local chest_pos = vector.add(pos, chest_offset)
|
||||
init_node_construct(chest_pos)
|
||||
local meta = minetest.get_meta(chest_pos)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("main", 9*3)
|
||||
mcl_loot.fill_inventory(inv, "main", lootitems)
|
||||
end
|
||||
return success
|
||||
|
@ -396,9 +408,10 @@ mcl_structures.generate_desert_temple = function(pos)
|
|||
}
|
||||
}}, pr)
|
||||
|
||||
local meta = minetest.get_meta(chests[c])
|
||||
init_node_construct(chests[c])
|
||||
local meta = minetest.get_meta(chests[c])
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("main", 9*3)
|
||||
mcl_loot.fill_inventory(inv, "main", lootitems)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue