summaryrefslogtreecommitdiff
path: root/filter-injector.lua
diff options
context:
space:
mode:
authorroot <root@linuxworks.belug.de>2017-04-15 13:30:39 +0200
committerroot <root@linuxworks.belug.de>2017-04-15 13:30:39 +0200
commite3f858c9484d9036354a89f0ca2c395e71bd1fbe (patch)
tree87751e3ed01c379f2fed1969b2b8eeda0b47b85e /filter-injector.lua
parent73e94e3c070555e3fcd3dd06c606c49480d4823c (diff)
parentd82227942d3a9e4c68582224327cab13e6556753 (diff)
Merge branch 'master' of https://github.com/minetest-mods/pipeworks
Diffstat (limited to 'filter-injector.lua')
-rw-r--r--filter-injector.lua17
1 files changed, 16 insertions, 1 deletions
diff --git a/filter-injector.lua b/filter-injector.lua
index 72f7bad..4870501 100644
--- a/filter-injector.lua
+++ b/filter-injector.lua
@@ -1,3 +1,5 @@
+local fs_helpers = pipeworks.fs_helpers
+
local function delay(x)
return (function() return x end)
end
@@ -169,7 +171,7 @@ local function punch_filter(data, filtpos, filtnode, msg)
is_fake_player = ":pipeworks",
get_wielded_item = delay(ItemStack(nil))
} -- TODO: use a mechanism as the wielder one
- local dir = minetest.facedir_to_right_dir(filtnode.param2)
+ local dir = pipeworks.facedir_to_right_dir(filtnode.param2)
local frompos = vector.subtract(filtpos, dir)
local fromnode = minetest.get_node(frompos)
if not fromnode then return end
@@ -194,6 +196,19 @@ local function punch_filter(data, filtpos, filtnode, msg)
["technic:tool_workshop"] = "src",
}
+ -- make sure there's something appropriate to inject the item into
+ local todir = pipeworks.facedir_to_right_dir(filtnode.param2)
+ local topos = vector.add(filtpos, todir)
+ local tonode = minetest.get_node(topos)
+ local todef = minetest.registered_nodes[tonode.name]
+
+ if not todef
+ or not (minetest.get_item_group(tonode.name, "tube") == 1
+ or minetest.get_item_group(tonode.name, "tubedevice") == 1
+ or minetest.get_item_group(tonode.name, "tubedevice_receiver") == 1) then
+ return
+ end
+
if fromtube then fromtube.input_inventory = input_special_cases[fromnode.name] or fromtube.input_inventory end
if not (fromtube and fromtube.input_inventory) then return end