Page 1 of 1

[MOD 0.17 - 1.1] Picklocks Inserter

Posted: Sun Dec 22, 2019 4:18 pm
by picklock
Type: Mod
Name: Picklocks Inserter
Description: This mod prevents Inserters to get stuck holding Items.
License: GNU GPLv3
Version: 1.110.7
Release: 07.03.2024
Tested with-Factorio-version: 1.1.104
Download: mods.factorio.com
Download-Url: https://mods.factorio.com/mod/Picks-Inserter
Category: Utility
Tags: Utility, Inserters, Train, Cargo wagon
Website: viewtopic.php?f=190&t=79205

Introduction
If an inserter is not able to place items at the target then this mod prevents the Inserter to get stuck holding these items.
  • tems will be put back to where they were picked up.
  • If this is not possible and the option is activated then the items will be destroyed.
+++++++
License
+++++++
Long Description - Story
+++++++
Known Issues
+++++++
Abbreviated changelog
+++++++
Inspiration

Re: [MOD 0.17] Picklocks Inserter

Posted: Wed Dec 25, 2019 7:36 pm
by picklock
Added the following reportet issues to start post.
  • When crafting something it will cycle each item through your hand (cursor).
  • Anything you craft is automatically duplicated, producing 2 of the crafted item.
I will have a look at it and if possible will fix it as soon as possible.

Re: [MOD 0.17] Picklocks Inserter

Posted: Wed Dec 25, 2019 11:17 pm
by PyroFire
found a typo; "if debug then"... always returns true, debug is a special lua library / keyword.
This appears twice in your control.lua
https://www.lua.org/pil/23.html

Also, why do you need to hook on_player_crafted_item at all?
It seems you are doing this just to be buggy for the sake of being buggy.
There is no apparent gain for hooking this event or taking any actions in it.
Though another typo, coincidentally in said on_player_crafted_item, is that you're checking if(cursor_stack.can_set_stack)then.
That is a function, and therefore your condition will always return true because you're just checking if the function exists.
Calling it without args also only returns true if you can clear the cursor stack.
You should be using cursor_stack.can_set_stack(event.item_stack).
Secondly, you're placing a copy of the crafted item in the cursor.. why?
Basically all of those problems can be avoided by .. not hooking on_player_crafted_item for literally no reason.

