Page 1 of 1

[MOD 0.17.x] Ammo-Loader

Posted: Sat May 05, 2018 6:10 am
by SilentCrim
potentialThumbnail3_large.png
potentialThumbnail3_large.png (35.93 KiB) Viewed 15689 times
Description:
Less turret logistics, more dead aliens. This mod adds chests to automatically fill turrets and vehicles with ammo/fuel.

Details:
  • Name: ammo-loader
  • Latest Release: 0.16.23, May 4, 2018
  • Factorio Version: 0.16
  • Download: Mod Portal
  • License: GNU GPL v3 with some graphical assets governed by the Creative Commons License
  • Tags: turret, load, ammo, auto, fuel, autofill, car
  • Author: SilentCrim
Long Description
Incompatibilities
Changelog
Attribution
Feel free to post any comments/suggestions/bug reports as a reply to this topic.

Re: [MOD 0.16] Ammo-Loader

Posted: Tue May 08, 2018 5:03 am
by Sir3n
I placed down a fuel loader chest, dropped some fuel in it and the game crashed with the following message:
Error while running event ammo-loader::on_tick (ID 0)
__ammo-loader__/lib/TrackedChest.lua:265: attempt to compare number with nil
The crash only happens when "Include burner structures" is enabled.

Re: [MOD 0.16] Ammo-Loader

Posted: Tue May 08, 2018 12:14 pm
by SilentCrim
Damn and I thought everything seemed pretty stable. Regardless, thanks for taking the time to report the bug.

I'll see if I can take a look at it when I get off work. Most likely there's a nil check missing before I check if an entity has a burner inventory.

Re: [MOD 0.16] Ammo-Loader

Posted: Wed May 09, 2018 8:50 am
by OhMods
That's the reason I had to keep the option off. Checked with burner crashes but not all the time. I started a vanilla game without my mods (minus creative to test) and if the check is on at game start it doesn't crash. Or at least not right away.

Also, I suppose it doesn't load Artillery Turrets? Probably make it too powerful.

Re: [MOD 0.16] Ammo-Loader

Posted: Wed May 16, 2018 2:14 am
by SilentCrim
I placed down a fuel loader chest, dropped some fuel in it and the game crashed with the following message:
Ok, there's a new version out that should hopefully fix the issue. I was never able to reproduce the problem on my end, but I think I identified the missing nil check, so hopefully that fixes things. Let me know if it doesn't work and we'll go from there.
Also, I suppose it doesn't load Artillery Turrets? Probably make it too powerful.
Something like that. On the other hand, I personally think the burner structures option is pretty powerful (especially with the AAI industries mod), so I don't see why I can't add an option for that if you want one. However, I created this mod before artillery wagons existed, so it might be extra busted with those in mind. Let me know if you want it and I'll try to add it in this weekend (the weekend is really the only time I have to work on it).

Re: [MOD 0.16] Ammo-Loader

Posted: Wed May 16, 2018 4:51 pm
by Sir3n
SilentCrim wrote:Ok, there's a new version out that should hopefully fix the issue. I was never able to reproduce the problem on my end, but I think I identified the missing nil check, so hopefully that fixes things. Let me know if it doesn't work and we'll go from there.
That crash doesn't happen anymore it seems. Thanks for the fix.

Re: [MOD 0.16] Ammo-Loader

Posted: Wed May 16, 2018 5:51 pm
by Sir3n
I found more bugs i think:

Bug 1:
If you set the "Max items per slot" to something bigger than the maximum stack size of the item and max items per inventory is uncapped, the fuel loader chest keeps deleting items from the game.

Steps to reproduce:
1) Start a fresh game.
2) Set "Max items per slot" to 100, have "Include burner structures" enabled, make sure "Max items per inventory" is set to 0.
3) Place down a Fuel Loader Chest. Fill it completely with coal
4) Place down a furnace.
5) Furnace gets filled up, but all your excess coal in the Loader chest disappears.

Bug 2:
Same problem happens with "Max items per inventory" too. If "Max items per inventory" is set to something bigger than the inventory can hold, and "max items per slot" is uncapped, the fuel chest basically just deletes items from the game.

1) Start a fresh game.
2) Set "Max items per inventory" to 1000, have "Include burner structures" enabled, make sure "Max items per slot" is set to 0.
3) Place down a Fuel Loader Chest. Fill it completely with coal
4) Place down tracks + locomotive.
5) Locomotive gets filled up, but all your excess coal in the Loader chest disappears.

Bug 3:
If "Include burner structures" is disabled, the Fuel loader chest does not fill up locomotives.
I'm not sure if this is expected behaviour or a bug, might as well report it just to make sure.

Re: [MOD 0.16] Ammo-Loader

Posted: Sat May 19, 2018 5:14 am
by SilentCrim
I found more bugs i think:
:D Awesome, I really appreciate your help with improving the mod. There is a new version out now that should address these issues.

