mirror of
https://github.com/minetest-mods/technic.git
synced 2024-12-22 05:42:33 +01:00
Add tubelib support to technic chests (#498)
This commit is contained in:
parent
e8f1033d49
commit
8a987bb361
@ -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
|
@ -2,6 +2,7 @@ local S = rawget(_G, "intllib") and intllib.Getter() or function(s) return s end
|
|||||||
|
|
||||||
local pipeworks = rawget(_G, "pipeworks")
|
local pipeworks = rawget(_G, "pipeworks")
|
||||||
local fs_helpers = rawget(_G, "fs_helpers")
|
local fs_helpers = rawget(_G, "fs_helpers")
|
||||||
|
local tubelib_exists = minetest.global_exists("tubelib")
|
||||||
|
|
||||||
local allow_label = ""
|
local allow_label = ""
|
||||||
local tube_entry = ""
|
local tube_entry = ""
|
||||||
@ -330,12 +331,46 @@ function technic.chests:definition(name, data)
|
|||||||
return def
|
return def
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local _TUBELIB_CALLBACKS = {
|
||||||
|
on_pull_item = function(pos, side, player_name)
|
||||||
|
if not minetest.is_protected(pos, player_name) then
|
||||||
|
local inv = minetest.get_meta(pos):get_inventory()
|
||||||
|
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,
|
||||||
|
}
|
||||||
|
|
||||||
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 tubelib_exists 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 +388,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 tubelib_exists then
|
||||||
|
tubelib.register_node(nn..postfix, {}, _TUBELIB_CALLBACKS)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user