1
0
mirror of https://github.com/Wyrrrd/Gun_Turret_Alerts.git synced 2026-03-25 16:49:50 +01:00

Small cleanup and commenting

This commit is contained in:
Wyrrrd
2024-11-10 11:49:00 +01:00
parent d6d426ddc7
commit 4c8b05b930
2 changed files with 9 additions and 5 deletions

View File

@@ -125,9 +125,11 @@ local function remove_force_from_list(event)
force = event.source
end
if force and not force.connected_players then
for surface_name,_ in pairs(game.surfaces) do
storage.ammo_entities[surface_name.."_"..force.name] = nil
if force then
if not force.valid or (force.valid and table_is_empty(force.connected_players)) then
for surface_name,_ in pairs(game.surfaces) do
storage.ammo_entities[surface_name.."_"..force.name] = nil
end
end
end
end
@@ -217,6 +219,7 @@ local function generate_alerts()
if inventory and get_ammo_flag[mode] then
if entity.type == "ammo-turret" or entity.type == "artillery-turret" or entity.type == "artillery-wagon" then
ammo_flag = get_ammo_flag[mode](inventory, player_threshold)
-- Automated amme count override (if activated)
if auto_full and entity.prototype.automated_ammo_count then
if entity.prototype.automated_ammo_count < player_threshold then
ammo_flag = get_ammo_flag[mode](inventory, entity.prototype.automated_ammo_count)
@@ -237,6 +240,7 @@ local function generate_alerts()
end
end
else
-- Cleanup if entity is invalid
table.remove(ammo_entities, index)
end
end