Keep Organized

by Thaui

Quickbar keep organized when slots filter are set.

Utilities
6 years ago
0.16
5

b Slows game to a crawl when enabled on an existing save

6 years ago
(updated 6 years ago)

I tried adding this to my world because it sounded really helpful. But I had to disable it immediately as it had slowed my game to a crawl. Is this a temporary thing as it's indexing or could this be a bug?

Tested in Factorio v0.16.24

6 years ago

Opening the file control.lua and changing the line 2 to (ignore the square brackets):

[if from.valid_for_read and ((not to.valid_for_read) or (to.name == from.name and to.count < to.prototype.stack_size)) then]

Seems to have fixed the lag in my game.

6 years ago
(updated 6 years ago)

I am new to lua modding, but my guess to the issue is that when [on_player_inventory_changed] gets called and you have a filtered slot in the quickbar that is partially filled, the function [transfer_stack(from,to)] tries to fill that slot by calling [to.transfer_stack(from)].

[to.transfer_stack(from)] would try to move every item in every nonempty slot in the inventory into the filtered slot, and registers [on_player_quickbar_inventory_changed] and [on_player_main_inventory_changed], both of which calls [on_player_inventory_changed].

But if you have no more of the item in the inventory to fill the filtered slot, [to.transfer_stack(from)] will just keep trying to move item A into the slot filtered with item B, and it would not be successful, and you would be stuck in a loop calling [on_player_inventory_changed] over and over.

I think my fix works by adding a check to stop calling [to.transfer_stack(from)] to try to move item A into a slot filtered with item B, so the game won't fall in the loop.

6 years ago

Also changing line 49 [transfer_stack(providing[i], inventory[j])] to:

if providing[i].valid_for_read then
transfer_stack(providing[i], inventory[j])
else
break
end

Seems to make it run slightly faster by exiting a loop early in some cases, but it might just be placebo effect on me.
Hope Thaui won't be angry at me pasting modified codes here =w= .

6 years ago
(updated 6 years ago)

There is no problem in helping improving the code, unfortunately I can't update today, but wednesday I can do it.

The fact is that the mod trigger itself an inventory update which makes the mods processing it and triggering itself again in a loop, I need for that to make sure that for each transfer, some conditions are verified so only real transfer (not the null ones) are done

6 years ago
(updated 6 years ago)

AMCH0507, thanks for the propositions but the first one really help a lot, but the secondary can't be used as proposed since it would make the mod not working properly and since the mod don't run again in a loop, it's like a placebo effect. I've updated the mod with an added debug setting if this problem is still here, you can see every operation the mod does.

6 years ago

Well thank you Thaui for making and updating the mod. I wished to have something like this before, but I am not good enough with lua to make it myself. Your code helped me understanding it a lot.

6 years ago

Well in fact I wish the devs put this in base game.

6 years ago

I think they should =w=

New response