Wowpedia

We have moved to Warcraft Wiki. Click here for information and the new URL.

READ MORE

Wowpedia
Line 4: Line 4:
 
NOTE: This appears to have issues with the advent of Patch 3.0.2
 
NOTE: This appears to have issues with the advent of Patch 3.0.2
 
It seems to be only working intermittently.
 
It seems to be only working intermittently.
  +
  +
Until you open the world map, this always seems to return (0,0). <br>
  +
After you open and close the world map, the coords return the correct values. <br>
  +
  +
Start your code with the following two lines in your OnInitialize Section: <br>
  +
WorldMapFrame:Show() <br>
  +
WorldMapFrame:Hide() <br>
   
 
==Usage==
 
==Usage==

Revision as of 00:42, 13 December 2008

Patch 3.0.2

NOTE: This appears to have issues with the advent of Patch 3.0.2 It seems to be only working intermittently.

Until you open the world map, this always seems to return (0,0).
After you open and close the world map, the coords return the correct values.

Start your code with the following two lines in your OnInitialize Section:
WorldMapFrame:Show()
WorldMapFrame:Hide()

Usage

Returns the position of a unit on the current map

posX, posY = GetPlayerMapPosition("unit");

Parameters

Arguments

unit
String - The unitId for which the position is returned. Does not work with all unit types. Works with "player", "partyN" or "raidN" as unit type. In particular, it does not work on pets. This was to disable range-checking mods.

Returns

posX, posY
posX
Number - X value of the unit position (a proportion between 0 and 1, relative to WorldMapDetailFrame)
posY
Number - Y value of the unit position (a proportion between 0 and 1, relative to WorldMapDetailFrame)
If both posX and posY are exactly 0, the position is unknown, unknowable, or not valid for the current map, i.e.
  • The player is inside an instance: the game will never return coordinates inside an instance. (CHANGED AS OF 3.0.1 - coordinates are returned within instances)
  • The map hasn't been updated yet; either open the map or use SetMapToCurrentZone() after entering a new zone
  • An unsupported unitId was given.
  • You're actually at 0,0 in a given map, which although its unlikely, its perfectly possible and legal.

Example

local posX, posY = GetPlayerMapPosition("player");

Result

0.43320921063423, 0.69365233182907