[MOD 0.16] Ammo-Loader

Topics and discussion about specific mods

[MOD 0.16] Ammo-Loader

Postby SilentCrim » Sat May 05, 2018 6:10 am

potentialThumbnail3_large.png
potentialThumbnail3_large.png (35.93 KiB) Viewed 556 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
2018-05-05-1048-51.gif
2018-05-05-1048-51.gif (4.39 MiB) Viewed 533 times

This mod provides 2 new entities: the Ammo Loader Chest and Fuel Loader Chest. These entities load Ammo and Fuel respectively into entities that need them.

Ammo Loader
  • Will load ammo-turrets and weapon-mounted vehicles with its contents.
  • Simply put ammo inside the chest and it will do the rest.
  • Optionally upgrades ammo making ammunition technology transitions a piece of cake.
  • Customizable effective radius: give yourself a challenge or have chests fill turrets from across the map.

Fuel Loader
  • Will load vehicles with fuel.
  • Optionally load burner structures as well (burner inserter, AAI Industries burner buildings, etc.).
  • Allows you to explore the map without worrying about having fuel for your vehicles.


Incompatibilities
TL;DR:
Should function with all other mods, though may not support all custom turrets/vehicles/structures.

Long Answer:
This mod works by checking for compatible inventories of every placed entity and tracking them internally when found. This approach allows the mod to scale reasonably well to larger factories, but does have some disadvantages. Namely, this algorithm assumes that:
  1. All relevant entities can be identified immediately upon being placed, and
  2. Entities of a certain type can always be identified in the same way.
What this means for compatibility is that mods whose entities do not follow these rules will most likely not be compatible. Some examples are:
  1. Mods that destroy/replace entities programmatically after they are placed.
  2. Mods with prototypes that have an unconventional structure (i.e. a turret that uses a separate chest as its source of ammo, rather than a built-in inventory).
For the most part, incompatibility will not cause any game-breaking issues; incompatible mods will simply be invisible to the Ammo or Fuel Loader Chests. Occasionally incompatibilities will cause a crash, but I try to fix these cases as quickly as possible.


Changelog
Version: 0.16.21
Date: 29. 04. 2018
Bugfixes:
  • Fixed bug causing crash on load.


Version: 0.16.20
Date: 29. 04. 2018
Bugfixes:
  • Fixed infinite ammo bug.
  • Improved compatibility with some mods.
  • Code cleanup to reduce spaghetti.
Changes:
  • Implemented distance restriction on chests (accessible in mod options, defaults to zero).
  • Added Fuel Loader Chest into the game, separating chests that load ammo from those that load fuel.
  • Restructured data models to make quote easier to understand.
  • Revised main looping algorithm, resulting in more steady performance.
  • Revised ammo upgrade algorithm, greatly reducing the number of turrets that fail to get the best ammo.
  • New icons.


Version: 0.16.19
Date: 10. 02. 2018
Changes:
  • Performance update, approx. ~30% improvement (on my personal machine).


Version: 0.16.18
Date: 10. 02. 2018
Bugfixes:
  • fixed chests would stop working after load game.


Version: 0.16.17
Date: 04. 02. 2018
Bugfixes:
  • fixed turret would stop being loaded if ammo was taken out by player.


Version: 0.16.16
Date: 04. 02. 2018
Bugfixes:
  • fixed crash when starting new game.


Version: 0.16.15
Date: 04. 02. 2018
Changes:
  • added "finished" queue for turrets that are already full of the best ammo, roughly ~50% performance increase when there are lots of gun turrets (500+).
  • added setting to control the number of new entities that will be scanned per tick when placing large blueprints, etc.
  • added explanations to all settings.
  • set min/max values for integer settings.
Bugfixes:
  • fixed locale file so settings will be named properly.


Version: 0.16.14
Date: 05. 01. 2018
Changes:
  • added limit to number of entities that can be added per tick (50 at the moment) for performance issues with blueprints.
