From 7b999bc91fb6b36c0f0dce033fa84b8dadaefb2a Mon Sep 17 00:00:00 2001 From: Sattva <74269253+Sattva-108@users.noreply.github.com> Date: Thu, 22 May 2025 03:53:40 +0300 Subject: [PATCH] flight-timers: #6 address ping issue --- Leatrix_Plus.lua | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/Leatrix_Plus.lua b/Leatrix_Plus.lua index 2889fee..13458ae 100644 --- a/Leatrix_Plus.lua +++ b/Leatrix_Plus.lua @@ -8038,25 +8038,37 @@ function LeaPlusLC:Player() editFrame:Hide() end - --local PLAYER_ON_TAXI = false + -- Delay a short moment, then start polling taxi state. LibCompat.After(0.1, function() local ticker - ticker = LibCompat.NewTicker(0.1, function() + local seenAirborne = false -- becomes true the first time UnitOnTaxi() returns true + local timeSinceTickerStart = 0 -- Counter for timeout + local MAX_WAIT_TIME = 5 -- Max seconds to wait for flight to start + + ticker = LibCompat.NewTicker(0.1, function(self, elapsed) + local tickDuration = elapsed or 0.1 if UnitOnTaxi("player") then - -- print("ticking") - --PLAYER_ON_TAXI = true - --if PLAYER_ON_TAXI == true then print("register event") end - elseif not UnitOnTaxi("player") then - LibCompat.CancelTimer(ticker) -- stop the timer - --PLAYER_ON_TAXI = false + -- We’re definitely airborne now + seenAirborne = true + return + end + + if seenAirborne then + -- First false after a true → actual landing + LibCompat.CancelTimer(ticker) Leatrix_HandleFlightLanding() - --print("unregister event") - --if PLAYER_ON_TAXI == false then print("unregister event") else print("event still registered") end if LeaPlusLC.FlightProgressBar then LeaPlusLC.FlightProgressBar:Stop() LeaPlusLC.FlightProgressBar = nil end + else + -- Still waiting for that first airborne tick + timeSinceTickerStart = timeSinceTickerStart + tickDuration + if timeSinceTickerStart > MAX_WAIT_TIME then + -- Give up if we never saw UnitOnTaxi turn true + LibCompat.CancelTimer(ticker) + end end end) end)