1.1.2

esorochinskiy [07-26-22 - 10:38]
1.1.2
Filename
WellEater.lua
WellEater.txt
lang/de.lua
lang/en.lua
lang/ru.lua
diff --git a/WellEater.lua b/WellEater.lua
index e9cbec0..6af7b83 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.1.1"
+WellEater.Version = "1.1.2"
 WellEater.Author = "|c5EFFF5esorochinskiy|r"
 local NAMESPACE = {}
 NAMESPACE.settingsDefaults = {
@@ -135,6 +135,10 @@ NAMESPACE.skillUpItems = {

 }

+NAMESPACE.crownFoods = {
+    [64711] = true
+}
+
 -- local functions

 local function hideOut(control, animationOut)
@@ -192,27 +196,72 @@ local function processAutoEat()
         return
     end

+    local locSettings = WellEater:getAllUserPreferences()
+    local useFood = locSettings.useFood
+    local useDrink = locSettings.useDrink
+    local useCrownFood = locSettings.useCrownFood
+    --[[
+        table.sort(bagCache, function(a, b)
+            if not a or type(a) ~= "table" then
+                return false
+            end
+
+            if not a.stolen then
+                local slotId = a.slotIndex
+                local itemType = GetItemType(bagId, slotId)
+                local itemId = GetItemId(bagId, slotId)
+                if ((useFood and itemType == ITEMTYPE_FOOD) or
+                        (useDrink and itemType == ITEMTYPE_DRINK)) and
+                        not SkillUpItem(itemId) then
+                    if useCrownFood then
+                        return NAMESPACE.crownFoods[itemId]
+                    else
+                        return not NAMESPACE.crownFoods[itemId]
+                    end
+                else
+                    return false
+                end
+            else
+                return false
+            end
+        end)
+    ]]
     for _, itemInfo in pairs(bagCache) do
-        local locSettings = WellEater:getAllUserPreferences()
-        local useFood = locSettings.useFood
-        local useDrink = locSettings.useDrink
-        local useCrownFood = locSettings.useCrownFood
+
         local slotId = itemInfo.slotIndex
         if not itemInfo.stolen then
-            local itemType, specialType = GetItemType(bagId, slotId)
-            local useThisFood = (specialType ~= SPECIALIZED_ITEMTYPE_CROWN_ITEM or
-                    (useCrownFood and specialType == SPECIALIZED_ITEMTYPE_CROWN_ITEM))
+            local itemType = GetItemType(bagId, slotId)
             local itemId = GetItemId(bagId, slotId)
+            local useThisFood = (not NAMESPACE.crownFoods[itemId] or (useCrownFood and NAMESPACE.crownFoods[itemId]))
+            --[[d("key = " .. i)
+            d("name = " .. GetItemName(bagId, slotId))
+            d("useThisFood = ")
+            d(useThisFood)
+]]
             if ((useFood and itemType == ITEMTYPE_FOOD) or
-                    (useDrink and itemType == ITEMTYPE_DRINK)) and
-                    useThisFood and not SkillUpItem(itemId) then
+                    (useDrink and itemType == ITEMTYPE_DRINK)) and useThisFood and not SkillUpItem(itemId) then
+
+
+                --d("itemType = " .. itemType)
                 local icon, stack, sellPrice, meetsUsageRequirement, locked, equipType, itemStyleId, quality = GetItemInfo(bagId, slotId)

                 if meetsUsageRequirement and locSettings and locSettings[quality] then
-
+--[[
+                    d("meetsUsageRequirement = ")
+                    d(meetsUsageRequirement)
+                    d("locSettings[quality] = ")
+                    d(locSettings[quality])
+]]
                     local usable, onlyFromActionSlot = IsItemUsable(bagId, slotId)
                     if usable and not onlyFromActionSlot then
-
+--[[
+                        d("usable = ")
+                        d(usable)
+                        d("onlyFromActionSlot = ")
+                        d(onlyFromActionSlot)
+
+                        d("Trying...")
+                        ]]
                         tryToUseItem(bagId, slotId)

                         local itemLink = GetItemLink(bagId, slotId)
@@ -249,6 +298,24 @@ local function checkAndRepair()
                     if not bagC or type(bagC) ~= "table" then
                         return
                     end
