mirror of
https://github.com/Wyrrrd/Gun_Turret_Alerts.git
synced 2026-06-30 12:05:44 +02:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d7f853f1a5 | |||
| 9ee6474408 | |||
| 33c9bbe783 | |||
| ad4ae53c97 | |||
| 9545d088eb |
@@ -9,4 +9,5 @@ If you want to contribute by translating this mod, you can view the existing tra
|
||||
|
||||
### Credit
|
||||
Thanks to [unhott](https://mods.factorio.com/user/unhott) for the [original mod](https://mods.factorio.com/mod/GunTurretAlerts).
|
||||
Thanks to [snouz](https://mods.factorio.com/user/snouz) for the new icons and thumbnail.
|
||||
Thanks to [snouz](https://mods.factorio.com/user/snouz) for the new icons and thumbnail.
|
||||
Thanks to [d0ob](https://github.com/d0ob) for the french locale.
|
||||
@@ -1,4 +1,21 @@
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Version: 1.1.8
|
||||
Date: 2021-08-06
|
||||
Locale:
|
||||
- Addedd french locale (thanks to d0ob)
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Version: 1.1.7
|
||||
Date: 2021-06-21
|
||||
Compatibility:
|
||||
- Added compatibility to Space Exploration's Meteor defence and other mods (no longer displays alert when ammo is dynamically loaded) (by snouz)
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Version: 1.1.6
|
||||
Date: 2021-04-22
|
||||
Bugfixes:
|
||||
- Defaulting multislot mode "selected" to first slot, if no slot selected. Defaulting to "added" mode caused a crash.
|
||||
Scripting:
|
||||
- Simplified some boolean logic misusing it as ternary
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Version: 1.1.5
|
||||
Date: 2021-04-21
|
||||
Features:
|
||||
|
||||
+26
-25
@@ -13,57 +13,53 @@ end
|
||||
|
||||
--local functions
|
||||
|
||||
local get_ammo_flags = {
|
||||
local get_ammo_flag = {
|
||||
--Applies mode to inventory, calculates and returns respective inventory flags
|
||||
--Uses boolean return value as ternary, with true = no ammo, false = low ammo and nil = enough ammo
|
||||
["added"] = function (inventory,player_threshold)
|
||||
local no,low = false
|
||||
if inventory.is_empty() then
|
||||
no = true
|
||||
return true
|
||||
else
|
||||
local ammo_count = 0
|
||||
for i=1, #inventory do
|
||||
ammo_count = ammo_count + inventory[i].count
|
||||
end
|
||||
if ammo_count == 0 then
|
||||
no = true
|
||||
return true
|
||||
elseif ammo_count < player_threshold then
|
||||
low = true
|
||||
return false
|
||||
end
|
||||
end
|
||||
return no, low
|
||||
end,
|
||||
|
||||
["individually"] = function (inventory,player_threshold)
|
||||
local no,low = false
|
||||
if inventory.is_empty() then
|
||||
no = true
|
||||
return true
|
||||
else
|
||||
for i=1, #inventory do
|
||||
if inventory[i].count == 0 then
|
||||
no = true
|
||||
return true
|
||||
elseif inventory[i].count < player_threshold then
|
||||
low = true
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
return no, low
|
||||
end,
|
||||
|
||||
["selected"] = function (inventory,player_threshold,gun_index)
|
||||
local no,low = false
|
||||
if inventory.is_empty() then
|
||||
no = true
|
||||
return true
|
||||
else
|
||||
if not gun_index then
|
||||
-- default to added mode if no slot selected (probably multislot turret)
|
||||
no, low = get_ammo_flags["added"](inventory, player_threshold)
|
||||
elseif inventory[gun_index].count == 0 then
|
||||
no = true
|
||||
-- default to first slot if no slot selected (probably multislot turret)
|
||||
gun_index = 1
|
||||
end
|
||||
if inventory[gun_index].count == 0 then
|
||||
return true
|
||||
elseif inventory[gun_index].count < player_threshold then
|
||||
low = true
|
||||
return false
|
||||
end
|
||||
end
|
||||
return no, low
|
||||
end
|
||||
}
|
||||
|
||||
@@ -166,20 +162,25 @@ local function generate_alerts()
|
||||
end
|
||||
|
||||
--Check for states of no or low ammo based on mode
|
||||
local no, low = false
|
||||
if inventory and get_ammo_flags[mode] then
|
||||
local ammo_flag
|
||||
if inventory and get_ammo_flag[mode] then
|
||||
if entity.type == "ammo-turret" then
|
||||
no, low = get_ammo_flags[mode](inventory, player_threshold)
|
||||
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
|
||||
ammo_flag = get_ammo_flag[mode](inventory, entity.prototype.automated_ammo_count)
|
||||
end
|
||||
end
|
||||
elseif entity.type == "car" then
|
||||
no, low = get_ammo_flags[mode](inventory, player_threshold, entity.selected_gun_index)
|
||||
ammo_flag = get_ammo_flag[mode](inventory, player_threshold, entity.selected_gun_index)
|
||||
end
|
||||
end
|
||||
|
||||
--Create alert for present state
|
||||
if no then
|
||||
if ammo_flag then
|
||||
-- no ammo alert
|
||||
player.add_custom_alert(entity, {type = "virtual", name = "ammo-icon-red"}, {"gun-turret-alerts.message-empty", entity.localised_name}, true)
|
||||
elseif low then
|
||||
elseif ammo_flag == false then
|
||||
-- low ammo alert
|
||||
player.add_custom_alert(entity, {type = "virtual", name = "ammo-icon-yellow"}, {"gun-turret-alerts.message-low", entity.localised_name}, true)
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "Gun_Turret_Alerts",
|
||||
"version": "1.1.5",
|
||||
"version": "1.1.8",
|
||||
"title": "Ammo Alerts",
|
||||
"author": "Wyrrrd",
|
||||
"factorio_version": "1.1",
|
||||
|
||||
@@ -17,4 +17,8 @@ autofilter_mode-selected=Auswahl
|
||||
|
||||
[gun-turret-alerts]
|
||||
message-empty=__1__ hat keine Munition
|
||||
message-low=__1__ hat wenig Munition
|
||||
message-low=__1__ hat wenig Munition
|
||||
|
||||
[virtual-signal-name]
|
||||
ammo-icon-red=Hat keine Munition
|
||||
ammo-icon-yellow=Hat wenig Munition
|
||||
@@ -17,4 +17,8 @@ autofilter_mode-selected=Selected
|
||||
|
||||
[gun-turret-alerts]
|
||||
message-empty=__1__ out of ammo
|
||||
message-low=__1__ ammo low
|
||||
message-low=__1__ low ammo
|
||||
|
||||
[virtual-signal-name]
|
||||
ammo-icon-red=Out of ammo signal
|
||||
ammo-icon-yellow=Low ammo signal
|
||||
@@ -0,0 +1,24 @@
|
||||
[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-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-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.
|
||||
|
||||
[string-mod-setting]
|
||||
autofilter_mode-added=Tous
|
||||
autofilter_mode-individually=Unique
|
||||
autofilter_mode-selected=Sélection
|
||||
|
||||
[gun-turret-alerts]
|
||||
message-empty=__1__ plus de munition
|
||||
message-low=__1__ peu de munitions
|
||||
|
||||
[virtual-signal-name]
|
||||
ammo-icon-red=Signal d'absence de munition
|
||||
ammo-icon-yellow=Signal de manque de munitions
|
||||
Reference in New Issue
Block a user