WoW:API GetPlayerMapPosition: Difference between revisions

m
Move page script moved page API GetPlayerMapPosition to WoW:API GetPlayerMapPosition without leaving a redirect
No edit summary
 
m (Move page script moved page API GetPlayerMapPosition to WoW:API GetPlayerMapPosition without leaving a redirect)
 
(20 intermediate revisions by 18 users not shown)
Line 1: Line 1:
<center>'''GetPlayerMapPosition''' ''-Documentation by [[user:Meog|Meog]]-''</center>
{{wowapi}} __NOTOC__


Returns the postion of a unit on the current map
==Initialization==
A one-time call to [[API SetMapToCurrentZone|SetMapToCurrentZone]]() is required before GetPlayerMapPosition() will return the correct values.


GetPlayerMapPosition(who);
==Usage==
Returns the position of a unit on the current map


----
posX, posY = GetPlayerMapPosition("unit");
;''Arguments''


:String who
== Parameters ==
:;who : Specifies the object for which the position is returned, valid are:<br>"player": current player<br>"party1", "party2", "party3", "party4": one of your group members<br>"target": the current target <small>- can't check, but does only work on friendly units, if ever</small><br>"anyPlayerName": of the player with that name <small>- can't check, but does only work on friendly units, if ever</small>
=== Arguments ===


----
:;unit : String - The [[unitId]] for which the position is returned. Does not work with all unit types. Works with <tt>"player"</tt>, <tt>"party''N''"</tt> or <tt>"raid''N''"</tt> as unit type. In particular, it does not work on pets.  This was to disable range-checking mods.
;''Returns''


:Number posX, Number posY
=== Returns ===
:;posX : x value of the player position (in percent, relative to WorldMapDetailFrame)
:;posY : y value of the player position (in percent, relative to WorldMapDetailFrame)


----
:posX, posY
;''Example''
:;posX : Number - X value of the unit position (a proportion between 0 and 1, relative to WorldMapDetailFrame)
local posX, posY = GetPlayerMapPosition();
:;posY : Number - Y value of the unit position (a proportion between 0 and 1, relative to WorldMapDetailFrame)


;''Result''
: If both posX and posY are exactly 0, the position is unknown, unknowable, or not valid for the current map, i.e.
0.43320921063423, 0.69365233182907
:* The map hasn't been updated yet; either open the map or use [[API SetMapToCurrentZone|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 ==
;''Description''
local posX, posY = GetPlayerMapPosition("player");


:
=== Result ===
Returns the postion of the player (argument) on the current map. (Both values equal zero, when the player is not on the currently shown map.)
0.43320921063423, 0.69365233182907
 
----
{{Template:WoW API}}
Anonymous user