diff --git a/changelog.txt b/changelog.txt index 2d93d9f..83ef316 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,4 +1,9 @@ --------------------------------------------------------------------------------------------------- +Version: 1.1.10 +Date: 2022-08-07 + Features: + - Added artillery as third alert group (off by default) +--------------------------------------------------------------------------------------------------- Version: 1.1.9 Date: 2021-08-07 Locale: diff --git a/control.lua b/control.lua index 10b0a5f..11b8dad 100644 --- a/control.lua +++ b/control.lua @@ -64,7 +64,7 @@ local get_ammo_flag = { } local function add_entity_to_list(event) - --Whenever an ammo-turret or car type entity is built, add it to the global table. + --Whenever an ammo-turret, car or artillery type entity is built, add it to the global table. local index = event.created_entity.surface.name.."_"..event.created_entity.force.name if global.ammo_entities[index] then table.insert(global.ammo_entities[index], event.created_entity) @@ -72,7 +72,7 @@ local function add_entity_to_list(event) end local function remove_entity_from_list(event) - --Whenever an ammo-turret or car type entity dies / is mined, remove it from the global table. + --Whenever an ammo-turret, car or artillery type entity dies / is mined, remove it from the global table. local index = event.entity.surface.name.."_"..event.entity.force.name if global.ammo_entities[index] then for i,entity in pairs(global.ammo_entities[index]) do @@ -85,7 +85,7 @@ local function remove_entity_from_list(event) end local function add_force_to_list(event) - --Whenever a player of an unscanned force joins the game or a force is created, add all ammo-turret or car type entities of that force to the global table. + --Whenever a player of an unscanned force joins the game or a force is created, add all ammo-turret, car or artillery type entities of that force to the global table. local player, force if event.player_index then player = game.get_player(event.player_index) @@ -99,7 +99,7 @@ local function add_force_to_list(event) if player and force and not global.ammo_entities[player.surface.name.."_"..force.name] then for _,surface in pairs(game.surfaces) do - global.ammo_entities[surface.name.."_"..force.name] = surface.find_entities_filtered{type = {"ammo-turret","car"}, force = force, to_be_deconstructed = false} + global.ammo_entities[surface.name.."_"..force.name] = surface.find_entities_filtered{type = {"ammo-turret","car","artillery-turret","artillery-wagon"}, force = force, to_be_deconstructed = false} end end end @@ -140,11 +140,12 @@ local function init_list() end local function generate_alerts() - --Every 10 seconds recheck and give alerts to players for car and ammo-turret entities on the same force as them. + --Every 10 seconds recheck and give alerts to players for ammo-turret, car or artillery type entities on the same force as them. for _,player in pairs(game.connected_players) do local turret_enabled = player.mod_settings["gun-turret-alerts-enabled"].value local car_enabled = player.mod_settings["gun-turret-alerts-car-enabled"].value + local artillery_enabled = player.mod_settings["gun-turret-alerts-artillery-enabled"].value local mode = player.mod_settings["gun-turret-alerts-mode"].value local player_threshold = player.mod_settings["gun-turret-alerts-threshold"].value local ammo_entities = global.ammo_entities[player.surface.name.."_"..player.force.name] @@ -159,12 +160,18 @@ local function generate_alerts() inventory = entity.get_inventory(defines.inventory.turret_ammo) elseif car_enabled and entity.type == "car" and not table_is_empty(entity.prototype.guns) then inventory = entity.get_inventory(defines.inventory.car_ammo) + elseif artillery_enabled then + if entity.type == "artillery-turret" then + inventory = entity.get_inventory(defines.inventory.artillery_turret_ammo) + elseif entity.type == "artillery-wagon" then + inventory = entity.get_inventory(defines.inventory.artillery_wagon_ammo) + end end --Check for states of no or low ammo based on mode local ammo_flag if inventory and get_ammo_flag[mode] then - if entity.type == "ammo-turret" 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) if entity.prototype.automated_ammo_count then if entity.prototype.automated_ammo_count < player_threshold then @@ -203,11 +210,11 @@ script.on_event(defines.events.on_player_changed_force, remove_force_from_list) script.on_event(defines.events.on_force_created, add_force_to_list) script.on_event(defines.events.on_forces_merged, remove_force_from_list) -script.on_event(defines.events.on_built_entity, add_entity_to_list, {{filter="type", type = "ammo-turret"},{filter="type", type = "car"}}) -script.on_event(defines.events.on_robot_built_entity, add_entity_to_list, {{filter="type", type = "ammo-turret"},{filter="type", type = "car"}}) +script.on_event(defines.events.on_built_entity, add_entity_to_list, {{filter="type", type = "ammo-turret"},{filter="type", type = "car"},{filter="type", type = "artillery-turret"},{filter="type", type = "artillery-wagon"}}) +script.on_event(defines.events.on_robot_built_entity, add_entity_to_list, {{filter="type", type = "ammo-turret"},{filter="type", type = "car"},{filter="type", type = "artillery-turret"},{filter="type", type = "artillery-wagon"}}) -script.on_event(defines.events.on_player_mined_entity, remove_entity_from_list, {{filter="type", type = "ammo-turret"},{filter="type", type = "car"}}) -script.on_event(defines.events.on_robot_mined_entity, remove_entity_from_list, {{filter="type", type = "ammo-turret"},{filter="type", type = "car"}}) -script.on_event(defines.events.on_entity_died, remove_entity_from_list, {{filter="type", type = "ammo-turret"},{filter="type", type = "car"}}) +script.on_event(defines.events.on_player_mined_entity, remove_entity_from_list, {{filter="type", type = "ammo-turret"},{filter="type", type = "car"},{filter="type", type = "artillery-turret"},{filter="type", type = "artillery-wagon"}}) +script.on_event(defines.events.on_robot_mined_entity, remove_entity_from_list, {{filter="type", type = "ammo-turret"},{filter="type", type = "car"},{filter="type", type = "artillery-turret"},{filter="type", type = "artillery-wagon"}}) +script.on_event(defines.events.on_entity_died, remove_entity_from_list, {{filter="type", type = "ammo-turret"},{filter="type", type = "car"},{filter="type", type = "artillery-turret"},{filter="type", type = "artillery-wagon"}}) script.on_nth_tick(600, generate_alerts) \ No newline at end of file diff --git a/info.json b/info.json index 8616de3..553a56e 100644 --- a/info.json +++ b/info.json @@ -1,6 +1,6 @@ { "name": "Gun_Turret_Alerts", - "version": "1.1.9", + "version": "1.1.10", "title": "Ammo Alerts", "author": "Wyrrrd", "factorio_version": "1.1", diff --git a/locale/de/config.cfg b/locale/de/config.cfg index 336b145..ee605d6 100644 --- a/locale/de/config.cfg +++ b/locale/de/config.cfg @@ -1,12 +1,14 @@ [mod-setting-name] gun-turret-alerts-enabled=Alarme für Geschützturmmunition aktiviert gun-turret-alerts-car-enabled=Alarme für Fahrzeugmunition aktiviert +gun-turret-alerts-artillery-enabled=Alarme für Artillerie aktiviert gun-turret-alerts-mode=Mehrplatz-Modus gun-turret-alerts-threshold=Grenze für wenig Munition [mod-setting-description] gun-turret-alerts-enabled=Aktiviert Alarme für Geschützturmmunition für deinen Spieler gun-turret-alerts-car-enabled=Aktiviert Alarme für Fahrzeugmunition für deinen Spieler +gun-turret-alerts-artillery-enabled=Aktiviert Alarme für Artillerie für deinen Spieler gun-turret-alerts-mode=Bestimmt, ob die Munitionsplätze aufaddiert, jeder Platz einzeln oder nur der ausgewählte Platz gezählt wird.\n(Greift nur bei mehr als einem Munitionsplatz, zum Beispiel in Fahrzeugen.) gun-turret-alerts-threshold=Wenn ein Fahrzeug oder Geschützturm weniger als diese Anzahl Munition hat, wird ein Alarm zu deinem Spieler hinzugefügt diff --git a/locale/en/config.cfg b/locale/en/config.cfg index 62a698b..97eb9e1 100644 --- a/locale/en/config.cfg +++ b/locale/en/config.cfg @@ -1,12 +1,14 @@ [mod-setting-name] gun-turret-alerts-enabled=Turret ammo alerts enabled gun-turret-alerts-car-enabled=Car ammo alerts enabled +gun-turret-alerts-artillery-enabled=Artillery ammo alerts enabled gun-turret-alerts-mode=Multi slot mode gun-turret-alerts-threshold=Low ammo threshold [mod-setting-description] gun-turret-alerts-enabled=Enables turret ammo alerts to be added to your player. gun-turret-alerts-car-enabled=Enables car ammo alerts to be added to your player. +gun-turret-alerts-artillery-enabled=Enables artillery ammo alerts to be added to your player. gun-turret-alerts-mode=Controls, if the ammo slots are added up, every slot is counted individually, or just the selected slot is counted.\n(Only applies for more than one ammo slot, for example in vehicles.) gun-turret-alerts-threshold=If a car or turret has less than this much ammo an alert will be added to your player. diff --git a/locale/fr/config.cfg b/locale/fr/config.cfg index cbfcce7..86d6717 100644 --- a/locale/fr/config.cfg +++ b/locale/fr/config.cfg @@ -1,12 +1,14 @@ [mod-setting-name] gun-turret-alerts-enabled=Activer les alertes de manque de munitions dans les tourelles. gun-turret-alerts-car-enabled=Activer les alertes de manque de munitions dans les véhicules. +gun-turret-alerts-artillery-enabled=Activer les alertes de manque de munitions dans la artillerie. gun-turret-alerts-mode=Prendre en considération plusieurs compartiments de munitions. gun-turret-alerts-threshold=Nombre de munitions restantes avant d'être alerté. [mod-setting-description] gun-turret-alerts-enabled=Le manque de munitions dans une tourelle enverra une alerte au joueur. gun-turret-alerts-car-enabled=Le manque de munitions dans un véhicule enverra une alerte au joueur. +gun-turret-alerts-artillery-enabled=Le manque de munitions dans une artillerie enverra une alerte au joueur. gun-turret-alerts-mode=Surveiller tous les compartiments de l'unité, un seul, ou une sélection.\n(Certaines unités, principalement des véhicules, peuvent posséder plusieurs compartiments. À laisser décoché s'il n'y en a qu'un seul.) gun-turret-alerts-threshold=Le nombre de munitions, dans une tourelle ou un véhicule, qui déclenchera un alerte une fois atteint. diff --git a/settings.lua b/settings.lua index 02ae43f..7bec18b 100644 --- a/settings.lua +++ b/settings.lua @@ -14,6 +14,12 @@ data:extend({ setting_type = "runtime-per-user", default_value = true }, + { + type = "bool-setting", + name = "gun-turret-alerts-artillery-enabled", + setting_type = "runtime-per-user", + default_value = false + }, { type = "string-setting", name = "gun-turret-alerts-mode",