WoW:USERAPI GetPlayerBearing
Jump to navigation
Jump to search
Template:Localuserfunc Returns the player's current facing bearing based on the rotation of the minimap arrow.
bearing = GetPlayerBearing();
Return values
- bearing
- number [0, 360] - the player's current bearing, 000 being North, 090 East, 180 South and 270 West; nil if the function is unable to determine the bearing.
Example Implementation
local 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() and v:GetModel() == "Interface\\Minimap\\MinimapArrow" then obj = v; break; 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