summaryrefslogtreecommitdiff
path: root/filter-injector.lua
diff options
context:
space:
mode:
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