Thread Tools Display Modes
06/23/21, 03:31 PM   #1
NeuroticPixels
Addon Addict
 
NeuroticPixels's Avatar
Premium Member
Join Date: May 2019
Posts: 211
Question Zone Change Notification In Chat

Would it be possible to give zone change notifications in chat? Even something as simple as "Zone Changed."
A lot of the time, I'm wondering if something said in zone chat was in the zone I was in prior to using a wayshrine, or if what was said was done so in the new zone I'm in.
...If that makes sense...

More often than I'd like to admit, I answer people's questions I see in zone chat...... but I've already left the area and didn't realize my answer isn't going to the right zone! LOL
  Reply With Quote
06/23/21, 04:12 PM   #2
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,964
EVENT_PLAYER_ACTIVATED will be called after login and after a zone change where a loading screen occured.
So you can use this event to output a text to chat as this happens.

Lua Code:
  1. EVENT_MANAGER:RegisterForEvent("MyUnqueAddonName_Event_Player_Activated", EVENT_PLAYER_ACTIVATED, function(eventId,wasFirst)
  2.   --wasFirst is true if it was the first event call, should be after login
  3.   local zoneName = ZO_CachedStrFormat("<<C:1>>", GetZoneNameByIndex(GetCurrentMapZoneIndex()))
  4.  
  5.   if not wasFirst then
  6.      d("=========\nZone changed to: " ..zoneName)
  7.   else
  8.     d("=========\nLogged in at: " ..zoneName)
  9.   end
  10. end)

Add this to any addon's EVENT_ADD_ON_LOADED callback function, at the end of it, and you should have your output.

You can change the ====== at the start of the String if you like to. I only added them so you are easily able to see where in the chat the change has taken place. The \n means a line break.

Last edited by Baertram : 06/23/21 at 04:18 PM.
  Reply With Quote
06/23/21, 04:20 PM   #3
NeuroticPixels
Addon Addict
 
NeuroticPixels's Avatar
Premium Member
Join Date: May 2019
Posts: 211
That's great!
Now is there anyone that would put this feature in their addon?
Hehe.
  Reply With Quote
06/23/21, 04:48 PM   #4
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,964
Originally Posted by LoneStar2911 View Post
That's great!
Now is there anyone that would put this feature in their addon?
Hehe.
Use the template addon provided by Phuein e.g., just put that into the EVENT_ADD_ON_LOADED callback function,
rename the folder and txt file to something else, like LoneStarTweaks and you got your addon ready ;-)

Or just create 2 empty files in a folder "LoneStarTweaks" in your live/AddOns folder.
1 txt named LoneStarTweaks.txt containing this info:
Code:
## Version: 1
## AddOnVersion: 001
## APIVersion: 100035 101031
## Description: My personal tweaks

LoneStarTweaks.lua
And 1 lua file named "LoneStarTweaks.lua" containing this:
Lua Code:
  1. local function LoneStarTweaks_Loaded(eventId, addOnName)
  2.     if addOnName ~= "LoneStarTweaks" then return end
  3.     EVENT_MANAGER:UnregisterForEvent("LoneStarTweaks_Event_Add_On_Loaded", EVENT_ADD_ON_LOADED)
  4.  
  5.     EVENT_MANAGER:RegisterForEvent("LoneStarTweaks_Event_Player_Activated", EVENT_PLAYER_ACTIVATED,
  6.         function(eventIdPA, wasFirst)
  7.             --wasFirst is true if it was the first event call, should be after login
  8.             local zoneName = ZO_CachedStrFormat("<<C:1>>", GetZoneNameByIndex(GetCurrentMapZoneIndex()))
  9.             if not wasFirst then
  10.                 d("=========\nZone changed to: " ..zoneName)
  11.             else
  12.                 d("=========\nLogged in at: " ..zoneName)
  13.             end
  14.         end)
  15. end
  16. EVENT_MANAGER:RegisterForEvent("LoneStarTweaks_Event_Add_On_Loaded", EVENT_ADD_ON_LOADED, LoneStarTweaks_Loaded)

Save, /reloadui ingame.

Last edited by Baertram : 06/23/21 at 06:52 PM.
  Reply With Quote
06/23/21, 05:24 PM   #5
NeuroticPixels
Addon Addict
 
NeuroticPixels's Avatar
Premium Member
Join Date: May 2019
Posts: 211
I did that, and got this when I logged in (still in a public dungeon):
Code:
user:/AddOns/LoneStarTweaks/LoneStarTweaks.lua:3: function expected instead of nil
stack traceback:
user:/AddOns/LoneStarTweaks/LoneStarTweaks.lua:3: in function 'LoneStarTweaks_Loaded'
|caaaaaa<Locals> eventId = 65536, addOnName = "LoneStarTweaks" </Locals>|r
  Reply With Quote
06/23/21, 06:52 PM   #6
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,964
EVENT_MANAGER:UnegisterForEvent

Typo, missing an r for Unregister

Last edited by Baertram : 06/24/21 at 03:08 AM.
  Reply With Quote
06/23/21, 07:36 PM   #7
NeuroticPixels
Addon Addict
 
NeuroticPixels's Avatar
Premium Member
Join Date: May 2019
Posts: 211
Originally Posted by Baertram View Post
EVENT_MANAGER:UnegisterForEvent

Typo, missing and r for Unregister
lol, I even looked for typos and I missed that. Should've looked on line 3 like the error tried to tell me... Derp.

Thank you for your patience and your help. <3

Edit: Also switched places for =========\nLogged in at: and =========\nZone changed to:
Those seemed in the wrong places.

