[MOD 0.17 - 1.1] Picklocks Inserter

Topics and discussion about specific mods
Post Reply
User avatar
picklock
Fast Inserter
Fast Inserter
Posts: 138
Joined: Sat Nov 09, 2019 6:49 am
Contact:

[MOD 0.17 - 1.1] Picklocks Inserter

Post 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
Last edited by picklock on Thu Mar 07, 2024 6:07 pm, edited 17 times in total.
My Mods: Picklocks Fusion Power | Picklocks Inserter | Picklocks Lithium Polymer Accumulator | Picklocks rocket silo stats | Picklocks Set Inventory Filters

User avatar
picklock
Fast Inserter
Fast Inserter
Posts: 138
Joined: Sat Nov 09, 2019 6:49 am
Contact:

Re: [MOD 0.17] Picklocks Inserter

Post 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.
My Mods: Picklocks Fusion Power | Picklocks Inserter | Picklocks Lithium Polymer Accumulator | Picklocks rocket silo stats | Picklocks Set Inventory Filters

PyroFire
Filter Inserter
Filter Inserter
Posts: 356
Joined: Tue Mar 08, 2016 8:18 am
Contact:

Re: [MOD 0.17] Picklocks Inserter

Post 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 :(

Bilka
Factorio Staff
Factorio Staff
Posts: 3128
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: [MOD 0.17] Picklocks Inserter

Post 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
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

User avatar
picklock
Fast Inserter
Fast Inserter
Posts: 138
Joined: Sat Nov 09, 2019 6:49 am
Contact:

Re: [MOD 0.17] Picklocks Inserter

Post 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.
My Mods: Picklocks Fusion Power | Picklocks Inserter | Picklocks Lithium Polymer Accumulator | Picklocks rocket silo stats | Picklocks Set Inventory Filters

User avatar
picklock
Fast Inserter
Fast Inserter
Posts: 138
Joined: Sat Nov 09, 2019 6:49 am
Contact:

Re: [MOD 0.17] Picklocks Inserter

Post by picklock »

Updated mod for game version 0.18 with V1.18.0.
Last edited by picklock on Wed Aug 26, 2020 8:15 am, edited 1 time in total.
My Mods: Picklocks Fusion Power | Picklocks Inserter | Picklocks Lithium Polymer Accumulator | Picklocks rocket silo stats | Picklocks Set Inventory Filters

User avatar
picklock
Fast Inserter
Fast Inserter
Posts: 138
Joined: Sat Nov 09, 2019 6:49 am
Contact:

Re: [MOD 0.17 - 0.18] Picklocks Inserter

Post 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.
My Mods: Picklocks Fusion Power | Picklocks Inserter | Picklocks Lithium Polymer Accumulator | Picklocks rocket silo stats | Picklocks Set Inventory Filters

User avatar
picklock
Fast Inserter
Fast Inserter
Posts: 138
Joined: Sat Nov 09, 2019 6:49 am
Contact:

Re: [MOD 0.17 - 1.0] Picklocks Inserter

Post by picklock »

Updated mod for game version 1.0 with V1.18.2.
My Mods: Picklocks Fusion Power | Picklocks Inserter | Picklocks Lithium Polymer Accumulator | Picklocks rocket silo stats | Picklocks Set Inventory Filters

User avatar
Yuri
Manual Inserter
Manual Inserter
Posts: 2
Joined: Sat May 06, 2017 6:40 am
Contact:

Desync cause

Post 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 5264 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

User avatar
picklock
Fast Inserter
Fast Inserter
Posts: 138
Joined: Sat Nov 09, 2019 6:49 am
Contact:

Re: [MOD 0.17 - 1.0] Picklocks Inserter

Post 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.
My Mods: Picklocks Fusion Power | Picklocks Inserter | Picklocks Lithium Polymer Accumulator | Picklocks rocket silo stats | Picklocks Set Inventory Filters

PyroFire
Filter Inserter
Filter Inserter
Posts: 356
Joined: Tue Mar 08, 2016 8:18 am
Contact:

Re: [MOD 0.17 - 1.0] Picklocks Inserter

Post 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.

User avatar
picklock
Fast Inserter
Fast Inserter
Posts: 138
Joined: Sat Nov 09, 2019 6:49 am
Contact:

Re: [MOD 0.17 - 1.0] Picklocks Inserter

Post 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?
My Mods: Picklocks Fusion Power | Picklocks Inserter | Picklocks Lithium Polymer Accumulator | Picklocks rocket silo stats | Picklocks Set Inventory Filters

User avatar
picklock
Fast Inserter
Fast Inserter
Posts: 138
Joined: Sat Nov 09, 2019 6:49 am
Contact:

[MOD 1.1] Picklocks Inserter

Post by picklock »

Updated mod for game version 1.1 and made some minor internal changes with V1.110.0.

See start post for details.
Last edited by picklock on Sat Dec 05, 2020 8:22 pm, edited 1 time in total.
My Mods: Picklocks Fusion Power | Picklocks Inserter | Picklocks Lithium Polymer Accumulator | Picklocks rocket silo stats | Picklocks Set Inventory Filters

User avatar
picklock
Fast Inserter
Fast Inserter
Posts: 138
Joined: Sat Nov 09, 2019 6:49 am
Contact:

[MOD 1.0 - 1.1] Picklocks Inserter

Post 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
Last edited by picklock on Sat Dec 05, 2020 8:22 pm, edited 1 time in total.
My Mods: Picklocks Fusion Power | Picklocks Inserter | Picklocks Lithium Polymer Accumulator | Picklocks rocket silo stats | Picklocks Set Inventory Filters

User avatar
picklock
Fast Inserter
Fast Inserter
Posts: 138
Joined: Sat Nov 09, 2019 6:49 am
Contact:

[MOD 1.0 - 1.1] Picklocks Inserter

Post 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
My Mods: Picklocks Fusion Power | Picklocks Inserter | Picklocks Lithium Polymer Accumulator | Picklocks rocket silo stats | Picklocks Set Inventory Filters

User avatar
picklock
Fast Inserter
Fast Inserter
Posts: 138
Joined: Sat Nov 09, 2019 6:49 am
Contact:

Re: [MOD 0.17 - 1.1] Picklocks Inserter

Post 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
My Mods: Picklocks Fusion Power | Picklocks Inserter | Picklocks Lithium Polymer Accumulator | Picklocks rocket silo stats | Picklocks Set Inventory Filters

User avatar
picklock
Fast Inserter
Fast Inserter
Posts: 138
Joined: Sat Nov 09, 2019 6:49 am
Contact:

Re: [MOD 1.1] Picklocks Inserter

Post 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.
My Mods: Picklocks Fusion Power | Picklocks Inserter | Picklocks Lithium Polymer Accumulator | Picklocks rocket silo stats | Picklocks Set Inventory Filters

User avatar
picklock
Fast Inserter
Fast Inserter
Posts: 138
Joined: Sat Nov 09, 2019 6:49 am
Contact:

Re: [MOD 1.1] Picklocks Inserter

Post 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.
My Mods: Picklocks Fusion Power | Picklocks Inserter | Picklocks Lithium Polymer Accumulator | Picklocks rocket silo stats | Picklocks Set Inventory Filters

User avatar
picklock
Fast Inserter
Fast Inserter
Posts: 138
Joined: Sat Nov 09, 2019 6:49 am
Contact:

Re: [MOD 1.1] Picklocks Inserter

Post 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.
My Mods: Picklocks Fusion Power | Picklocks Inserter | Picklocks Lithium Polymer Accumulator | Picklocks rocket silo stats | Picklocks Set Inventory Filters

User avatar
picklock
Fast Inserter
Fast Inserter
Posts: 138
Joined: Sat Nov 09, 2019 6:49 am
Contact:

Re: [MOD 1.1] Picklocks Inserter

Post 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.
My Mods: Picklocks Fusion Power | Picklocks Inserter | Picklocks Lithium Polymer Accumulator | Picklocks rocket silo stats | Picklocks Set Inventory Filters

Post Reply

Return to “Mods”