Ammo Alerts

by Wyrrrd

Adds map alerts for players when a gun turret, vehicle or artillery is either out of ammo or has low ammo.

Utilities
11 days ago
0.18 - 2.0
41.2K

b [Ugly quick fix] No warnings above 10

15 days ago

Thanks for the awesome mod.
It seems as if there is a kind of bug, or maybe I get something entirely wrong.

No matter what I do, I do not get warnings anymore as soon as my turret has 10 ammo items (as in 10x10=100 bullets).

I've tried different options for counting, the default and individual, I've set the limit to 50, 75, 100, 1000 and 10000, closed and reloaded the map and even restarted the game, just to be sure the settings were taken into account, but no matter what, I can't make the mod give me warnings above 10.

15 days ago
(updated 15 days ago)

No, you are totally right. Funny that nobody caught that for the last 3.5 years, that's how long that bit of code has been in there...

It is handling the edge case that an alert would be fired if the automatically loaded amount (automated_ammo_count) is smaller than the player threshold setting, making the turret always call for help.

If you fill all your turrets with inserters, it works fine. But if you add more ammo manually, this logic breaks. I need to figure out how to separate those two cases.

14 days ago

Thanks for your quick reply.

It's the second time within a week a mod author said that. xD

Maybe don't handle that case at all and leave it to the user to decide how much ammo they want?
I would assume if someone would fill the turrets with inserters, they'd set the value lower, but also that in that case the mod itself would provide less value, because when you automate it, there are less chances for mistakes than when you fill them manually. (Which I still do, because I'm not yet ready for the automation.)

That said, to keep the mod as closely to what it is right now and not confuse others, a solution might be adding a setting (bool), that is set to true by default, that people who fill manually can turn off, and handle that edge case only when the setting is not active.

That's all I can think of for now.

14 days ago
(updated 14 days ago)

The problem here is that you set your threshold globally, for all entities, turrets, artillery and vehicles alike.
The more sustainable solution would be to be able to override the threshold per entity, but I don't know if I can find the time to implement it soon.
For now I think I'll go with your quick fix setting combined with only not raising an alert when the ammo count is exactly equal to the automated count (currently it checks if ammo count is equal or greater), as this would be better than the current situation.

Thanks for your input :)

14 days ago

You are welcome and thanks for doing the quick fix.

The other thing you mentioned sounds plausible, but I see how it takes some effort to do that, and then, you can only do it for all the mods you are interested in and aware of.
There might be another not so elegant quicker step towards that goal, if you are willing to do that, provide a setting that takes a string of the format:
"prototype-name;threshold;prototype-name;threshold" etc.
e.g. "gun-turret;20;tank;40"
And then maybe later on add settings for all the prototypes/entities you deem worth supporting in a more user friendly way.

Just an idea though, personally, I am well served with the quick fix setting you are willing to do. I need the warning primarily for turrets.

13 days ago
(updated 13 days ago)

Quick fix is implemented, but I could not figure out the "exactly"-part since inserters can overshoot the automated ammo count... and I didn't want to check the map for all inserters pointing at the entity to calculate their maximum overshoot, and that for each entity every ten seconds 🤣

13 days ago

Thanks! I will test it and get back to you.
And yeah, checking all inserters would be a little bit over the tops. :)

13 days ago

Tested it for a while and it seems to work very well now. Thanks again!

New response