summaryrefslogtreecommitdiff
path: root/lua/api.lua
diff options
context:
space:
mode:
authorLNJ <git@lnj.li>2017-04-01 19:13:09 +0200
committerLNJ <git@lnj.li>2017-04-01 19:13:09 +0200
commiteaec8f74783b3672a18a4a0095994bf99aa9574e (patch)
tree06193a8c8ef0b85812939370d830512a58a2c9e7 /lua/api.lua
parentf42c15019a7832f246765c95e9b6472ab37b5e41 (diff)
Add support for pipeworks
Diffstat (limited to 'lua/api.lua')
-rwxr-xr-xlua/api.lua20
1 files changed, 20 insertions, 0 deletions
diff --git a/lua/api.lua b/lua/api.lua
index ecda9f2..3789018 100755
--- a/lua/api.lua
+++ b/lua/api.lua
@@ -92,6 +92,14 @@ function drawers.drawer_on_dig(pos, node, player)
end
end
+function drawers.drawer_insert_object(pos, node, stack, direction)
+ local drawer_visual = drawers.drawer_visuals[core.serialize(pos)]
+ if not drawer_visual then return stack end
+
+ local leftover = drawer_visual.try_insert_stack(drawer_visual, stack, true)
+ return leftover
+end
+
function drawers.register_drawer(name, def)
def.description = def.description or "Drawer"
def.drawtype = "nodebox"
@@ -114,6 +122,18 @@ function drawers.register_drawer(name, def)
def.on_rotate = def.on_rotate or screwdriver.disallow
end
+ if pipeworks then
+ def.groups.tubedevice = 1
+ def.groups.tubedevice_receiver = 1
+ def.tube = def.tube or {}
+ def.tube.insert_object = def.tube.insert_object or
+ drawers.drawer_insert_object
+ def.tube.connect_sides = {left = 1, right = 1, back = 1, top = 1,
+ bottom = 1}
+ def.after_place_node = pipeworks.after_place
+ def.after_dig_node = pipeworks.after_dig
+ end
+
core.register_node(name, def)
if (not def.no_craft) and def.material then