Automated Fuel & Ammo

by folk

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

Utilities
7 days ago
0.14 - 2.0
824
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.3.1 (7 days ago)
Factorio version:
0.14 - 2.0
Downloaded by:
824 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.3.1:
- Rewrite large sections of the code.
- Artillery Wagons, Artillery Turrets, and Spidertrons are now supported.
- Rocket Turrets work properly. Rail Turrets also, but they might have worked previously as well, I never tested them :-P
- Added 4 settings for ignored/preferred fuel and ammo items. Use the items prototype names, comma-separated if necessary. The mod now by default ignores capture-robot-rocket and atomic-bomb.
- Now only tries to use fuel sources that can actually chemically burn
0.2.2 - 0.2.5: 2.0 fixes and updates. Also if you have less than the configured stack % of fuel in your inventory, the mod inserts half of what you have now to help prevent running out of for example wood.
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.