ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Lua/XML Help (https://www.esoui.com/forums/forumdisplay.php?f=175)
-   -   Compass Events (https://www.esoui.com/forums/showthread.php?t=2030)

unLeashed3k 07/28/14 01:08 PM

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?

Fyrakin 07/28/14 01:45 PM

Quote:

Originally Posted by unLeashed3k (Post 10918)
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.

unLeashed3k 07/28/14 01:48 PM

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?

Garkin 07/28/14 01:50 PM

Quote:

Originally Posted by unLeashed3k (Post 10918)
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

Fyrakin 07/28/14 01:54 PM

Quote:

Originally Posted by unLeashed3k (Post 10920)
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])

Fyrakin 07/28/14 01:56 PM

Quote:

Originally Posted by Garkin (Post 10921)
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.

Garkin 07/28/14 01:57 PM

Quote:

Originally Posted by Fyrakin (Post 10923)
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.

unLeashed3k 07/28/14 02:09 PM

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. =)

unLeashed3k 07/28/14 02:35 PM

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.

Garkin 07/28/14 02:44 PM

Quote:

Originally Posted by unLeashed3k (Post 10926)
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.

ZO_CompassContainer is not a function, its a control. So it does not return anything.

Fyrakin wrote that you have to check its children controls, it means something like:
Lua Code:
  1. for i = 1, ZO_CompassContainer:GetNumChildren() do
  2.    local control = ZO_CompassContainer:GetChild(i)
  3.    if control:GetName() == "whatever" then --I have no idea what is the name of compass pin, so...
  4.    end
  5. end

unLeashed3k 07/28/14 03:37 PM

Lua Code:
  1. function YYZ.doIt()
  2.     for i = 1, ZO_CompassContainer:GetNumChildren() do
  3.        local description, type, distance, drawLayer, suppressed = ZO_CompassContainer:GetCenterOveredPinInfo(i)
  4.        if description ~= "" then
  5.            d(string.format("%s is type: %d", description, type))
  6.         end
  7.     end
  8. end

So happy! Got this outputting what I want to get started. Thank you a million times for getting me on track. I'll try to keep the amateur questions to a minimum now that I have one foothold on this mountain. ha!

Edit: just wish there was a function to gather all marker pins on the compass rather than just the markers the avatar is directly facing; something like ZO_CompassContainer:GetAllPinInfo()

Fyrakin 07/28/14 04:53 PM

Quote:

Originally Posted by unLeashed3k (Post 10929)
Lua Code:
  1. function YYZ.doIt()
  2.     for i = 1, ZO_CompassContainer:GetNumChildren() do
  3.        local description, type, distance, drawLayer, suppressed = ZO_CompassContainer:GetCenterOveredPinInfo(i)
  4.        if description ~= "" then
  5.            d(string.format("%s is type: %d", description, type))
  6.         end
  7.     end
  8. end

So happy! Got this outputting what I want to get started. Thank you a million times for getting me on track. I'll try to keep the amateur questions to a minimum now that I have one foothold on this mountain. ha!



Edit: just wish there was a function to gather all marker pins on the compass rather than just the markers the avatar is directly facing; something like ZO_CompassContainer:GetAllPinInfo()

Well, Compass doesn't hold that much info, you would need ZO_WorldMapContainer, which holds all pins.

unLeashed3k 07/28/14 05:11 PM

Quote:

Originally Posted by Fyrakin (Post 10931)
Well, Compass doesn't hold that much info, you would need ZO_WorldMapContainer, which holds all pins.

Is there any type of documentation on all these [no clue what they are] controls?

What I truly need is a method to try all these functions and controls within an basic/universal example program. I'm extremely frustrated because I believe I'm looking at how everything works completely backwards.

Looking at http://wiki.esoui.com/Userdata_in_100007_API I can't figure out what they return (or contain). Are these all objects? If so, how do I look at them? Every function I use on them returns nil or an error (userdata).

Edit: How about that. Getting output now of ZO_MapPin1 through 50. Now to figure out how to map the globals to what they really are.

Garkin 07/28/14 09:41 PM

Quote:

Originally Posted by unLeashed3k (Post 10933)
Is there any type of documentation on all these [no clue what they are] controls?

What I truly need is a method to try all these functions and controls within an basic/universal example program. I'm extremely frustrated because I believe I'm looking at how everything works completely backwards.

Looking at http://wiki.esoui.com/Userdata_in_100007_API I can't figure out what they return (or contain). Are these all objects? If so, how do I look at them? Every function I use on them returns nil or an error (userdata).

Edit: How about that. Getting output now of ZO_MapPin1 through 50. Now to figure out how to map the globals to what they really are.

Controls are objects.
http://wiki.esoui.com/Controls

