WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Map POI Tracking (https://www.wowinterface.com/forums/showthread.php?t=52412)

Resike 06-25-15 10:58 AM

Map POI Tracking
 
I have create a small hook, to hide the stuck Draenor treasures from the world map:

Lua Code:
  1. hooksecurefunc("WorldMapFrame_Update", function(self)
  2.     for i = 1, GetNumMapLandmarks() do
  3.         local poi = _G["WorldMapFramePOI"..i]
  4.         local poiTexture = _G["WorldMapFramePOI"..i.."Texture"]
  5.         if poi and poiTexture then
  6.             local ULx, ULy, LLx, LLy, URx, URy, LRx, LRy = poiTexture:GetTexCoord()
  7.             if ULx == 0.07421875 and ULy == 0.494140625 and LLx == 0.07421875 and LLy == 0.52734375 and URx == 0.140625 and URy == 0.494140625 and LRx == 0.140625 and LRy == 0.52734375 then
  8.                 poi:Hide()
  9.             end
  10.         end
  11.     end
  12. end)

Is it possible to add this function to the World Map Frame's Tracking dropdown as "Show Trasures" as a toggle?

myrroddin 06-25-15 11:15 AM

Quote:

Originally Posted by Resike (Post 309408)
Is it possible to add this function to the World Map Frame's Tracking dropdown as "Show Trasures" as a toggle?

Not sure about your question, but probably. I'm not actively playing WoW to test code.

However, I see an unnecessary global lookup, where you already have a local to do the job:
Lua Code:
  1. local poi = _G["WorldMapFramePOI"..i]
  2. local poiTexture = _G["WorldMapFramePOI"..i.."Texture"] -- right here
Replace with:
Lua Code:
  1. local poi = _G["WorldMapFramePOI"..i]
  2. local poiTexture = poi.."Texture"
Unless for some reason the texture lookup won't work in that manner?

Resike 06-25-15 11:50 AM

Quote:

Originally Posted by myrroddin (Post 309410)
Not sure about your question, but probably. I'm not actively playing WoW to test code.

However, I see an unnecessary global lookup, where you already have a local to do the job:
Lua Code:
  1. local poi = _G["WorldMapFramePOI"..i]
  2. local poiTexture = _G["WorldMapFramePOI"..i.."Texture"] -- right here
Replace with:
Lua Code:
  1. local poi = _G["WorldMapFramePOI"..i]
  2. local poiTexture = poi.."Texture"
Unless for some reason the texture lookup won't work in that manner?

It would probably work, but it's even better just to remove/ignore the poi frame.

Choonstertwo 06-25-15 12:28 PM

Quote:

Originally Posted by myrroddin (Post 309410)
Not sure about your question, but probably. I'm not actively playing WoW to test code.

However, I see an unnecessary global lookup, where you already have a local to do the job:
Lua Code:
  1. local poi = _G["WorldMapFramePOI"..i]
  2. local poiTexture = _G["WorldMapFramePOI"..i.."Texture"] -- right here
Replace with:
Lua Code:
  1. local poi = _G["WorldMapFramePOI"..i]
  2. local poiTexture = poi.."Texture"
Unless for some reason the texture lookup won't work in that manner?

Resike's code is getting the WorldMapFramePOI1 and WorldMapFramePOI1Texture objects, your code is getting the WorldMapFramePOI1 object and then attempting to concatenate that with the "Texture" string (which won't work).

semlar 06-25-15 12:31 PM

_G["WorldMapFramePOI"..i] is a reference to a frame, you can't concatenate a string onto that.

I would be very surprised if your condition comparing texture coordinates to floats actually worked because of the way lua tends to round numbers.

Also, I suspect attempting to add anything to any Blizzard dropdown menu is just going to break something unrelated with taint since it recycles those dropdown menus for secure functions.

Resike 06-25-15 12:52 PM

Quote:

Originally Posted by semlar (Post 309413)
_G["WorldMapFramePOI"..i] is a reference to a frame, you can't concatenate a string onto that.

I would be very surprised if your condition comparing texture coordinates to floats actually worked because of the way lua tends to round numbers.

Also, I suspect attempting to add anything to any Blizzard dropdown menu is just going to break something unrelated with taint since it recycles those dropdown menus for secure functions.

I was about to cut the numbers, but it's not needed works fine.


All times are GMT -6. The time now is 05:22 AM.

vBulletin © 2020, Jelsoft Enterprises Ltd
© 2004 - 2020 MMOUI