Last edited by NeuroticPixels : 06/23/21 at 09:06 PM.
  Reply With Quote
06/23/21, 09:29 PM   #8
NeuroticPixels
Addon Addict
 
NeuroticPixels's Avatar
Premium Member
Join Date: May 2019
Posts: 211
Hmmm. Is there another code or whatnot that needs to be added for public dungeons?
Earlier, I got a message that I went into Inner Sea Armature (delve).
But when I go into Bad Man's Hallows (public dungeon), I only get "Zone changed to: Glenumbra".
  Reply With Quote
06/24/21, 03:04 AM   #9
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,964
GetCurrentMapZoneIndex returns an index and GetZoneNameByIndex returns the string with the name.
Seems PD returns the index of the parentMap then somehow instead of the current map. There also exist other API functions to get the Parent zone index, and this is what I would have expected to return Glenumbra's index then....


It's hard to detect PD, there is no API function like IsInPublicDungeon, and IsUnitInDungen("player") returns true for delves, PDs, group dungeons etc.
There is a difficulty function returning 1 (delve, PD) or 2 (group dungeon) but nothing to definately say "you are in a PD".
In the past one was able to "somehow reliably identify" this by checking the map texture name (the .dds file of the current map) as it often contained something like "public_dungeon". But even this has changed I think (for newer DLCs).
So I would not know how to detect the current zone name differently for the PDs.
  Reply With Quote
06/24/21, 03:14 AM   #10
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,964
Also switched places for =========\nLogged in at: and =========\nZone changed to:
Those seemed in the wrong places.
The 2nd parameter I had named "wasFirst" (offical name is "initial") should be true if you first login. And false for any later execution of the event.
So switching them would be wrong!
I think my "if not wasFirst then" was wrong

Try it like this:
Lua Code:
  1. if wasFirst == true then
  2.       d("=========\nLogged in at: " ..zoneName)
  3.    else
  4.       d("=========\nZone changed to: " ..zoneName)
  5.    end

Last edited by Baertram : 06/24/21 at 03:55 PM.
  Reply With Quote
06/24/21, 01:49 PM   #11
NeuroticPixels
Addon Addict
 
NeuroticPixels's Avatar
Premium Member
Join Date: May 2019
Posts: 211
It just keeps telling me "logged in at:" whenever I log in or change zones. It never tells me "Zone changed to:".

Code:
local function LoneStarTweaks_Loaded(eventId, addOnName)
    if addOnName ~= "LoneStarTweaks" then return end
    EVENT_MANAGER:UnregisterForEvent("LoneStarTweaks_Event_Add_On_Loaded", EVENT_ADD_ON_LOADED)
 
    EVENT_MANAGER:RegisterForEvent("LoneStarTweaks_Event_Player_Activated", EVENT_PLAYER_ACTIVATED,
        function(eventIdPA, wasFirst)
            --wasFirst is true if it was the first event call, should be after login
            local zoneName = ZO_CachedStrFormat("<<C:1>>", GetZoneNameByIndex(GetCurrentMapZoneIndex()))
            if wasFirst then
                d("=========\nLogged in at: " ..zoneName)
            else
                d("=========\nZone changed to: " ..zoneName)
            end
        end)
end
EVENT_MANAGER:RegisterForEvent("LoneStarTweaks_Event_Add_On_Loaded", EVENT_ADD_ON_LOADED, LoneStarTweaks_Loaded)

Last edited by NeuroticPixels : 06/24/21 at 02:31 PM.
  Reply With Quote
06/24/21, 02:42 PM   #12
NeuroticPixels
Addon Addict
 
NeuroticPixels's Avatar
Premium Member
Join Date: May 2019
Posts: 211
I try with the one line, and I get this error:
Code:
user:/AddOns/LoneStarTweaks.lua:11 ) expected (to close ( at line 5) near 'end'
I tried to figure it out myself... Added the ) on line 11, but then it wanted the , removed as well. And then when I removed the , it wanted even more things changed! AAAHHHH! lol

Edit:

For now, I'm just going to use:

Code:
local function LoneStarTweaks_Loaded(eventId, addOnName)
    if addOnName ~= "LoneStarTweaks" then return end
    EVENT_MANAGER:UnregisterForEvent("LoneStarTweaks_Event_Add_On_Loaded", EVENT_ADD_ON_LOADED)
 
    EVENT_MANAGER:RegisterForEvent("LoneStarTweaks_Event_Player_Activated", EVENT_PLAYER_ACTIVATED,
        function(eventIdPA, wasFirst)
            --wasFirst is true if it was the first event call, should be after login
            local zoneName = ZO_CachedStrFormat("<<C:1>>", GetZoneNameByIndex(GetCurrentMapZoneIndex()))
            if wasFirst then
                d("=================\nZone Changed To: " ..zoneName)
            else
                d("=================\nZone Changed To: " ..zoneName)
            end
        end)
end
EVENT_MANAGER:RegisterForEvent("LoneStarTweaks_Event_Add_On_Loaded", EVENT_ADD_ON_LOADED, LoneStarTweaks_Loaded)
I don't need a different notification for logging in versus changing zones. I just need a note in chat to remind me that I've changed zones and can no longer respond to the same zone chat.
Because I'm ADD and forgetful. LOL

Last edited by NeuroticPixels : 06/24/21 at 02:49 PM.
  Reply With Quote
06/24/21, 03:55 PM   #13
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,964
If youdo not want to differ then just change it to
Code:
                d("=================\nZone Changed To: " ..zoneName)
Without the if ... else ... end
  Reply With Quote

ESOUI » AddOns » AddOn Search/Requests » Zone Change Notification In Chat


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