summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorest31 <MTest31@outlook.com>2015-02-03 23:12:10 +0100
committerest31 <MTest31@outlook.com>2015-02-03 23:32:55 +0100
commit8e9affc841412fffef35e2396566334ae3e6b091 (patch)
treecce9ce1da7497f4b4d415fcc6e9a995c8bdf0ba0
parent50b417ce134a8549d4fa3a245babbcb30e0a9f34 (diff)
downloadpipeworks-8e9affc841412fffef35e2396566334ae3e6b091.tar
pipeworks-8e9affc841412fffef35e2396566334ae3e6b091.tar.gz
pipeworks-8e9affc841412fffef35e2396566334ae3e6b091.tar.bz2
pipeworks-8e9affc841412fffef35e2396566334ae3e6b091.tar.xz
pipeworks-8e9affc841412fffef35e2396566334ae3e6b091.zip
Make sorting tubes not drop elements if all outputs filtering for a specific element are filled.
Send them to some other open (empty) port instead.
-rw-r--r--sorting_tubes.lua39
1 files changed, 23 insertions, 16 deletions
diff --git a/sorting_tubes.lua b/sorting_tubes.lua
index 84a2306..8c1d49e 100644
--- a/sorting_tubes.lua
+++ b/sorting_tubes.lua
@@ -52,22 +52,29 @@ if pipeworks.enable_mese_tube then
local inv = meta:get_inventory()
local name = stack:get_name()
for i, vect in ipairs(pipeworks.meseadjlist) do
- if meta:get_int("l"..i.."s") == 1 then
- local invname = "line"..i
- local is_empty = true
- for _, st in ipairs(inv:get_list(invname)) do
- if not st:is_empty() then
- is_empty = false
- if st:get_name() == name then
- foundn = foundn + 1
- found[foundn] = vect
- end
- end
- end
- if is_empty then
- tbln = tbln + 1
- tbl[tbln] = vect
- end
+ local npos = vector.add(pos, vect)
+ local node = minetest.get_node(npos)
+ local reg_node = minetest.registered_nodes[node.name]
+ if meta:get_int("l"..i.."s") == 1 and reg_node then
+ local tube_def = reg_node.tube
+ if not tube_def or not tube_def.can_insert or
+ tube_def.can_insert(npos, node, stack, vect) then
+ local invname = "line"..i
+ local is_empty = true
+ for _, st in ipairs(inv:get_list(invname)) do
+ if not st:is_empty() then
+ is_empty = false
+ if st:get_name() == name then
+ foundn = foundn + 1
+ found[foundn] = vect
+ end
+ end
+ end
+ if is_empty then
+ tbln = tbln + 1
+ tbl[tbln] = vect
+ end
+ end
end
end
return (foundn > 0) and found or tbl