Automated Fuel & Ammo

by folk

Most likely automatically fills in things properly, probably. Preferrably both fuel and ammunition, if possible.

Utilities
6 years ago
0.14 - 0.16
33
Owner:
folk
Source:
https://github.com/folknor/factorio-fill
Homepage:
N/A
License:
CC-BY-NC 4.0
Created:
7 years ago
Latest Version:
0.2.2 (6 years ago)
Factorio version:
0.14 - 0.16
Downloaded by:
33 users

Automated Fuel & Ammo

Automatically inserts your most powerful fuel and ammunition into items placed by the player. \o/

The main feature of the mod is that it works without configuration for both AAI Vehicles (tested with Flame Tumbler and Hauler), all Tankwerkz tanks, and most likely all other mods you can think of.

The second advantage is that it doesn't lag the game when you spam-drop turrets.

The third advantage is that it automatically fills in all ammunition slots (Tankwerkz Goliath tank has 3x weapons), if you have enough ammunition.

The fourth advantage is that if the car/turret/tank/whatever has 2x weapons of type rocket or cannon, it will insert different ammunition in them.

It's made to work automatically with all vehicles, trains, and turrets added by mods. But it has only been tested with AAI/Tankwerkz.

If you look at the code, you'll see that the way it does this is quite weird, because most of the functionality that is needed to make this happen in a clean way is not actually exposed to the modding interface.

Settings

In the 0.15 options menu for all mods, there are two settings; Fuel stack size % and Ammo stack size %. These values tell the mod how many % of a normal stack size you want to insert when you plop down something.
A standard bullet magazine has a stack size of 200, and the default is 10%, which means the mod will try to insert 20 clips.
Fuel default is 100%, so a full stack.

If the mod can not insert the desired amount, it will always insert however many you have in your inventory, divided by 4.

These settings are per-player, and also per-save. You can change them mid-game.

How it behaves

The mod exclusively takes from the players inventory - not quick bar, and not vehicle inventory if you are in one. Please let me know if that's something that reeeeeally bothers you.

For fuel, it will add a full stack of whatever is the most powerful fuel in your inventory. This includes "Small electric pole".

For ammunition, it will add 25% of a stack of ammunition (usually 25), if it can. If not, it will add a 4th of however many you currently have in your inventory (minimum 1). It uses the "best" ammunition from your inventory, sorted by the order string in the data.

There are two exceptions to the ammunition rule, both of which are exceptionally rare.
1. If you're placing down a "car" that has more than 1 gun that takes the same category of ammunition, and the ammunition is in the category "rocket" or "cannon-shell". Then, it will try to insert two kinds of ammunition. The only case I know where this happens is the Tankwerkz Goliath.
2. If you're placing down a "ammo-turret" that has more than 1 gun of the same category and you have less than 1 stacks worth of ammunition in your inventory, the 2nd+ gun will not be filled. This is purely theoretical, I have never tested it - I don't know of any such turrets.

Planned features/considerations

Please let me know in the comments section if you have any questions or comments. Thank you!

Changelog

0.2.1: Just some tidying up, nothing visible.
0.2.0: Added ingame settings for percent-stack sizes.
0.1.2: Update for 0.15.
0.1.1: Fixed fuel insert/remove to not give you free stacks. Oops! Thanks Ratzap for reporting.