+                    --[[
+                                        table.sort(bagC, function(a, b)
+                                            if not a or type(a) ~= "table" then
+                                                return false
+                                            end
+
+                                            local slotId = a.slotIndex
+                                            if not a.stolen and IsItemNonGroupRepairKit(BAG_BACKPACK, slotId) then
+                                                if locSettings.useCrownRepair then
+                                                    return not IsItemNonCrownRepairKit(BAG_BACKPACK, slotId)
+                                                else
+                                                    return IsItemNonCrownRepairKit(BAG_BACKPACK, slotId)
+                                                end
+                                            else
+                                                return false
+                                            end
+                                        end)
+                    ]]
                 end

                 for _, itemInfo in pairs(bagC) do
@@ -288,6 +355,7 @@ end
 local function checkEquippedWeapon()
     local bagC
     local locSettings = WellEater:getAllUserPreferences()
+    local useCrownGems = locSettings.useCrownGems

     for testSlot, isToCheck in pairs(locSettings.slots) do
         if isToCheck and HasItemInSlot(BAG_WORN, testSlot)
@@ -304,13 +372,31 @@ local function checkEquippedWeapon()
                     if not bagC or type(bagC) ~= "table" then
                         return
                     end
+                    --[[
+                                        table.sort(bagC, function(a, b)
+                                            if not a or type(a) ~= "table" then
+                                                return false
+                                            end
+
+                                            local slotId = a.slotIndex
+                                            local specializedItemType = select(2, GetItemType(BAG_BACKPACK, slotId))
+                                            if not a.stolen and IsItemSoulGem(SOUL_GEM_TYPE_FILLED, BAG_BACKPACK, slotId) then
+                                                if useCrownGems then
+                                                    return specializedItemType == SPECIALIZED_ITEMTYPE_CROWN_ITEM
+                                                else
+                                                    return specializedItemType ~= SPECIALIZED_ITEMTYPE_CROWN_ITEM
+                                                end
+                                            else
+                                                return false
+                                            end
+                                        end)
+                    ]]
                 end

                 for _, itemInfo in pairs(bagC) do
                     local slotId = itemInfo.slotIndex
                     if not itemInfo.stolen and IsItemSoulGem(SOUL_GEM_TYPE_FILLED, BAG_BACKPACK, slotId) then
                         local specializedItemType = select(2, GetItemType(BAG_BACKPACK, slotId))
-                        local useCrownGems = locSettings.useCrownGems

                         local useThis = (specializedItemType ~= SPECIALIZED_ITEMTYPE_CROWN_ITEM or
                                 (useCrownGems and specializedItemType == SPECIALIZED_ITEMTYPE_CROWN_ITEM))
diff --git a/WellEater.txt b/WellEater.txt
index 3c9259f..02cb0e2 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 and armor autorepair
-## Version: 1.1.1
+## Version: 1.1.2
 ## SavedVariables: WellEater_Settings
 ## DependsOn: LibAddonMenu-2.0>=28

diff --git a/lang/de.lua b/lang/de.lua
index f822d92..694c6b5 100644
--- a/lang/de.lua
+++ b/lang/de.lua
@@ -19,7 +19,7 @@ local L = {
     youEat = "Sie haben <<1>> gegessen",
     youCharge = "Eingeladen <<1>>",
     youRepair = "Reparieren <<1>>",
-    allRepair = "alles",
+    allRepair = "Alles wird repariert",
     outputSetupHeader = "Anzeigen die Nachricht",
     outputOnScreen = "Auf den Bildschirm",
     outputSetupHeader_TT = "Wenn die Einstellung aktiviert ist, wird eine Nachricht über das gegessene Gericht" ..
diff --git a/lang/en.lua b/lang/en.lua
index 6884c4b..1273489 100644
--- a/lang/en.lua
+++ b/lang/en.lua
@@ -18,7 +18,7 @@ local L = {
     youEat = "You have eaten <<1>>",
     youCharge = "Charged <<1>>",
     youRepair = "Repaired <<1>>",
-    allRepair = "all",
+    allRepair = "All repaired",
     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",
diff --git a/lang/ru.lua b/lang/ru.lua
index dbe32ab..248239c 100644
--- a/lang/ru.lua
+++ b/lang/ru.lua
@@ -19,7 +19,7 @@ local L = {
     youEat = "Вы съели: <<1>>",
     youCharge = "Заряжено <<1>>",
     youRepair = "Отремонтировано <<1>>",
-    allRepair = "все",
+    allRepair = "Все отремонтировано",
     outputSetupHeader = "Вывод сообщения",
     outputOnScreen = "На экран",
     outputSetupHeader_TT = "При включенной настройке сообщение о съеденном блюде или перезарядке оружия будет выведено на экран, а не только" ..