Thread Tools Display Modes
07/28/14, 01:08 PM   #1
unLeashed3k
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 33
Compass Events

Is there such a thing as compass events?

I've been desperately attempting to figure out a way to access the compass pins (quests, POI, anything and all) when they appear on the compass but I can not find an event to even begin writing my AddOn. Currently, the only thing I want to do is when a Pin becomes visible on the Compass I want to grab what the pin is (pinType perhaps?) and write it (the name) to the chat panel.

I thought this would be extremely simple being it would fire once (event?) but now several days in I'm just spinning in circles trying to put the puzzle together.

Is there any documentation on COMPASS.container or ZO_WorldMap_IsPinGroupShown? Or better yet is there an event fired when a pin shows on the compass?
  Reply With Quote
07/28/14, 01:45 PM   #2
Fyrakin
 
Fyrakin's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 129
Originally Posted by unLeashed3k View Post
Is there such a thing as compass events?

I've been desperately attempting to figure out a way to access the compass pins (quests, POI, anything and all) when they appear on the compass but I can not find an event to even begin writing my AddOn. Currently, the only thing I want to do is when a Pin becomes visible on the Compass I want to grab what the pin is (pinType perhaps?) and write it (the name) to the chat panel.

I thought this would be extremely simple being it would fire once (event?) but now several days in I'm just spinning in circles trying to put the puzzle together.

Is there any documentation on COMPASS.container or ZO_WorldMap_IsPinGroupShown? Or better yet is there an event fired when a pin shows on the compass?
Compass usually not all that big, you can query ZO_CompassContainer for children controlls (Compass Pins) and see if it changes.
  Reply With Quote
07/28/14, 01:48 PM   #3
unLeashed3k
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 33
Would you be kind enough to show me in simple code sample?

Do I make an <OnUpdate> function and poll the GUI for what's actively displayed?
  Reply With Quote
07/28/14, 01:54 PM   #4
Fyrakin
 
Fyrakin's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 129
Originally Posted by unLeashed3k View Post
Would you be kind enough to show me in simple code sample?

Do I make an <OnUpdate> function and poll the GUI for what's actively displayed?
Best practice would be to make a function to check ZO_CompassContainer
and call that function via registration

EVENT_MANAGER:RegisterForUpdate("OnUpdateSomethingYouMade", [number in miliseconds how often to call your function], [your function name])
  Reply With Quote
07/28/14, 01:50 PM   #5
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by unLeashed3k View Post
Is there such a thing as compass events?

I've been desperately attempting to figure out a way to access the compass pins (quests, POI, anything and all) when they appear on the compass but I can not find an event to even begin writing my AddOn. Currently, the only thing I want to do is when a Pin becomes visible on the Compass I want to grab what the pin is (pinType perhaps?) and write it (the name) to the chat panel.

I thought this would be extremely simple being it would fire once (event?) but now several days in I'm just spinning in circles trying to put the puzzle together.

Is there any documentation on COMPASS.container or ZO_WorldMap_IsPinGroupShown? Or better yet is there an event fired when a pin shows on the compass?
There is no such event...

I was playing around with compass in my test addon Compass Distance (http://www.esoui.com/forums/showthread.php?p=9208).

I don't know if it is the best way, but have hooked OnUpdate function:
Lua Code:
  1. ZO_PreHookHandler(COMPASS.container, "OnUpdate",
  2.    function()
  3.       --do stuff
  4.    end)
And from there I'm calling:
Lua Code:
  1. for i = 1, COMPASS.container:GetNumCenterOveredPins() do
  2.    local description, pinType, distance, drawLayer, drawLevel, isSupressed = COMPASS.container:GetCenterOveredPinInfo(i)
  3.       if not isSupressed then
  4.          --do stuff
  5.       end
  6.    end
  7. end
  Reply With Quote
07/28/14, 01:56 PM   #6
Fyrakin
 
Fyrakin's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 129
Originally Posted by Garkin View Post
There is no such event...

I was playing around with compass in my test addon Compass Distance (http://www.esoui.com/forums/showthread.php?p=9208).

I don't know if it is the best way, but have hooked OnUpdate function:
Lua Code:
  1. ZO_PreHookHandler(COMPASS.container, "OnUpdate",
  2.    function()
  3.       --do stuff
  4.    end)
And from there I'm calling:
Lua Code:
  1. for i = 1, COMPASS.container:GetNumCenterOveredPins() do
  2.    local description, pinType, distance, drawLayer, drawLevel, isSupressed = COMPASS.container:GetCenterOveredPinInfo(i)
  3.       if not isSupressed then
  4.          --do stuff
  5.       end
  6.    end
  7. end
That would also work. Just don't forget to return false or compass will not update.
  Reply With Quote
07/28/14, 01:57 PM   #7
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by Fyrakin View Post
That would also work. Just don't forget to return false or compass will not update.
You don't need to return anything, no return value (nil) works the same as if you return false.

Last edited by Garkin : 07/28/14 at 02:08 PM.
  Reply With Quote
07/28/14, 02:09 PM   #8
unLeashed3k
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 33
Hopefully I'll figure this out and I appreciate the help.

My final goal, which is incredible simple (not for me apparently ~laughs~), is to output text to a message box <Label> that a "Quest Giver is near," thus why I am looking to find all compass pins then somehow distinguish between MAP_PIN_TYPE_QUEST_OFFER and all_the_rest.

Again, thank you for a starting point and I hope I'll get it some day. =)
  Reply With Quote
07/28/14, 02:35 PM   #9
unLeashed3k
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 33
Lua Code:
  1. YYZ = {}
  2.  
  3. YYZ.ModName = "ESOunLeashed"
  4.  
  5.  
  6.  
  7. function YYZ.doIt()
  8.     local str = ZO_CompassContainer
  9.     d(string.format("%s", str))
  10. end
  11.  
  12.  
  13. function YYZ.OnAddOnLoaded(event, str)
  14.     if str == YYZ.ModName then
  15.         EVENT_MANAGER:RegisterForUpdate(YYZ.ModName, 1000, YYZ.doIt)
  16.     end
  17. end
  18.  
  19.  
  20. EVENT_MANAGER:RegisterForEvent(YYZ.ModName, EVENT_ADD_ON_LOADED, YYZ.OnAddOnLoaded)

What does ZO_CompassContainer return? My error is something about userdata.
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Compass Events


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