1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-02-03 13:12:11 +02:00

Merge pull request #147 from ComfyFactory/mtn_v3_icw

Mtn v3 - ICW fix weird bug
This commit is contained in:
Gerkiz 2021-11-01 16:48:08 +01:00 committed by GitHub
commit 737e09d2f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -180,17 +180,19 @@ local function input_filtered(wagon_inventory, chest, chest_inventory, free_slot
request_stacks[stack.name] = 10 * prototypes[stack.name].stack_size request_stacks[stack.name] = 10 * prototypes[stack.name].stack_size
end end
end end
for i = 1, wagon_inventory.get_bar() - 1, 1 do if wagon_inventory.supports_bar() then
if free_slots <= 0 then for i = 1, wagon_inventory.get_bar() - 1, 1 do
return if free_slots <= 0 then
end return
local stack = wagon_inventory[i] end
if stack.valid_for_read then local stack = wagon_inventory[i]
local request_stack = request_stacks[stack.name] if stack.valid_for_read then
if request_stack and request_stack > chest_inventory.get_item_count(stack.name) then local request_stack = request_stacks[stack.name]
chest_inventory.insert(stack) if request_stack and request_stack > chest_inventory.get_item_count(stack.name) then
stack.clear() chest_inventory.insert(stack)
free_slots = free_slots - 1 stack.clear()
free_slots = free_slots - 1
end
end end
end end
end end
@ -303,9 +305,11 @@ local function input_cargo(wagon, chest)
local chest_inventory = chest.get_inventory(defines.inventory.chest) local chest_inventory = chest.get_inventory(defines.inventory.chest)
local free_slots = 0 local free_slots = 0
for i = 1, chest_inventory.get_bar() - 1, 1 do if chest_inventory.supports_bar() then
if not chest_inventory[i].valid_for_read then for i = 1, chest_inventory.get_bar() - 1, 1 do
free_slots = free_slots + 1 if not chest_inventory[i].valid_for_read then
free_slots = free_slots + 1
end
end end
end end
@ -314,14 +318,16 @@ local function input_cargo(wagon, chest)
goto continue goto continue
end end
for i = 1, wagon_inventory.get_bar() - 1, 1 do if wagon_inventory.supports_bar() then
if free_slots <= 0 then for i = 1, wagon_inventory.get_bar() - 1, 1 do
goto continue if free_slots <= 0 then
end goto continue
if wagon_inventory[i].valid_for_read then end
chest_inventory.insert(wagon_inventory[i]) if wagon_inventory[i].valid_for_read then
wagon_inventory[i].clear() chest_inventory.insert(wagon_inventory[i])
free_slots = free_slots - 1 wagon_inventory[i].clear()
free_slots = free_slots - 1
end
end end
end end