mirror of
https://github.com/HybridDog/connected_chests.git
synced 2024-12-28 06:00:17 +01:00
fix pipeworks item inserting support, closes #1
This commit is contained in:
parent
acf8042587
commit
f2aa5c1c95
@ -1,3 +1,2 @@
|
|||||||
TODO:
|
TODO:
|
||||||
— disallow rotating the chest with a screwdriver
|
— disallow rotating the chest with a screwdriver
|
||||||
— test inserting items in the right side
|
|
||||||
|
28
init.lua
28
init.lua
@ -225,7 +225,9 @@ end
|
|||||||
minetest.register_node("connected_chests:chest_locked_left", chest_locked)
|
minetest.register_node("connected_chests:chest_locked_left", chest_locked)
|
||||||
|
|
||||||
|
|
||||||
local tube_to_left_locked = {
|
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)
|
insert_object = function(pos, node, stack)
|
||||||
local x, z = unpack(string.split(param_tab2[node.param2], " "))
|
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)
|
return minetest.get_meta({x=pos.x+x, y=pos.y, z=pos.z+z}):get_inventory():add_item("main", stack)
|
||||||
@ -235,10 +237,17 @@ local tube_to_left_locked = {
|
|||||||
return minetest.get_meta({x=pos.x+x, y=pos.y, z=pos.z+z}):get_inventory():room_for_item("main", stack)
|
return minetest.get_meta({x=pos.x+x, y=pos.y, z=pos.z+z}):get_inventory():room_for_item("main", stack)
|
||||||
end,
|
end,
|
||||||
connect_sides = {right = 1, back = 1, front = 1, bottom = 1, top = 1}
|
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 = table.copy(tube_to_left_locked)
|
||||||
tube_to_left.input_inventory = "main"
|
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", {
|
minetest.register_node("connected_chests:chest_right", {
|
||||||
tiles = {top_texture.."^[transformFX", top_texture.."^[transformFX", "default_chest_side.png",
|
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"
|
if node_left.name ~= "connected_chests:chest_left"
|
||||||
or node_left.param2 ~= node.param2 then
|
or node_left.param2 ~= node.param2 then
|
||||||
minetest.remove_node(pos)
|
minetest.remove_node(pos)
|
||||||
|
return
|
||||||
end
|
end
|
||||||
|
tube_update(pos)
|
||||||
end,
|
end,
|
||||||
after_destruct = function(pos, oldnode)
|
after_destruct = function(pos, oldnode)
|
||||||
if oldnode.param2 > 3 then
|
if oldnode.param2 > 3 then
|
||||||
@ -271,9 +282,12 @@ minetest.register_node("connected_chests:chest_right", {
|
|||||||
and node_left.param2 == oldnode.param2
|
and node_left.param2 == oldnode.param2
|
||||||
and minetest.get_node(pos).name == "air" then
|
and minetest.get_node(pos).name == "air" then
|
||||||
minetest.set_node(pos, oldnode)
|
minetest.set_node(pos, oldnode)
|
||||||
|
return
|
||||||
end
|
end
|
||||||
|
tube_update(pos)
|
||||||
end,
|
end,
|
||||||
tube = tube_to_left,
|
tube = tube_to_left,
|
||||||
|
groups = tube_groups,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("connected_chests:chest_locked_right", {
|
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)
|
local node = minetest.get_node(pos)
|
||||||
if node.param2 > 3 then
|
if node.param2 > 3 then
|
||||||
node.param2 = node.param2%4
|
node.param2 = node.param2%4
|
||||||
|
-- ↓ calls the on_construct from the beginning again
|
||||||
minetest.set_node(pos, node)
|
minetest.set_node(pos, node)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -295,7 +310,9 @@ minetest.register_node("connected_chests:chest_locked_right", {
|
|||||||
if node_left.name ~= "connected_chests:chest_locked_left"
|
if node_left.name ~= "connected_chests:chest_locked_left"
|
||||||
or node_left.param2 ~= node.param2 then
|
or node_left.param2 ~= node.param2 then
|
||||||
minetest.remove_node(pos)
|
minetest.remove_node(pos)
|
||||||
|
return
|
||||||
end
|
end
|
||||||
|
tube_update(pos)
|
||||||
end,
|
end,
|
||||||
after_destruct = function(pos, oldnode)
|
after_destruct = function(pos, oldnode)
|
||||||
if oldnode.param2 > 3 then
|
if oldnode.param2 > 3 then
|
||||||
@ -307,9 +324,12 @@ minetest.register_node("connected_chests:chest_locked_right", {
|
|||||||
and node_left.param2 == oldnode.param2
|
and node_left.param2 == oldnode.param2
|
||||||
and minetest.get_node(pos).name == "air" then
|
and minetest.get_node(pos).name == "air" then
|
||||||
minetest.set_node(pos, oldnode)
|
minetest.set_node(pos, oldnode)
|
||||||
|
return
|
||||||
end
|
end
|
||||||
|
tube_update(pos)
|
||||||
end,
|
end,
|
||||||
tube = tube_to_left_locked,
|
tube = tube_to_left_locked,
|
||||||
|
groups = tube_groups,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- abms to fix half chests
|
-- abms to fix half chests
|
||||||
|
Loading…
Reference in New Issue
Block a user