ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   General Authoring Discussion (https://www.esoui.com/forums/forumdisplay.php?f=174)
-   -   API Docu mistakes? (https://www.esoui.com/forums/showthread.php?t=1110)

Asto 04/23/14 02:41 AM

Chat Event with wrong parameters in api docs?
 
Hello,

i've developed a few smaller WoW AddOns years ago and now wanted to start with ESO again. While fooling around with the API, i guess i found a few mistakes:

EVENT_CHAT_MESSAGE_CHANNEL (integer messageType, string fromName, string text)
is wrong. I get more parameters in my event handler function, sth like

EVENT_CHAT_MESSAGE_CHANNEL (integer messageType, integer channelId, string fromName, string text)

Another thing i found out: The channelId values slightly differ from the wiki page Raw_globals_dump. While CHAT_CHANNEL_ZONE is correctly 31 in my handler, the guild chat channelIds seem to be different.
CHAT_CATEGORY_GUILD_1 is 12 instead of 10,
CHAT_CATEGORY_GUILD_2 is 13 instead of 11
(couldn't test more)

Can anyone confirm this? :)

archpoet 04/23/14 02:52 AM

Afaik when you provide a callback to that event, *that* function gets the following args passed along:

(integer eventCode, integer messageType, string fromName, string text)

messageType *should* actually be the channelId
and eventCode is actually unique* for that specific channel (messageType)

...hence the discrepancy between 10 vs 12 for category vs. event.

:)

Asto 04/23/14 03:00 AM

ah i see... the eventCode confused me because it didn't show up in the api and i didn't know messageType should be the channelId - okay ;)

thanks!

archpoet 04/23/14 03:01 AM

My pleasure, happy to help! :)

Seerah 04/23/14 01:25 PM

Let's compare methods between WoW and ESO so that you can get your bearings. :)

In WoW:
Lua Code:
  1. local f = CreateFrame("Frame", nil, UIParent)
  2. f:RegisterEvent("ADDON_LOADED")
  3. f:SetScript("OnEvent", function(self, event, addon)
  4.      if addon == "MyAddon" then
  5.           --do stuff
  6.      end
  7. end)

In ESO:
Lua Code:
  1. local f = CreateTopLevelWindow("MyAddonFrame")
  2. f:RegisterForEvent(EVENT_ADD_ON_LOADED, function(event, addon)
  3.      if addon == "MyFrame" then
  4.           --do stuff
  5.      end
  6. end)

or, you can do it this way in ESO (register your event through the game's EVENT_MANAGER instead of through a frame)
Lua Code:
  1. EVENT_MANAGER:RegisterForEvent("MyAddon", EVENT_ADD_ON_LOADED, function(event, addon)
  2.      if addon == "MyAddon" then
  3.           --do stuff
  4.      end
  5. end)

As you can see, both WoW and ESO pass the event name/code through the event handler before the args that come with the event.

Vuelhering 04/24/14 12:00 AM

Quote:

Originally Posted by Asto (Post 5482)
Another thing i found out: The channelId values slightly differ from the wiki page Raw_globals_dump. While CHAT_CHANNEL_ZONE is correctly 31 in my handler, the guild chat channelIds seem to be different.
CHAT_CATEGORY_GUILD_1 is 12 instead of 10,
CHAT_CATEGORY_GUILD_2 is 13 instead of 11
(couldn't test more)

Can anyone confirm this? :)

The raw globals dump will change (somewhat) every patch. Certainly, many functions will move, but it would make sense that some globals might change. This is why it's a good idea to future-proof by using the variables, and not hard-code it with magic numbers.

Asto 04/24/14 04:12 AM

thank you seerah :D


All times are GMT -6. The time now is 01:03 PM.

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