Thread Tools Display Modes
04-03-10, 09:49 PM   #1
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
GetPlayerMapPosition issue

why does GetPlayerMapPosition return 0's if you open the world map and view an area other then the one your in?

why is GetPlayerMapPosition hooked to the world map frame at all?
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
04-04-10, 04:57 AM   #2
Foxlit
A Warpwood Thunder Caller
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 91
Originally Posted by Grimsin View Post
why does GetPlayerMapPosition return 0's if you open the world map and view an area other then the one your in?
Because you're not on the map you're currently viewing.

why is GetPlayerMapPosition hooked to the world map frame at all?
It's not so much tied to the world map frame as it is tied to the map API, which also happens to be what the world map frame is tied to.

Why? Because that API was designed to support the default world map frame in displaying positions of you and your raid members, as opposed to any other purpose.
__________________
... and you do get used to it, after a while.
  Reply With Quote
04-04-10, 07:30 AM   #3
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
yea but one would think that GetPlayerMapPosition would return your position even while viewing another zone.

Is there no work around for the issue? im pretty sure that i saw a cords addon that did not sit on zeros while the world map frame was open. Of course i also noticed that on some maps it does not show 0's but rather returns different cords lol.
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
04-04-10, 08:17 AM   #4
Foxlit
A Warpwood Thunder Caller
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 91
Originally Posted by Grimsin View Post
yea but one would think that GetPlayerMapPosition would return your position even while viewing another zone.
It returns your position on the currently viewed map. If it were to return what you suggest, everyone would appear to be in every zone on the world map.

Is there no work around for the issue? im pretty sure that i saw a cords addon that did not sit on zeros while the world map frame was open. Of course i also noticed that on some maps it does not show 0's but rather returns different cords lol.
Change the world map zone before you query coordinates, and restore it when you're done. If you do that in the event processing cycle of a single frame, the player will be unaware that you ever changed the world map zone.
__________________
... and you do get used to it, after a while.
  Reply With Quote
04-04-10, 08:45 AM   #5
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Question is... Why do you need player coordinates while they're looking at the map?
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
04-04-10, 10:21 AM   #6
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
well because your current cords are displayed below the minimap in my UI. everytime you open the world map to say look at other zones and the quests you have there the cords frame stops showing your cords and shows 00.00 00.00. and strangely for some zones it shows a dif cord all together not 0's.

and i had originally had it where it always showed your current location but a problem was noticed in the fact that when you would try to view certain zones on the world map it would jump back to your current zone. now i took that out but it reads the 00's when viewing the world map. and for a more specific example of what i was talking about with some zones not showing 0's if i go to thunderbluff and i open up the xroads it will change the cords, it does not read 0's but it does not read the proper cords of you current location. Now when i open thousand needles it gives me 0's instead of bogus cords. Also note that when i stand in TB and look at the Xroads it keeps registering movement on the cords frame but its not the right cords lol.

edit - an after thought to better explain serah.... i like to be able to see my current cords while running along looking at the big map to. i keep my world map on minimode all the time dont you?
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]

Last edited by Grimsin : 04-04-10 at 10:26 AM.
  Reply With Quote
04-04-10, 10:23 AM   #7
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
this is what the code looks like right now
Code:
local GUICordsFrame = CreateFrame('Button', "GUICordsFrame", UIParent)
GUICordsFrame:SetPoint("BOTTOM", UIParent, "BOTTOM", 0, 0)
GUICordsFrame:SetHeight(11)
GUICordsFrame:SetWidth(80)
GUICordsFrame:RegisterForClicks('LeftButtonUp', 'RightButtonUp')

local GUICordsFrameBG = GUICordsFrame:CreateTexture(nil, "BACKGROUND")
GUICordsFrameBG:SetTexture(0, 0, 0, .8)
GUICordsFrameBG:SetAllPoints(GUICordsFrame)

local GUICordsFrameText = GUICordsFrame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
GUICordsFrameText:SetPoint("CENTER", GUICordsFrame, "CENTER", 0, 1)
GUICordsFrameText:SetTextColor(1, 1, 1, 1)
GUICordsFrameText:SetFont("Fonts\\FRIZQT__.TTF", 10, "NORMAL")
GUICordsFrameText:SetJustifyH("CENTER")

local UpdateInterval = 0.3
local TimeSinceLastUpdate = 0 
local x,y

