Thread Tools Display Modes
02-17-14, 03:13 AM   #1
Spawnova
A Warpwood Thunder Caller
 
Spawnova's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2012
Posts: 96
Ping minimap question

Since the function to ping the minimap uses it's own values instead of what GetPlayerMapPosition returns, I'm having trouble pinging the minimap at the location I would like to.

For instance I would like to ping 58,58 on the minimap, but Minimap:PingLocation() uses pixels from the minimaps center rather than coordinates.

If anyone knows how to do this or can point me in the right direction I would appreciate it.
  Reply With Quote
02-17-14, 06:47 AM   #2
Vlad
A Molten Giant
 
Vlad's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2005
Posts: 793
Math is the answer.

You got your x and y coordinates from GetPlayerMapPosition("player")
You got the wanted x and y position you wish to ping.
Some math should help solve the issue!

The important thing here is how PingLocation behaves, since the coordinates are pixel distances relative to the center of the minimap (positive coordinates are above or to the right of the center, negative are below or to the left), and not world coordinates!

This means you need to account for the zoom levels, get the size of the map and calculate where your desired coordinates lie in the minimap scope of coordinates, then finally apply the ping animation.

Working on the answer as I haven't done this particular formula before. By all means if someone else wishes to reply, do it!
__________________
Profile: Curse | Wowhead

Last edited by Vlad : 02-17-14 at 06:55 AM.
  Reply With Quote
02-17-14, 06:50 AM   #3
Spawnova
A Warpwood Thunder Caller
 
Spawnova's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2012
Posts: 96
Yea I've been working on it most of this morning, I'm not very good at math when it comes to things like this but I'm still trying to figure it out in the mean time.
  Reply With Quote
02-17-14, 07:00 AM   #4
Vlad
A Molten Giant
 
Vlad's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2005
Posts: 793
*Edit*

I just edited my reply.

Here is what I found out, with Astrolabe this is a really easy thing to do, here is sample code:
Code:
local icon = CreateFrame("Frame")
icon:SetSize(1, 1)

local astrolabe = DongleStub("Astrolabe-1.0")

local function ApplyMinimapMath(x, y)
  local scale = Minimap:GetEffectiveScale()
  x = x/scale
  y = y/scale
  local cx, cy = Minimap:GetCenter()
  x = x - cx
  y = y - cy
  if sqrt(x*x + y*y) < (Minimap:GetWidth()/2) then
    return x, y
  end
end

local function PingLocation(mapID, level, x, y)
  if astrolabe:PlaceIconOnMinimap(icon, mapID, level, x, y) == 0 then
    local x, y = icon:GetCenter()
    local edge = astrolabe:IsIconOnEdge(icon)
    astrolabe:RemoveIconFromMinimap(icon)
    if not edge then
      x, y = ApplyMinimapMath(x, y)
      if x then
        Minimap:PingLocation(x, y)
      end
    end
  end
end

-- pings in the middle of your current map and level
PingLocation(GetCurrentMapAreaID(), GetCurrentMapDungeonLevel(), .5, .5)
You can find the latest version of Astrolabe and DongleStub at:
http://svn.esamynn.org/astrolabe/trunk/
__________________
Profile: Curse | Wowhead

Last edited by Vlad : 02-17-14 at 08:18 AM.
  Reply With Quote
02-17-14, 08:59 AM   #5
Spawnova
A Warpwood Thunder Caller
 
Spawnova's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2012
Posts: 96
Thanks vlad, I appreciate all the help. ^.^

This does a lot more than what I was thinking it will be fun to mess around with it.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Ping minimap question

Thread Tools
Display Modes

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