Bugfixes:
  • fixed bug where turrets already on map when mod was installed not being recognized.
  • added check to remove invalid items when mods change.


Version: 0.16.13
Date: 04. 1. 2018
Changes:
  • made ammo loader chest available from the start of the game, since it's actually useless before turret research anyway.


Version: 0.16.12
Date: 03. 01. 2018
Bugfixes:
  • small bugfix for crash due to incorrect file name.


Version: 0.16.11
Date: 02. 01. 2018
Changes:
  • update to factorio v16
  • rewritten once again.
  • performance improvements.
  • add support for vehicles with multiple guns.
  • hopefully improved compatibility.


Version: 0.15.10
Date: 22. 08. 2017
Changes:
  • empty inventories will now be loaded first, this may come at a cost to performance, so please let me know if you have any issues.
  • improved support for aai programmable vehicles mod, multiple bugs that occurred when using this mod should be fixed.
Bugfixes:
  • fixed recipe not becoming available when mod was added to game in progress.


Version: 0.15.9
Date: 21. 08. 2017
Changes:
  • update to factorio v15.
  • rewritten from the ground up, performance should now be stable regardless of the amount of chests/turrets.
  • should now be multiplayer compatible.
  • options now available through menu.
Bugfixes:
  • fixed entity sprite selection offset.


Version: 0.14.8
Date: 29. 03. 2017
Bugfixes:
  • fixed a bug where picking up chests would cause a crash.


Version: 0.14.7
Date: 28. 03. 2017
Changes:
  • added support for loading fuel into vehicles.
  • more optimizations that will hopefully improve performance when the number of turrets gets very high.
Bugfixes:
  • fixed a bug with some vehicle mods where new vehicles were taking too long to start receiving ammo and fuel.


Version: 0.14.6
Date: 27. 03. 2017
Changes:
  • changed how main loop iterates chests and turrets.
Bugfixes:
  • fixed several bugs causing program to "stick" to one turret if specific conditions were met, as a result, should be fully compatible with bob's mods (tested with bob's+additional+predictabowl) and more compatible with others.


Version: 0.14.5
Date: 26. 03. 2017
Bugfixes:
  • temporary fix for compatibility with some mods.
  • Added ignore list to config.


Version: 0.14.4
Date: 25. 03. 2017
Bugfixes:
  • fixed bug causing crash when lists were not properly purged of invalid entities.


Version: 0.14.3
Date: 24. 03. 2017
Changes:
  • included several optimizations that should increase performace.
  • max_rounds_per_stack and upgrades are now both configurable by individual ammo type, see config for more info, by default it is set to upgrade firearm mags with piercing and cannon shells with explosive cannon shells.
  • Support for vehicles added, fully tested with aai-programmable-vehicles suite, should work with any modded vehicles that use defines,inventory,car_ammo
  • added config options max_turrets_per_cycle and max_chests_per_cycle, Leaving these both at 1 greatly improves performance at the cost of insertion speed, bumped max_ammo_per_turret up to 5 to compensate.


Version: 0.14.2
Date: 23. 03. 2017
Changes:
  • added option to limit max ammo in a single turret.
  • Moved editable variables to config file.


Version: 0.14.1
Date: 22. 03. 2017
Changes:
  • first release.