GUICordsFrame:SetScript("OnUpdate", function(self, elapsed)
	
	TimeSinceLastUpdate = TimeSinceLastUpdate + elapsed
	
	while (TimeSinceLastUpdate > UpdateInterval) do
	
	x,y = GetPlayerMapPosition("player")

	GUICordsFrameText:SetFormattedText("%.2f  %.2f", 100*x, 100*y)
	
	TimeSinceLastUpdate = TimeSinceLastUpdate - UpdateInterval
	end
	end)
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
04-04-10, 05:36 PM   #8
Foxlit
A Warpwood Thunder Caller
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 91
Code:
local UpdateInterval, TimeSinceLastUpdate, x, y = 0.3, 0;
GUICordsFrame:SetScript("OnUpdate", function(self, elapsed)
	TimeSinceLastUpdate = TimeSinceLastUpdate + elapsed
	while (TimeSinceLastUpdate > UpdateInterval) do
		x,y = GetPlayerMapPosition("player")
		GUICordsFrameText:SetFormattedText("%.2f  %.2f", 100*x, 100*y)
		TimeSinceLastUpdate = TimeSinceLastUpdate - UpdateInterval
	end
end)
Just on a general note, the while loop is entirely pointless and should be replaced by an if. Aside from that, we'll have to save which map is currently displayed, ask for the map of the zone the player is in, query coordinates, and then restore the old map:

lua Code:
  1. local UpdateInterval, TimeSinceLastUpdate, x, y = 0.3, 0;
  2. GUICordsFrame:SetScript("OnUpdate", function(self, elapsed)
  3.     TimeSinceLastUpdate = TimeSinceLastUpdate + elapsed
  4.     if TimeSinceLastUpdate < UpdateInterval then return end
  5.     -- Copy current map state
  6.     local continent, zone, dungeon = GetCurrentMapContinent(), GetCurrentMapZone(), GetCurrentMapDungeonLevel();
  7.     -- Change map to display the zone the player is in.
  8.     SetMapToCurrentZone();
  9.     -- Grab our data
  10.     TimeSinceLastUpdate, x, y = 0, GetPlayerMapPosition("player");
  11.     -- Restore map state based on copied data
  12.     SetMapZoom(continent, zone);
  13.     if dungeon then SetDungeonMapLevel(dungeon); end
  14.     -- Use retrieved coordinates however you like.
  15.     GUICordsFrameText:SetFormattedText("%.2f  %.2f", 100*x, 100*y)
  16. end)
__________________
... and you do get used to it, after a while.

Last edited by Foxlit : 04-04-10 at 05:42 PM.
  Reply With Quote
04-04-10, 08:17 PM   #9
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
the while was to prevent the delay on it returning your location to make the current readout more accurate. Your method worked perfectly btw thank you very much!
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
04-04-10, 08:47 PM   #10
Shadowed
...
Premium Member
Featured
Join Date: Feb 2006
Posts: 387
Originally Posted by Grimsin View Post
why does GetPlayerMapPosition return 0's if you open the world map and view an area other then the one your in?

why is GetPlayerMapPosition hooked to the world map frame at all?
Nearly every (99.99%) of the Blizzard APi's are for Blizzard and used in their UI. The position APi doesn't return coords because then they don't need it to since they only need it when showing the players location on the currently visible map. It wouldn't be very helpful to say the player is at 50/30 when viewing the Icecrown map when they are actually in Wintergrasp.

If the API was designed with addon developers in mind, it would give you x, y and zone. Since it's not, you get the above. A lot of the API's you limitations are due to that.
  Reply With Quote
04-04-10, 10:06 PM   #11
corveroth
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Apr 2006
Posts: 29
Originally Posted by Shadowed View Post
If the API was designed with addon developers in mind, it would give you x, y and zone.
More like, x, y, z, and zone. Z-coords would give a whole new dimension in which you could optimize path-finding for Gatherer, QuestHelper, etc.
  Reply With Quote
04-05-10, 08:00 AM   #12
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
its really surprising that we do not have a z read out already. One would think it would have been necessary for flying at some point.
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
04-05-10, 08:01 AM   #13
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Blizzard has it. But we don't. It has been requested repeatedly. They have reasons for not giving access.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
04-05-10, 08:42 AM   #14
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
im sure they do, as i figured it would be necessary for the flying mounts. What would their reasons be though do you know? Other then the better pathing i cant think of any malicious or over advantageous uses for the z coord output.
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
04-05-10, 10:14 AM   #15
Shadowed
...
Premium Member
Featured
Join Date: Feb 2006
Posts: 387
Originally Posted by Grimsin View Post
im sure they do, as i figured it would be necessary for the flying mounts. What would their reasons be though do you know? Other then the better pathing i cant think of any malicious or over advantageous uses for the z coord output.
Botting I would imagine, since that's why they usually don't want to expose data in the API's.
  Reply With Quote
04-05-10, 12:38 PM   #16
corveroth
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Apr 2006
Posts: 29
Of course, we aren't technically prevented from gathering Z-data. However, it would require a massive amount of manual data gathering, interpolation, and Pythagoras, and as I learned last time I proposed this, it would only work in flyable areas because your xy-speed is constant while you're on the ground (i.e. there's no xy-speed loss from moving vertically, so you can't work out your altitude delta).

Or you could write a program to generate a table from the map files, although I'm not sure how Blizz would feel about that one. Either way, it's a ton of data to be stored.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » GetPlayerMapPosition issue


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off