mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-03-19 21:10:19 +02:00
Fix module
Iterate and check if valid logistics filters
This commit is contained in:
parent
2689768d07
commit
ca24e86ba7
@ -40,6 +40,17 @@ local bps_blacklist = {
|
|||||||
['blueprint'] = true
|
['blueprint'] = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local get_filters = function (points)
|
||||||
|
for _, section in pairs(points.sections) do
|
||||||
|
for _, filter in pairs(section.filters) do
|
||||||
|
if filter.value and filter.value.name then
|
||||||
|
filters[#filters + 1] = filter
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return filters
|
||||||
|
end
|
||||||
|
|
||||||
local on_init_token =
|
local on_init_token =
|
||||||
Task.register(
|
Task.register(
|
||||||
function ()
|
function ()
|
||||||
@ -258,8 +269,8 @@ end
|
|||||||
local function check_if_valid_requests(chest)
|
local function check_if_valid_requests(chest)
|
||||||
local requests = 0
|
local requests = 0
|
||||||
if chest.type == 'logistic-container' then
|
if chest.type == 'logistic-container' then
|
||||||
local lp = chest.get_logistic_point(defines.logistic_member_index.logistic_container)
|
local logistics = chest.get_logistic_point(defines.logistic_member_index.logistic_container)
|
||||||
local filters = LP.get_filters(lp)
|
local filters = get_filters(logistics)
|
||||||
requests = #filters
|
requests = #filters
|
||||||
end
|
end
|
||||||
return requests > 0
|
return requests > 0
|
||||||
@ -413,18 +424,15 @@ local function insert_into_wagon_filtered(stack, chests, name, floaty_text_list)
|
|||||||
for chestnr, chest in pairs(chests.chest) do
|
for chestnr, chest in pairs(chests.chest) do
|
||||||
if chest.type == 'logistic-container' then
|
if chest.type == 'logistic-container' then
|
||||||
local chest_inventory = chests.inventory[chestnr]
|
local chest_inventory = chests.inventory[chestnr]
|
||||||
for index = 1, chest.request_slot_count do
|
local logistics = chest.get_logistic_point(defines.logistic_member_index.logistic_container)
|
||||||
if chest_inventory.can_insert(stack) then
|
local filters = get_filters(logistics)
|
||||||
if chest.get_request_slot(index) ~= nil then
|
for _, filter in pairs(filters) do
|
||||||
local n = chest.get_request_slot(index)
|
if filter.value.name == name then
|
||||||
if n and n.name == name then
|
local inserted_count = chest_inventory.insert(stack)
|
||||||
local inserted_count = chest_inventory.insert(stack)
|
stack.count = stack.count - inserted_count
|
||||||
stack.count = stack.count - inserted_count
|
prepare_floaty_text(floaty_text_list, chest.surface, chest.position, name, inserted_count)
|
||||||
prepare_floaty_text(floaty_text_list, chest.surface, chest.position, name, inserted_count)
|
if stack.count <= 0 then
|
||||||
if stack.count <= 0 then
|
return chestnr
|
||||||
return chestnr
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -455,18 +463,15 @@ local function insert_item_into_chest(stack, chests, filtered_chests, name, floa
|
|||||||
for chestnr, chest in pairs(chests.chest) do
|
for chestnr, chest in pairs(chests.chest) do
|
||||||
if chest.type == 'logistic-container' then
|
if chest.type == 'logistic-container' then
|
||||||
local chest_inventory = chests.inventory[chestnr]
|
local chest_inventory = chests.inventory[chestnr]
|
||||||
for index = 1, chest.request_slot_count do
|
local logistics = chest.get_logistic_point(defines.logistic_member_index.logistic_container)
|
||||||
if chest_inventory.can_insert(stack) then
|
local filters = get_filters(logistics)
|
||||||
if chest.get_request_slot(index) ~= nil then
|
for _, filter in pairs(filters) do
|
||||||
local n = chest.get_request_slot(index)
|
if filter.value.name == name then
|
||||||
if n and n.name == name then
|
local inserted_count = chest_inventory.insert(stack)
|
||||||
local inserted_count = chest_inventory.insert(stack)
|
stack.count = stack.count - inserted_count
|
||||||
stack.count = stack.count - inserted_count
|
prepare_floaty_text(floaty_text_list, chest.surface, chest.position, name, inserted_count)
|
||||||
prepare_floaty_text(floaty_text_list, chest.surface, chest.position, name, inserted_count)
|
if stack.count <= 0 then
|
||||||
if stack.count <= 0 then
|
return chestnr
|
||||||
return chestnr
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user