Attribution
The graphics in this mod are a combination of base game graphics and other custom graphics that are not my own work. These custom graphics are published under the Creative Commons License and here I credit the authors with their work. They include:

  1. Author: Madebyoliver | Website: Flaticon | License: Creative Commons BY 3.0
  2. Author: Treasure | Website: Flaticon | License: Creative Commons BY 3.0
  3. Author: Iconnice | Website: Flaticon | License: Creative Commons BY 3.0
  4. Author: Freepik | Website: Flaticon | License: Creative Commons BY 3.0
  5. Author: money | Website: Flaticon | License: Creative Commons BY 3.0
  6. Author: money | Website: Flaticon | License: Creative Commons BY 3.0
  7. Author: Bullet | Website: Flaticon | License: Creative Commons BY 3.0
  8. Author: Freepik | Website: Flaticon | License: Creative Commons BY 3.0
  9. Author: money | Website: Flaticon | License: Creative Commons BY 3.0
  10. Author: money | Website: Flaticon | License: Creative Commons BY 3.0
  11. Author: book | Website: Flaticon | License: Creative Commons BY 3.0
  12. Author: weapons | Website: Flaticon | License: Creative Commons BY 3.0
  13. Author: security | Website: Flaticon | License: Creative Commons BY 3.0
  14. Author: security | Website: Flaticon | License: Creative Commons BY 3.0
  15. Author: security | Website: Flaticon | License: Creative Commons BY 3.0
  16. Author: security | Website: Flaticon | License: Creative Commons BY 3.0
  17. Author: security | Website: Flaticon | License: Creative Commons BY 3.0
  18. Author: security | Website: Flaticon | License: Creative Commons BY 3.0
  19. Author: Closet | Website: Flaticon | License: Creative Commons BY 3.0
  20. Author: sports | Website: Flaticon | License: Creative Commons BY 3.0
  21. Author: sports | Website: Flaticon | License: Creative Commons BY 3.0
  22. Author: Ammo | Website: Flaticon | License: Creative Commons BY 3.0
  23. Author: Bullets | Website: Flaticon | License: Creative Commons BY 3.0
  24. Author: money | Website: Flaticon | License: Creative Commons BY 3.0


Feel free to post any comments/suggestions/bug reports as a reply to this topic.
ImageImage
SilentCrim
Burner Inserter
Burner Inserter
 
Posts: 12
Joined: Sun Apr 09, 2017 10:56 pm

Re: [MOD 0.16] Ammo-Loader

Postby Sir3n » Tue May 08, 2018 5:03 am

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.
Sir3n
Inserter
Inserter
 
Posts: 26
Joined: Tue Apr 03, 2018 11:35 pm

Re: [MOD 0.16] Ammo-Loader

Postby SilentCrim » Tue May 08, 2018 12:14 pm

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.
ImageImage
SilentCrim
Burner Inserter
Burner Inserter
 
Posts: 12
Joined: Sun Apr 09, 2017 10:56 pm

Re: [MOD 0.16] Ammo-Loader

Postby OhMods » Wed May 09, 2018 8:50 am

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.
OhMods
Manual Inserter
Manual Inserter
 
Posts: 2
Joined: Fri Jun 09, 2017 7:48 am

Re: [MOD 0.16] Ammo-Loader

Postby SilentCrim » Wed May 16, 2018 2:14 am

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).
ImageImage
SilentCrim
Burner Inserter
Burner Inserter
 
Posts: 12
Joined: Sun Apr 09, 2017 10:56 pm

Re: [MOD 0.16] Ammo-Loader

Postby Sir3n » Wed May 16, 2018 4:51 pm

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.
Last edited by Sir3n on Wed May 16, 2018 5:51 pm, edited 1 time in total.
Sir3n
Inserter
Inserter
 
Posts: 26
Joined: Tue Apr 03, 2018 11:35 pm

Re: [MOD 0.16] Ammo-Loader

Postby Sir3n » Wed May 16, 2018 5:51 pm

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.
Sir3n
Inserter
Inserter
 
Posts: 26
Joined: Tue Apr 03, 2018 11:35 pm

Re: [MOD 0.16] Ammo-Loader

Postby SilentCrim » Sat May 19, 2018 5:14 am

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.
ImageImage
SilentCrim
Burner Inserter
Burner Inserter
 
Posts: 12
Joined: Sun Apr 09, 2017 10:56 pm


Return to Mods

Who is online

Users browsing this forum: No registered users and 7 guests