forked from mtcontrib/connected_chests
fix pipeworks item inserting support, closes #1
This commit is contained in:
parent
acf8042587
commit
f2aa5c1c95
|
@ -1,3 +1,2 @@
|
|||
TODO:
|
||||
— disallow rotating the chest with a screwdriver
|
||||
— test inserting items in the right side
|
||||
|
|
46
init.lua
46
init.lua
|
@ -225,20 +225,29 @@ end
|
|||
minetest.register_node("connected_chests:chest_locked_left", chest_locked)
|
||||
|
||||
|
||||
local tube_to_left_locked = {
|
||||
insert_object = function(pos, node, stack)
|
||||
local x, z = unpack(string.split(param_tab2[node.param2], " "))
|
||||
return minetest.get_meta({x=pos.x+x, y=pos.y, z=pos.z+z}):get_inventory():add_item("main", stack)
|
||||
end,
|
||||
can_insert = function(pos, node, stack)
|
||||
local x, z = unpack(string.split(param_tab2[node.param2], " "))
|
||||
return minetest.get_meta({x=pos.x+x, y=pos.y, z=pos.z+z}):get_inventory():room_for_item("main", stack)
|
||||
end,
|
||||
connect_sides = {right = 1, back = 1, front = 1, bottom = 1, top = 1}
|
||||
}
|
||||
local tube_to_left, tube_to_left_locked, tube_update, tube_groups
|
||||
if minetest.global_exists("pipeworks") then
|
||||
tube_to_left_locked = {
|
||||
insert_object = function(pos, node, stack)
|
||||
local x, z = unpack(string.split(param_tab2[node.param2], " "))
|
||||
return minetest.get_meta({x=pos.x+x, y=pos.y, z=pos.z+z}):get_inventory():add_item("main", stack)
|
||||
end,
|
||||
can_insert = function(pos, node, stack)
|
||||
local x, z = unpack(string.split(param_tab2[node.param2], " "))
|
||||
return minetest.get_meta({x=pos.x+x, y=pos.y, z=pos.z+z}):get_inventory():room_for_item("main", stack)
|
||||
end,
|
||||
connect_sides = {right = 1, back = 1, front = 1, bottom = 1, top = 1}
|
||||
}
|
||||
|
||||
local tube_to_left = table.copy(tube_to_left_locked)
|
||||
tube_to_left.input_inventory = "main"
|
||||
tube_to_left = table.copy(tube_to_left_locked)
|
||||
tube_to_left.input_inventory = "main"
|
||||
|
||||
tube_update = pipeworks.scan_for_tube_objects
|
||||
|
||||
tube_groups = {tubedevice=1, tubedevice_receiver=1}
|
||||
else
|
||||
function tube_update() end
|
||||
end
|
||||
|
||||
minetest.register_node("connected_chests:chest_right", {
|
||||
tiles = {top_texture.."^[transformFX", top_texture.."^[transformFX", "default_chest_side.png",
|
||||
|
@ -259,7 +268,9 @@ minetest.register_node("connected_chests:chest_right", {
|
|||
if node_left.name ~= "connected_chests:chest_left"
|
||||
or node_left.param2 ~= node.param2 then
|
||||
minetest.remove_node(pos)
|
||||
return
|
||||
end
|
||||
tube_update(pos)
|
||||
end,
|
||||
after_destruct = function(pos, oldnode)
|
||||
if oldnode.param2 > 3 then
|
||||
|
@ -271,9 +282,12 @@ minetest.register_node("connected_chests:chest_right", {
|
|||
and node_left.param2 == oldnode.param2
|
||||
and minetest.get_node(pos).name == "air" then
|
||||
minetest.set_node(pos, oldnode)
|
||||
return
|
||||
end
|
||||
tube_update(pos)
|
||||
end,
|
||||
tube = tube_to_left,
|
||||
groups = tube_groups,
|
||||
})
|
||||
|
||||
minetest.register_node("connected_chests:chest_locked_right", {
|
||||
|
@ -287,6 +301,7 @@ minetest.register_node("connected_chests:chest_locked_right", {
|
|||
local node = minetest.get_node(pos)
|
||||
if node.param2 > 3 then
|
||||
node.param2 = node.param2%4
|
||||
-- ↓ calls the on_construct from the beginning again
|
||||
minetest.set_node(pos, node)
|
||||
return
|
||||
end
|
||||
|
@ -295,7 +310,9 @@ minetest.register_node("connected_chests:chest_locked_right", {
|
|||
if node_left.name ~= "connected_chests:chest_locked_left"
|
||||
or node_left.param2 ~= node.param2 then
|
||||
minetest.remove_node(pos)
|
||||
return
|
||||
end
|
||||
tube_update(pos)
|
||||
end,
|
||||
after_destruct = function(pos, oldnode)
|
||||
if oldnode.param2 > 3 then
|
||||
|
@ -307,9 +324,12 @@ minetest.register_node("connected_chests:chest_locked_right", {
|
|||
and node_left.param2 == oldnode.param2
|
||||
and minetest.get_node(pos).name == "air" then
|
||||
minetest.set_node(pos, oldnode)
|
||||
return
|
||||
end
|
||||
tube_update(pos)
|
||||
end,
|
||||
tube = tube_to_left_locked,
|
||||
groups = tube_groups,
|
||||
})
|
||||
|
||||
-- abms to fix half chests
|
||||
|
|
Loading…
Reference in New Issue
Block a user