Bug 1:
If you set the "Max items per slot" to something bigger than the maximum stack size of the item and max items per inventory is uncapped, the fuel loader chest keeps deleting items from the game.
Lol this made me facepalm. When I recently restructured the code, I took out the line that checked an item's stack size before inserting it. For whatever reason I remember thinking that it was redundant, but obviously it wasn't. Good catch.

Bug 2:
Same problem happens with "Max items per inventory" too. If "Max items per inventory" is set to something bigger than the inventory can hold, and "max items per slot" is uncapped, the fuel chest basically just deletes items from the game.
This was just an odd consequence of bug 1. The max items per inventory option actually doesn't do anything anymore; I stopped using it a while back because the calls to inventory.get_item_count() each tick were too expensive. This setting has been removed in the new version.

Bug 3:
If "Include burner structures" is disabled, the Fuel loader chest does not fill up locomotives.
I actually never intended for locomotives to be filled at all, but instead of taking this out I made it a separate option. You can now enable/disable filling locomotives in the mod options menu.

Also, I suppose it doesn't load Artillery Turrets? Probably make it too powerful.
There is now an option to enable/disable loading artillery.

Re: [MOD 0.16] Ammo-Loader

Posted: Wed Aug 15, 2018 3:26 am
by danieltudor94
I just encountered an error, its suspicious because factorio was the last program i ran last night and the first i started this morning,havent installed any mods to have an incompatibility and only modified the item stack from 5 to 15.

>>> Notice

Error while running deserialisation for mod-ammo-loader: [string "do local_={ammo_loader={},created_queue={fir..."]:1: function or expression too complex near 'nil' <<<

Untitled.png
Untitled.png (1.36 MiB) Viewed 15063 times
:(

Re: [MOD 0.16] Ammo-Loader

Posted: Sun Sep 02, 2018 3:51 am
by SilentCrim
That's a strange one. It's probably due to the way the mod handles the global table disagreeing with Factorio's savegame serialization.

I just released a new version that's a much cleaner rewrite, so I would try upgrading first to see if that helps.

Re: [MOD 0.16] Ammo-Loader

Posted: Sun Sep 02, 2018 5:51 am
by komodo99
I've just added this mod to my current save, or at least attempted to. I am getting an error on save load that is as follows.

Code: Select all

Error while applying migration: Ammo Loader+:v16_23.lua

__ammo-loader__/migrations/v16_23.lua:5:attempt to index field 'ammo-loader-tech-ammo1' (a nil value)
I suspect it is trying to migrate something that doesn't exist as it has just been added, but I have not delved too deeply into it.

Re: [MOD 0.16] Ammo-Loader

Posted: Sun Sep 02, 2018 7:47 am
by danieltudor94
komodo99 wrote:I've just added this mod to my current save, or at least attempted to. I am getting an error on save load that is as follows.

Code: Select all

Error while applying migration: Ammo Loader+:v16_23.lua

__ammo-loader__/migrations/v16_23.lua:5:attempt to index field 'ammo-loader-tech-ammo1' (a nil value)
I suspect it is trying to migrate something that doesn't exist as it has just been added, but I have not delved too deeply into it.

Im getting the error too :/

Re: [MOD 0.16] Ammo-Loader

Posted: Sun Sep 02, 2018 2:59 pm
by SilentCrim
komodo99 wrote:I've just added this mod to my current save, or at least attempted to. I am getting an error on save load that is as follows.

Code: Select all

Error while applying migration: Ammo Loader+:v16_23.lua

__ammo-loader__/migrations/v16_23.lua:5:attempt to index field 'ammo-loader-tech-ammo1' (a nil value)
I suspect it is trying to migrate something that doesn't exist as it has just been added, but I have not delved too deeply into it.
I just released a new version (0.16.29) that should fix this issue.

Re: [MOD 0.16] Ammo-Loader

Posted: Wed Sep 05, 2018 3:03 am
by komodo99
Aside from some debugging printing when a related research finishes, working well here. Thanks much!

Re: [MOD 0.16] Ammo-Loader

Posted: Mon Apr 22, 2019 12:36 pm
by luc
I can't use this mod in 0.17 anymore: it causes my game to try to use >10GB of memory when loading the map (and RAM is still more expensive today than it was in 2016, so I didn't upgrade to 16GB yet). Without this mod, it uses about 5.5GB.

Re: [MOD 0.16] Ammo-Loader

Posted: Mon Apr 22, 2019 12:50 pm
by SilentCrim
Hm yeah I've noticed really long load times in 0.17 as well, but only when updating/changing mods. After saving the first time loading goes back to normal.

I'll take another look but I have yet to see what's causing the issue. Unfortunately I'm tied up this week and don't have much time to work on it. Still thanks for letting me know about the problem.