From 9a84e0ef65b6aa41263d13497892ca2bed3cf7a0 Mon Sep 17 00:00:00 2001 From: James Whitehead Ii Date: Fri, 25 Jan 2008 11:14:55 +0000 Subject: [PATCH] * Fix for the crazy arrow --- TomTom_CrazyArrow.lua | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/TomTom_CrazyArrow.lua b/TomTom_CrazyArrow.lua index c6faa28..f5468ef 100644 --- a/TomTom_CrazyArrow.lua +++ b/TomTom_CrazyArrow.lua @@ -8,17 +8,29 @@ local Astrolabe = DongleStub("Astrolabe-0.4") -local twopi = math.pi * 2 - -local playerModel -local children = { Minimap:GetChildren() } -for idx,child in ipairs(children) do - if child:IsObjectType("Model") and child:GetModel() == "Interface\\Minimap\\MinimapArrow" then - playerModel = child - break +local GetPlayerBearing +function GetPlayerBearing() + local obj; -- Remains an upvalue + do + local t = {Minimap:GetChildren()}; -- Becomes garbage + for k, v in pairs(t) do + if v:IsObjectType("Model") and not v:GetName() then + local model = v:GetModel():lower() + if model:match("interface\\minimap\\minimaparrow") then + obj = v; break; + end + end + end end + if not obj then return; end + + -- If we've found what we were looking for, rewrite function to skip the search next time. + GetPlayerBearing = function() return (1-obj:GetFacing()/math.pi/2)*360; end + return GetPlayerBearing(); end +local twopi = math.pi * 2 + local wayframe = CreateFrame("Frame", "TomTomCrazyArrow", UIParent) wayframe:SetHeight(56) wayframe:SetWidth(42) @@ -106,7 +118,7 @@ local function OnUpdate(self, elapsed) end local angle = Astrolabe:GetDirectionToIcon(active_point) - local player = playerModel:GetFacing() + local player = GetPlayerBearing() angle = angle - player -- 1.7.9.5