1.0.8

esorochinskiy [06-19-22 - 07:47]
1.0.8
Filename
UI.lua
WellEater.lua
WellEater.txt
lang/de.lua
lang/en.lua
lang/ru.lua
diff --git a/UI.lua b/UI.lua
index bdd8606..44a35d4 100644
--- a/UI.lua
+++ b/UI.lua
@@ -170,6 +170,21 @@ function WellEater:initSettingsMenu()
         min = 50, max = 300, step = 10,
     }, "general", "minCharges")

+    sTable = MakeSubmenu(optionsTable,L.repairSetupHeader, L.repairSetupDescription)
+
+    MakeControlEntry(sTable,{
+        type = "checkbox",
+        name = L.repairSetupCheck,
+        tooltip = L.repairSetupCheck_TT,
+    }, "general", "useRepair")
+
+    MakeControlEntry(sTable,{
+        type = "slider",
+        name = L.repairPercent,
+        tooltip = L.repairPercent,
+        min = 10, max = 50, step = 10,
+    }, "general", "percent")
+
     MakeControlEntry(optionsTable,{
         type = "header",
         name = L.outputSetupHeader,
diff --git a/WellEater.lua b/WellEater.lua
index 87c056a..b092eba 100644
--- a/WellEater.lua
+++ b/WellEater.lua
@@ -2,7 +2,7 @@ WellEater = WellEater or {}
 WellEater.WELLEATER_SAVED_VERSION = 1
 WellEater.AddonName = "WellEater"
 WellEater.DisplayName = "|cFFFFFFWell |c0099FFEater|r"
-WellEater.Version = "1.0.7"
+WellEater.Version = "1.0.8"
 WellEater.Author = "|c5EFFF5esorochinskiy|r"
 local NAMESPACE = {}
 NAMESPACE.settingsDefaults = {
@@ -24,9 +24,21 @@ NAMESPACE.settingsDefaults = {
     minCharges = 300,
     useCrownGems = true,
     useCrownFood = false,
+    useRepair = true,
+    percent = 10
 }
 NAMESPACE.conversation = false
 NAMESPACE.notifications = {}
+NAMESPACE.wearSlots = {
+    EQUIP_SLOT_CHEST,
+    EQUIP_SLOT_HEAD,
+    EQUIP_SLOT_SHOULDERS,
+    EQUIP_SLOT_WAIST,
+    EQUIP_SLOT_WRIST,
+    EQUIP_SLOT_HAND,
+    EQUIP_SLOT_LEGS,
+    EQUIP_SLOT_FEET
+}

 function WellEater:isWeaponCheckable()
     local settings = self:getAllUserPreferences()
@@ -220,6 +232,49 @@ local function processAutoEat()
     end
 end

+local function checkAndRepair()
+    local bagC
+    local locSettings = WellEater:getAllUserPreferences()
+
+    for _,testSlot in pairs(NAMESPACE.wearSlots) do
+        local linkId = GetItemLink(BAG_WORN, testSlot)
+        if HasItemInSlot(BAG_WORN, testSlot) and DoesItemLinkHaveArmorDecay(linkId) then
+            local numPercent = GetItemLinkCondition(linkId)
+            if numPercent < locSettings.percent then
+                if not bagC then
+                    SHARED_INVENTORY:RefreshInventory(BAG_BACKPACK)
+                    bagC = SHARED_INVENTORY:GetOrCreateBagCache(BAG_BACKPACK)
+
+                    if not bagC or type(bagC) ~= "table" then
+                        return
+                    end
+                end
+
+                for _, itemInfo in pairs(bagC) do
+                    local slotId = itemInfo.slotIndex
+                    if not itemInfo.stolen and IsItemRepairKit(BAG_BACKPACK, slotId) then
+                        RepairItemWithRepairKit(BAG_WORN, testSlot, BAG_BACKPACK, slotId)
+                        local iName = GetItemLinkName(GetItemLink(BAG_WORN, testSlot))
+                        local locale = WellEater:getLocale()
+                        local formattedName = zo_strformat(locale.youRepair, iName) -- no control codes
+                        df("[%s] %s", WellEater.AddonName, formattedName)
+                        local toScreen = locSettings.notifyToScreen
+                        if toScreen then
+                            WellEater.WeaponAnimIn:PlayFromStart()
+                            WellEaterIndicator:SetHidden(false)
+                            WellEaterIndicatorWeaponLabel:SetText(formattedName)
+                            zo_callLater(function()
+                                hideOut(WellEaterIndicatorWeaponLabel, WellEater.WeaponAnimOut)
+                            end, 1500)
+                        end
+                        break
+                    end
+                end
+            end
+        end
+    end
+end
+
 local function checkEquippedWeapon()
     local bagC
     local locSettings = WellEater:getAllUserPreferences()
@@ -373,6 +428,11 @@ local function InitOnLoad(_, addonName)

                 if not arg then
                     --d(WellEater.AddonName .. " Combat exited")
+                    local useRepair = WellEater:getUserPreference("useRepair")
+                    if useRepair then
+                        checkAndRepair()
+                    end
+
                     StartUp()
                 else
                     --d(WellEater.AddonName .. " Combat entered")
diff --git a/WellEater.txt b/WellEater.txt
index a46ab89..b0c863b 100644
--- a/WellEater.txt
+++ b/WellEater.txt
@@ -31,7 +31,7 @@
 ## Author: |c5EFFF5esorochinskiy|r
 ## APIVersion: 101033 101034
 ## Description: Auto eat your preferred meals provided by your inventory after food or drink buff expiration. Provides weapon autoload
-## Version: 1.0.7
+## Version: 1.0.8
 ## SavedVariables: WellEater_Settings
 ## DependsOn: LibAddonMenu-2.0>=28

diff --git a/lang/de.lua b/lang/de.lua
index c36efd1..738fa62 100644
--- a/lang/de.lua
+++ b/lang/de.lua
@@ -18,6 +18,7 @@ local L = {

     youEat = "Sie haben <<1>> gegessen",
     youCharge = "Eingeladen <<1>>",
+    youRepair = "Reparieren <<1>>",
     outputSetupHeader = "Anzeigen die Nachricht",
     outputOnScreen = "Auf den Bildschirm",
     outputSetupHeader_TT = "Wenn die Einstellung aktiviert ist, wird eine Nachricht über das gegessene Gericht" ..
@@ -45,7 +46,12 @@ local L = {
     useCrownFoodTitle = "Kronessen benutzen",
     useCrownFoodTitle_TT = "Das gefundene Kronessen benutzt wird",

+    repairSetupHeader = "Automatische Reparatur",
+    repairSetupDescription = "Automatischereparaturbesetzung",

+    repairSetupCheck = "Automatische Reparatur",
+    repairSetupCheck_TT = "Sollen Sie einen Reparatursatz haben, um zu autoreparieren",
+    repairPercent = "Minimum Verfall %",
 }

 function WellEater:getLocale()
diff --git a/lang/en.lua b/lang/en.lua
index e919158..5ff522b 100644
--- a/lang/en.lua
+++ b/lang/en.lua
@@ -17,6 +17,7 @@ local L = {

     youEat = "You have eaten <<1>>",
     youCharge = "Charged <<1>>",
+    youRepair = "Repaired <<1>>",
     outputSetupHeader = "notification output",
     outputOnScreen = "On screen",
     outputSetupHeader_TT = "When on the notification about the meal eaten or weapon recharged is written to the screen not only to the debug log",
@@ -42,7 +43,12 @@ local L = {
     useCrownFoodTitle = "Use crown food",
     useCrownFoodTitle_TT = "While searching for a food crown meals are taken into the account",

+    repairSetupHeader = "Autorepair",
+    repairSetupDescription = "Autorepair settings",

+    repairSetupCheck = "Armor Auto Repair",
+    repairSetupCheck_TT = "There should be a repair kit in the inventory to get this to work",
+    repairPercent = "Minimum % of decay",

 }

diff --git a/lang/ru.lua b/lang/ru.lua
index dcc3fc9..ae35f31 100644
--- a/lang/ru.lua
+++ b/lang/ru.lua
@@ -18,6 +18,7 @@ local L = {

     youEat = "Вы съели: <<1>>",
     youCharge = "Заряжено <<1>>",
+    youRepair = "Отремонтировано <<1>>",
     outputSetupHeader = "Вывод сообщения",
     outputOnScreen = "На экран",
     outputSetupHeader_TT = "При включенной настройке сообщение о съеденном блюде или перезарядке оружия будет выведено на экран, а не только" ..
@@ -45,6 +46,13 @@ local L = {
     useCrownFoodTitle = "Использовать кронную еду",
     useCrownFoodTitle_TT = "При поиске еды в инвентаре учитывать и кронную еду",

+    repairSetupHeader = "Авторемонт",
+    repairSetupDescription = "Настройки авторемонта",
+
+    repairSetupCheck = "Автоматический ремонт снаряжения",
+    repairSetupCheck_TT = "Для автоматического ремонта снаряжения необходим ремонтный набор в инвентаре",
+    repairPercent = "Минимальный % повреждения",
+
 }

 function WellEater:getLocale()