mirror of
https://github.com/minetest-mods/technic.git
synced 2025-04-16 01:10:37 +02:00
add tubelib support to chests
This commit is contained in:
parent
a9b10cc4b1
commit
98949482f8
@ -4,3 +4,4 @@ moreblocks?
|
|||||||
moreores?
|
moreores?
|
||||||
pipeworks?
|
pipeworks?
|
||||||
intllib?
|
intllib?
|
||||||
|
tubelib?
|
||||||
|
3
technic_chests/mod.conf
Normal file
3
technic_chests/mod.conf
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
name=technic_chests
|
||||||
|
depends=default,basic_materials
|
||||||
|
optional_depends=moreblocks,moreores,pipeworks,intllib,tubelib
|
@ -330,12 +330,48 @@ function technic.chests:definition(name, data)
|
|||||||
return def
|
return def
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local _TUBELIB_CALLBACKS = {
|
||||||
|
on_pull_item = function(pos, side, player_name)
|
||||||
|
local inv = minetest.get_meta(pos):get_inventory()
|
||||||
|
if not minetest.is_protected(pos, player_name) then
|
||||||
|
for _, stack in pairs(inv:get_list("main")) do
|
||||||
|
if not stack:is_empty() then
|
||||||
|
return inv:remove_item("main", stack:get_name())
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return nil
|
||||||
|
end,
|
||||||
|
on_push_item = function(pos, side, item, player_name)
|
||||||
|
local inv = minetest.get_meta(pos):get_inventory()
|
||||||
|
if inv:room_for_item("main", item) then
|
||||||
|
inv:add_item("main", item)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end,
|
||||||
|
on_unpull_item = function(pos, side, item, player_name)
|
||||||
|
local inv = minetest.get_meta(pos):get_inventory()
|
||||||
|
if inv:room_for_item("main", item) then
|
||||||
|
inv:add_item("main", item)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end,
|
||||||
|
on_recv_message = function(pos, topic, payload)
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
function technic.chests:register(name, data)
|
function technic.chests:register(name, data)
|
||||||
local def = technic.chests:definition(name, data)
|
local def = technic.chests:definition(name, data)
|
||||||
|
|
||||||
local nn = "technic:"..name:lower()..(data.locked and "_locked" or "").."_chest"
|
local nn = "technic:"..name:lower()..(data.locked and "_locked" or "").."_chest"
|
||||||
minetest.register_node(":"..nn, def)
|
minetest.register_node(":"..nn, def)
|
||||||
|
|
||||||
|
if minetest.get_modpath("tubelib") then
|
||||||
|
tubelib.register_node(nn, {}, _TUBELIB_CALLBACKS)
|
||||||
|
end
|
||||||
|
|
||||||
if data.color then
|
if data.color then
|
||||||
local mk_front
|
local mk_front
|
||||||
if string.find(def.tiles[6], "%^") then
|
if string.find(def.tiles[6], "%^") then
|
||||||
@ -353,8 +389,10 @@ function technic.chests:register(name, data)
|
|||||||
colordef.groups = self.groups_noinv
|
colordef.groups = self.groups_noinv
|
||||||
colordef.tiles = { def.tiles[1], def.tiles[2], def.tiles[3], def.tiles[4], def.tiles[5], mk_front("technic_chest_overlay"..postfix..".png") }
|
colordef.tiles = { def.tiles[1], def.tiles[2], def.tiles[3], def.tiles[4], def.tiles[5], mk_front("technic_chest_overlay"..postfix..".png") }
|
||||||
minetest.register_node(":"..nn..postfix, colordef)
|
minetest.register_node(":"..nn..postfix, colordef)
|
||||||
|
if minetest.get_modpath("tubelib") then
|
||||||
|
tubelib.register_node(nn..postfix, {}, _TUBELIB_CALLBACKS)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user