Working code:
Lua Code:
  1. EVENT_MANAGER:RegisterForEvent("QuestOffers", EVENT_ADD_ON_LOADED,
  2.    function(event, addonName)
  3.       if (addonName):find("^ZO_") then return end
  4.       EVENT_MANAGER:UnregisterForEvent("QuestOffers", event)
  5.  
  6.       local time_between_alerts = 5000 --in milliseconds
  7.       local lastDescription, nextAlert
  8.       ZO_PreHookHandler(COMPASS.container, "OnUpdate",
  9.          function(self)
  10.             local now = GetFrameTimeMilliseconds()
  11.             if now < COMPASS.nextLabelUpdateTime then
  12.                return true
  13.             end
  14.  
  15.             --do not show alerts when boss bar is active
  16.             if BOSS_BAR.control:IsHidden() then
  17.                for i = 1, self:GetNumCenterOveredPins() do
  18.                   local description, pinTypeId = self:GetCenterOveredPinInfo(i)
  19.                   if pinTypeId == MAP_PIN_TYPE_QUEST_OFFER and (lastDescription ~= description or nextAlert < now) then
  20.                      CENTER_SCREEN_ANNOUNCE:DisplayMessage(CSA_EVENT_SMALL_TEXT, SOUNDS.QUEST_FOCUSED, "Quest offer: " .. ZO_ERROR_COLOR:Colorize(description))
  21.                      lastDescription = description
  22.                      nextAlert = now + time_between_alerts
  23.                   end
  24.                end
  25.             end
  26.  
  27.          end)
  28.  
  29.    end)

katkat42 07/28/14 10:14 PM

Quote:

Originally Posted by unLeashed3k (Post 10933)
Looking at http://wiki.esoui.com/Userdata_in_100007_API I can't figure out what they return (or contain). Are these all objects? If so, how do I look at them?

If you haven't already, download and install the zgoo addon. It lets you inspect the whole UI environment.

unLeashed3k 07/29/14 04:02 PM

Quote:

Originally Posted by Garkin (Post 10937)
Controls are objects.
http://wiki.esoui.com/Controls

Working code

It does! Thank you and it's helpful. I have hundreds of questions so I'm going to ask zero of them. =)

unLeashed3k 07/31/14 03:36 PM

1 Attachment(s)
Attachment 373

I have to resign attempting to accomplish what I want to do. There is no way, I know of, to capture pins on the compass unless I directly "faced" the pin (and even then I have to run a pretty heavy polling function). The pin does exists on the compass before "facing" it (picture shows it off to the right side) but it's far beyond me how to iterate through all pins on the compass.

I kept banging my head against this problem solely because the fact that "if it's displayed on my compass it must be somewhere in the GUI elements."

Anyways, I started writing a new addon, successfully! (lol), that tracks player coordinates and displays a "Road Sign" (just a ToolTip, actually) on [s]keyPress[/s] slash_cmd when the user enters a polygon. I check all vertices and notifications are sent to the user there's a Road Sign ahead if they are within the polygons boundaries. I still need to make the slash_cmd hotKeyed for the ToolTip/Road Sign. I have feeling my road_sign_tbl is going to be gigantic. =)

unLeashed3k 08/02/14 02:05 PM

Quote:

Originally Posted by Garkin (Post 10927)
Lua Code:
  1. for i = 1, ZO_CompassContainer:GetNumChildren() do
  2.    local control = ZO_CompassContainer:GetChild(i)
  3.    if control:GetName() == "whatever" then --I have no idea what is the name of compass pin, so...
  4.    end
  5. end

This object created holds the exact information I want for my addon, I know it, but it will not allow me to access the information.

In /zgoo "GetChild(index)" for ZO_CompassContainer says it's BLACKLISTED. Does that mean it's private?

Fyrakin 08/02/14 02:27 PM

Quote:

Originally Posted by unLeashed3k (Post 11035)
This object created holds the exact information I want for my addon, I know it, but it will not allow me to access the information.

In /zgoo "GetChild(index)" for ZO_CompassContainer says it's BLACKLISTED. Does that mean it's private?

ZO_CompassContainer:GetChild() - will be BLACKLISTED, because you have to specify index
if there are ZO_CompassContainer:GetNumChildren() > 0 then you can do the following:
Code:

local numChildren = ZO_CompassContainer:GetNumChildren()
        for index=1, numChildren do
                compassPin = ZO_CompassContainer:GetChild(index)
                if compassPin ~= nil then
                        -- do whatever you want with the compassPin child object here
                end
        end


unLeashed3k 08/02/14 03:09 PM

Lua Code:
  1. local zzz_numChildren = ZO_CompassContainer:GetNumChildren()
  2.    local zzz_string = ""
  3.    d("The number of children: "..zzz_numChildren.."\n -----")
  4.  
  5.    for index = 1, zzz_numChildren do
  6.       zzz_compassPin = ZO_CompassContainer:GetChild(index)
  7.       if zzz_compassPin ~= nil then
  8.          zzz_string = zzz_compassPin:GetName()
  9.          d(index..": "..zzz_string)
  10.       else
  11.          d(index..": nil")
  12.       end
  13.    end

Result:
Code:

The number of children: 67
-----
1: nil
2: nil
[ ... ]
66: nil
67: nil

You, and everyone that has responded and helped me I am incredibly grateful for but I have to give up (I think I already said that once already hehe). All I ever get in the simplest of code is a nil result.


All times are GMT -6. The time now is 01:16 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI