summaryrefslogtreecommitdiff
path: root/filter-injector.lua
diff options
context:
space:
mode:
authorelectrodude <electrodude512@gmail.com>2016-05-25 02:44:42 -0400
committerAuke Kok <sofar+github@foo-projects.org>2016-10-10 14:15:44 -0700
commit36d9e1fc08b77a058454d4d9de1cde505e37806e (patch)
tree946755789f8e035c1665b487bcea902ad0ecb09e /filter-injector.lua
parent6e0e7c47d08225b8483540229ccb900a24cf4aed (diff)
downloadpipeworks-36d9e1fc08b77a058454d4d9de1cde505e37806e.tar
pipeworks-36d9e1fc08b77a058454d4d9de1cde505e37806e.tar.gz
pipeworks-36d9e1fc08b77a058454d4d9de1cde505e37806e.tar.bz2
pipeworks-36d9e1fc08b77a058454d4d9de1cde505e37806e.tar.xz
pipeworks-36d9e1fc08b77a058454d4d9de1cde505e37806e.zip
Digiline Filter-Injector tweaks
* Made digiline filter-injectors not pull a whole stack if the count is exactly 1 * Made digiline filter-injectors pull a whole stack if no count specified * `default:dirt` still has a count of 1, but `{name="name"}` has no count
Diffstat (limited to 'filter-injector.lua')
-rw-r--r--filter-injector.lua13
1 files changed, 7 insertions, 6 deletions
diff --git a/filter-injector.lua b/filter-injector.lua
index 7fbabc2..88634ca 100644
--- a/filter-injector.lua
+++ b/filter-injector.lua
@@ -52,7 +52,7 @@ local function set_filter_formspec(data, meta)
end
-- todo SOON: this function has *way too many* parameters
-local function grabAndFire(data,slotseq_mode,exmatch_mode,filtmeta,frominv,frominvname,frompos,fromnode,filterfor,fromtube,fromdef,dir,fakePlayer,all)
+local function grabAndFire(data,slotseq_mode,exmatch_mode,filtmeta,frominv,frominvname,frompos,fromnode,filterfor,fromtube,fromdef,dir,fakePlayer,all,digiline)
local sposes = {}
for spos,stack in ipairs(frominv:get_list(frominvname)) do
local matches
@@ -104,10 +104,11 @@ local function grabAndFire(data,slotseq_mode,exmatch_mode,filtmeta,frominv,fromi
local count
if all then
count = math.min(stack:get_count(), doRemove)
- if filterfor.count and filterfor.count > 1 then
+ if filterfor.count and (filterfor.count > 1 or digiline) then
if exmatch_mode ~= 0 and filterfor.count > count then
- return false
+ return false -- not enough, fail
else
+ -- limit quantity to filter amount
count = math.min(filterfor.count, count)
end
end
@@ -207,13 +208,13 @@ local function punch_filter(data, filtpos, filtnode, msg)
end
if type(msg.name) == "string" then
- table.insert(filters, {name = msg.name, count = tonumber(msg.count) or 1})
+ table.insert(filters, {name = msg.name, count = tonumber(msg.count)})
else
for _, filter in ipairs(msg) do
local t_filter = type(filter)
if t_filter == "table" then
if type(filter.name) == "string" then
- table.insert(filters, {name = filter.name, count = tonumber(filter.count) or 1})
+ table.insert(filters, {name = filter.name, count = tonumber(filter.count)})
end
elseif t_filter == "string" then
local filterstack = ItemStack(filter)
@@ -252,7 +253,7 @@ local function punch_filter(data, filtpos, filtnode, msg)
for _, frominvname in ipairs(type(fromtube.input_inventory) == "table" and fromtube.input_inventory or {fromtube.input_inventory}) do
local done = false
for _, filterfor in ipairs(filters) do
- if grabAndFire(data, slotseq_mode, exact_match, filtmeta, frominv, frominvname, frompos, fromnode, filterfor, fromtube, fromdef, dir, fakePlayer, data.stackwise) then
+ if grabAndFire(data, slotseq_mode, exact_match, filtmeta, frominv, frominvname, frompos, fromnode, filterfor, fromtube, fromdef, dir, fakePlayer, data.stackwise, data.digiline) then
done = true
break
end