bug on EVENT_PLAYER_ACTIVATED fix

esorochinskiy [06-08-22 - 18:08]
bug on EVENT_PLAYER_ACTIVATED fix
Filename
WellEater.lua
WellEater.txt
diff --git a/WellEater.lua b/WellEater.lua
index dbd01fa..4919661 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.4"
+WellEater.Version = "1.0.5"
 WellEater.Author = "|c5EFFF5esorochinskiy|r"
 local NAMESPACE = {}
 NAMESPACE.settingsDefaults = {
@@ -23,6 +23,7 @@ NAMESPACE.settingsDefaults = {
     },
     minCharges = 300,
 }
+NAMESPACE.conversation = false

 function WellEater:isWeaponCheckable()
     local settings = self:getAllUserPreferences()
@@ -259,7 +260,7 @@ local function checkEquippedWeapon()
                                 WellEaterIndicator:SetHidden(false)
                                 WellEaterIndicatorWeaponLabel:SetText(formattedName)
                                 zo_callLater(function()
-                                        hideOut(WellEaterIndicatorWeaponLabel, WellEater.WeaponAnimOut)
+                                    hideOut(WellEaterIndicatorWeaponLabel, WellEater.WeaponAnimOut)
                                 end, 1500)
                             end
                             break
@@ -417,15 +418,13 @@ local function InitOnLoad(_, addonName)
     EVENT_MANAGER:RegisterForEvent(
             WellEater.AddonName,
             EVENT_PLAYER_ACTIVATED,
-            function(_, initial)
-                if initial then
-                    if not WellEater:isAddonEnabled() then
-                        return
-                    end
-
-                    --d(WellEater.AddonName .. " Active")
-                    StartUp()
+            function()
+                if not WellEater:isAddonEnabled() then
+                    return
                 end
+
+                --d(WellEater.AddonName .. " Active")
+                StartUp()
             end
     )

@@ -442,6 +441,34 @@ local function InitOnLoad(_, addonName)
             end
     )

+    -- EVENT_CHATTER_BEGIN
+    EVENT_MANAGER:RegisterForEvent(
+            WellEater.AddonName,
+            EVENT_CHATTER_BEGIN,
+            function()
+                if not WellEater:isAddonEnabled() then
+                    return
+                end
+                NAMESPACE.conversation = true
+                -- df("[%s] %s",WellEater.AddonName, " Iteraction begin")
+                ShutDown()
+            end
+    )
+    --  EVENT_CHATTER_END
+    EVENT_MANAGER:RegisterForEvent(
+            WellEater.AddonName,
+            EVENT_CHATTER_END,
+            function()
+                if not WellEater:isAddonEnabled() or not NAMESPACE.conversation then
+                    -- df("[%s] %s",WellEater.AddonName, "Not in conversation")
+                    return
+                end
+                NAMESPACE.conversation = false
+                -- df("[%s] %s",WellEater.AddonName," Iteraction end")
+                StartUp()
+            end
+    )
+
     EVENT_MANAGER:RegisterForEvent(WellEater.AddonName, EVENT_LUA_ERROR, OnUIError)

     -- local lamPanel =
diff --git a/WellEater.txt b/WellEater.txt
index 7f40cce..ef149d8 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.
-## Version: 1.0.4
+## Version: 1.0.5
 ## SavedVariables: WellEater_Settings
 ## DependsOn: LibAddonMenu-2.0>=28