Aside from that (and the fact that there's probably a few more typos similar to above), seems like the only real way to fix the problem.
But damn that's expensive doing it 25 times per tick. 10 maybe better.... but some bases can have literal thousands of inserters.

This may be better of simply being fixed in a mod than being worked around in a mod.
viewtopic.php?f=29&t=74900

Though... if you're looking for another thing to hotfix with a mod like this...
Did you know that you actually lose the ingredients of a recipe in a machine if you pick it up while it is crafting?
They vanish without a trace :(

Re: [MOD 0.17] Picklocks Inserter

Posted: Thu Dec 26, 2019 7:09 am
by Bilka
PyroFire wrote:
Wed Dec 25, 2019 11:17 pm
Though... if you're looking for another thing to hotfix with a mod like this...
Did you know that you actually lose the ingredients of a recipe in a machine if you pick it up while it is crafting?
They vanish without a trace :(
https://mods.factorio.com/mod/Dont_lose ... ngredients

Re: [MOD 0.17] Picklocks Inserter

Posted: Thu Dec 26, 2019 2:04 pm
by picklock
Fixed the reported issues with V1.0.1. See start post for details.

@PyroFire :
Thanks for your Post.
You were right, I didn’t need the event on_player_crafted_item. I do not use it anymore. This was a part of fixing the reported issues and avoids other misbehaviours.
As well as I did not have any performance issues testing my mod with my big base, I agree with you, that cleaning 25 inserters per tick is expensive and might generate performance issues. Therefore, I followed your suggestion and reduced the default setting for cleaning per tick to 10.
In my opinion my mod is not intended to clean all inserters of a base permanently. You mark only the inserters you want to clean or you activate the cleaning at train stops. So, even if there are thousands of inserters in a base only a few will be cleaned.

Re: [MOD 0.17] Picklocks Inserter

Posted: Wed Jan 22, 2020 12:17 pm
by picklock
Updated mod for game version 0.18 with V1.18.0.

Re: [MOD 0.17 - 0.18] Picklocks Inserter

Posted: Mon Feb 17, 2020 6:31 pm
by picklock
Released V1.18.1:
Due to performance reasons added a delay of 120 ticks for inserters marked by cleanup planer before it will be cleared again after it was successful cleared.

Re: [MOD 0.17 - 1.0] Picklocks Inserter

Posted: Wed Aug 26, 2020 8:14 am
by picklock
Updated mod for game version 1.0 with V1.18.2.

Desync cause

Posted: Thu Oct 22, 2020 1:33 am
by Yuri
My server has been plagued by desyncs lately and this mod appears to be the primary suspect. The scripts.dat files have several instances of desynced values related to it. The desync logs will sometimes have other mods but almost always this one.
Capture.PNG
Capture.PNG (72.43 KiB) Viewed 5372 times
Edit: Did some more testing and confirmed that this mod is the culprit. Loaded from an autosave and player desynced at the same time every time until the mod was removed and then it stopped happening.
If there's any reports or anything you need me to provide to debug I'll gladly help

Re: [MOD 0.17 - 1.0] Picklocks Inserter

Posted: Thu Oct 22, 2020 5:57 am
by picklock
Hello Yuri,

Thank you for the report.
I will have a look at it. If I need any further information I will contact you.

Edit:
I was not able to reproduce the issue with my testing enviroment. I sent Yuri a PM.

Edit 2:
Investigating of the issue ongoing.

Re: [MOD 0.17 - 1.0] Picklocks Inserter

Posted: Wed Nov 04, 2020 1:45 pm
by PyroFire
picklock wrote:
Thu Oct 22, 2020 5:57 am
stuff
My guess is your cleaning loop isn't happening in a predictable order.
I.e. you're using a local variable instead of a global to save/pause/resume the inserter scanner at different "positions" in the table, thus resulting in a desync when items are removed from different inserters for different people at different times.
I haven't checked it but this would be a common desync with this kind of code.

Re: [MOD 0.17 - 1.0] Picklocks Inserter

Posted: Thu Nov 05, 2020 11:54 am
by picklock
First of all, I want to thank PyroFire for the reply and the guess.

In the last days I did a lot of testing. The desync occurs only with the map from Yuri. I tested also with two more maps, also with several hundreds of hours played and one of them also heavy modded and with these maps there was no desync.

The desync in Yuris map happens with the following line of code:

Code: Select all

stack.count = stack.count - entity.insert(stack)
The desync occurs also when the variable that stores the inserter information is set to global as mentioned by PyroFire.

As the desync only occurs with Yuris map I assume that there is one of the over 90 Mods from the map not compatible with my mod or there is a problem with the map itself. Why the issue occurs after more the 300 hours of playtime is a strange behavior for me.

Does anyone has an idea why there is a desync with the code line above other than my assumption?

[MOD 1.1] Picklocks Inserter

Posted: Mon Nov 23, 2020 10:22 pm
by picklock
Updated mod for game version 1.1 and made some minor internal changes with V1.110.0.

See start post for details.

[MOD 1.0 - 1.1] Picklocks Inserter

Posted: Mon Nov 30, 2020 2:39 pm
by picklock
Fixed mulitplayer desync related to imserters selected with the inserter cleanup planner.

See startpost for details.

Please be aware that there are different versions for Factorio V1.0 and Factorio V1.1.
  • For Factorio V 1.0 use mod version 1.100.1
  • For Factorio V 1.1 use mod version 1.110.1

[MOD 1.0 - 1.1] Picklocks Inserter

Posted: Sat Dec 05, 2020 8:21 pm
by picklock
Fixed a bug that after loading a game, a mark was not deleted if the associated inserter was destroyed.

See startpost for details.

Please be aware that there are different versions for Factorio V1.0 and Factorio V1.1.
  • For Factorio V 1.0 use mod version 1.100.2
  • For Factorio V 1.1 use mod version 1.110.2

Re: [MOD 0.17 - 1.1] Picklocks Inserter

Posted: Sun Dec 06, 2020 3:16 pm
by picklock
Fixed a non-recoverable error occouring in some circumstates when starting a new game or loading a savegame.

See startpost for details.

Please be aware that there are different versions for Factorio V1.0 and Factorio V1.1.
  • For Factorio V 1.0 use mod version 1.100.3
  • For Factorio V 1.1 use mod version 1.110.3

Re: [MOD 1.1] Picklocks Inserter

Posted: Wed Feb 03, 2021 10:39 am
by picklock
Update V1.110.4 for Factorio V1.1:
- Fixed a bug that prevented the cleaning of the inserters if the train was in the "destination_full" status after leaving the station.
- Fixed a bug that prevented the cleaning of the inserters if the train was in the "wait_signal" status after leaving the station.

See start post for details.

Re: [MOD 1.1] Picklocks Inserter

Posted: Tue Feb 07, 2023 2:34 pm
by picklock
Update V1.110.5 for Factorio V1.1:
- Added cargo-wagon as target for set back (applies only to inserter cleanup planner).

Added cargo-wagon as additional target for set back. This works only with the inserter cleanup planner an not with the setting clean up inserters at train stops

See start post for details.

Re: [MOD 1.1] Picklocks Inserter

Posted: Wed Mar 01, 2023 12:30 pm
by picklock
Update V1.110.6 for Factorio V1.1:
- Fixed a bug causing a non-recoverable error with the event on_runtime_mod_setting_changed.

See start post for details.

Re: [MOD 1.1] Picklocks Inserter

Posted: Thu Mar 07, 2024 6:04 pm
by picklock
Update V1.110.7 for Factorio V1.1:
Date: 07.03.2024
Bugfixes:
- Fixes a bug causing a non-recoverable error on the client and the server when a player joins a headless server.
Optimisations:
- For performance reasons, the maximum number of inserters that can be cleaned per tick has been reduced from 120 to 30.
Locale:
- Updated and tweaked language files.

See start post for details.