Skip to content

Commit 0241610

Browse files
committed
Add parse options for logistic point util
1 parent 3ad1b8c commit 0241610

File tree

1 file changed

+30
-13
lines changed

1 file changed

+30
-13
lines changed

utils/logistic_point.lua

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,35 @@ local Public = {}
33
---@param item_stack LuaItemStack|SignalFilter
44
---@return SignalFilter
55
local function parse_item_stack(item_stack)
6-
return {
7-
value = {
8-
type = item_stack.type or 'item',
9-
name = item_stack.name,
10-
quality = item_stack.quality,
11-
comparator = item_stack.comparator,
12-
},
13-
min = item_stack.min or item_stack.count,
14-
max = item_stack.max or item_stack.count,
15-
minimum_delivery_count = item_stack.minimum_delivery_count,
16-
import_from = item_stack.import_from,
17-
}
6+
if item_stack.name and item_stack.type then
7+
return {
8+
value = {
9+
type = item_stack.type or 'item',
10+
name = item_stack.name,
11+
quality = item_stack.quality,
12+
comparator = item_stack.comparator,
13+
},
14+
min = item_stack.min or item_stack.count,
15+
max = item_stack.max or item_stack.count,
16+
minimum_delivery_count = item_stack.minimum_delivery_count,
17+
import_from = (type(item_stack.import_from) == 'table' and item_stack.import_from.name) or item_stack.import_from,
18+
}
19+
elseif item_stack.value then
20+
return {
21+
value = {
22+
type = item_stack.value.type or 'item',
23+
name = item_stack.value.name,
24+
quality = item_stack.value.quality,
25+
comparator = item_stack.value.comparator,
26+
},
27+
min = item_stack.min or item_stack.min,
28+
max = item_stack.max or item_stack.max,
29+
minimum_delivery_count = item_stack.minimum_delivery_count,
30+
import_from = (type(item_stack.import_from) == 'table' and item_stack.import_from.name) or item_stack.import_from,
31+
}
32+
else
33+
return nil
34+
end
1835
end
1936
Public.parse_item_stack = parse_item_stack
2037

@@ -38,7 +55,7 @@ end
3855
Public.add_filters = function(logistic_point, filters, group)
3956
local section = logistic_point.add_section(group)
4057
for index, filter in pairs(filters) do
41-
section.set_slot(parse_item_stack(filter), index)
58+
section.set_slot(index, parse_item_stack(filter))
4259
end
4360
end
4461

0 commit comments

Comments
 (0)