ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Lua/XML Help (https://www.esoui.com/forums/forumdisplay.php?f=175)
-   -   don't know how to detect zone change (https://www.esoui.com/forums/showthread.php?t=10487)

Shuba00 03/17/23 09:58 AM

don't know how to detect zone change
 
Hello,
I'm new to lua, and I was trying to create an addon, nothing to much complicated.
i wanted to detect EVENT_ZONE_CHANGED, but can't detect anything.

EVENT_MANAGER:RegisterForEvent(NiceT.name, EVENT_EVENT_ZONE_CHANGED , NiceT.OnPlayerZoneChanged)
EVENT_MANAGER:RegisterForEvent(NiceT.name, EVENT_EVENT_ZONE_CHANGED , NiceT.OnPlayerZoneU)

I'm Using this two event manager, and can't see nothing in debug window(just made a little function that when it's called does just d("Hello1") or d("hello2")

Masteroshi430 03/17/23 10:01 AM

Quote:

Originally Posted by Shuba00 (Post 47396)
Hello,
I'm new to lua, and I was trying to create an addon, nothing to much complicated.
i wanted to detect EVENT_ZONE_CHANGED, but can't detect anything.

EVENT_MANAGER:RegisterForEvent(NiceT.name, EVENT_EVENT_ZONE_CHANGED , NiceT.OnPlayerZoneChanged)
EVENT_MANAGER:RegisterForEvent(NiceT.name, EVENT_EVENT_ZONE_CHANGED , NiceT.OnPlayerZoneU)

I'm Using this two event manager, and can't see nothing in debug window(just made a little function that when it's called does just d("Hello1") or d("hello2")

EVENT_EVENT_ZONE_CHANGED -> EVENT_ZONE_CHANGED :rolleyes:

Shuba00 03/17/23 10:05 AM

hey,
ty for the reply, but that was just an error copying here, in the addon is without "double" event_

Masteroshi430 03/17/23 10:32 AM

Quote:

Originally Posted by Shuba00 (Post 47398)
hey,
ty for the reply, but that was just an error copying here, in the addon is without "double" event_

Show the code if you want some help then.

Shuba00 03/17/23 10:43 AM

Quote:

Originally Posted by Masteroshi430 (Post 47399)
Show the code if you want some help then.

NiceT = {
}
NiceT.name = "NiceT"

function NiceT.Initialize()
d("Thanks for using NiceT!")
NiceT.ZN = GetUnitZone("player") --just trying
d(NiceT.ZN)
EVENT_MANAGER:RegisterForEvent(NiceT.name, EVENT_ZONE_CHANGED, NiceT.OnPlayerZoneChanged)
EVENT_MANAGER:RegisterForEvent(NiceT.name, EVENT_ZONE_UPDATE , NiceT.OnPlayerZoneU)
end
function NiceT.OnAddOnLoaded(event, addonName)
if addonName == NiceT.name then
NiceT.Initialize()
end
end




function NiceT.OnPlayerZoneChanged( eventCode, zoneName, subZoneName, newSubzone, zoneId, subZoneId)
d("HELLO2")
end
function NiceT.OnPlayerZoneU( eventCode, unitTag, newZoneName)
d("HELLO1")
end


EVENT_MANAGER:RegisterForEvent(NiceT.name, EVENT_ADD_ON_LOADED, NiceT.OnAddOnLoaded)

Baertram 03/17/23 11:37 AM

Event_zone_changed does not fire for all changed zones afaik, only if you are e.g. inside a city and step out to the worldmap again etc.

Try EVENT_PLAYER_ACTIVATED instead (fires after login, loading screens where you changed a zone etc.). You can do the zone check there, by using
API functions like

Lua Code:
  1. local zoneIndex = GetCurrentMapZoneIndex()
  2. --Either:
  3. local zoneName = zo_strformat(SI_UNIT_NAME, GetZoneNameByIndex(zoneIndex))
  4. --or if you also need the zoneId:
  5. local zoneId = GetZoneId(zoneIndex)
  6. local zoneName = zo_strformat(SI_UNIT_NAME, GetZoneNameById(zoneId))
  7.  
  8. --Parent zoneId is the id of the parent's zone, e.g. if you are inside a delve in Alik'r Desert the zoneId is the one of the delve and the parentZoneId is the one of the zone (e.g. Alik'r)
  9. loca parentZoneId = GetarentZoneId(zoneId)
etc.

Shuba00 03/18/23 06:54 AM

Quote:

Originally Posted by Baertram (Post 47401)
Event_zone_changed does not fire for all changed zones afaik, only if you are e.g. inside a city and step out to the worldmap again etc.

Try EVENT_PLAYER_ACTIVATED instead (fires after login, loading screens where you changed a zone etc.). You can do the zone check there, by using
API functions like

Lua Code:
  1. local zoneIndex = GetCurrentMapZoneIndex()
  2. --Either:
  3. local zoneName = zo_strformat(SI_UNIT_NAME, GetZoneNameByIndex(zoneIndex))
  4. --or if you also need the zoneId:
  5. local zoneId = GetZoneId(zoneIndex)
  6. local zoneName = zo_strformat(SI_UNIT_NAME, GetZoneNameById(zoneId))
  7.  
  8. --Parent zoneId is the id of the parent's zone, e.g. if you are inside a delve in Alik'r Desert the zoneId is the one of the delve and the parentZoneId is the one of the zone (e.g. Alik'r)
  9. loca parentZoneId = GetarentZoneId(zoneId)
etc.


TY :), this helped me a lot

Sharlikran 03/18/23 04:59 PM

ZOS has features that show in the UI such as when you are close to the Wayshrine it mentions which Wayshrine. Maybe you enter a city and it says the name of the city. However, when you exit a city it may trigger something for the UI but the zone's information is still for the city.

There are many places where you will not get accurate information because the developers made it do what they want. Because of that it doesn't really return what I might want for a mod like Lorebooks or for whatever you are doing.

So what's this for? Will you be adding map pins using LibMapPins? Depending on what you need I may have some other options.

remosito 03/20/23 04:33 AM

Quote:

Originally Posted by Baertram (Post 47401)
Event_zone_changed does not fire for all changed zones afaik, only if you are e.g. inside a city and step out to the worldmap again etc.

Try EVENT_PLAYER_ACTIVATED instead (fires after login, loading screens where you changed a zone etc.). You can do the zone check there, by using
API functions like

Lua Code:
  1. local zoneIndex = GetCurrentMapZoneIndex()
  2. --Either:
  3. local zoneName = zo_strformat(SI_UNIT_NAME, GetZoneNameByIndex(zoneIndex))
  4. --or if you also need the zoneId:
  5. local zoneId = GetZoneId(zoneIndex)
  6. local zoneName = zo_strformat(SI_UNIT_NAME, GetZoneNameById(zoneId))
  7.  
  8. --Parent zoneId is the id of the parent's zone, e.g. if you are inside a delve in Alik'r Desert the zoneId is the one of the delve and the parentZoneId is the one of the zone (e.g. Alik'r)
  9. loca parentZoneId = GetarentZoneId(zoneId)
etc.

wow...so glad I checked out this thread...had no idea playeractivated is after map zone changes too

thanks baertram

Shuba00 03/21/23 01:19 PM

Quote:

Originally Posted by remosito (Post 47437)
wow...so glad I checked out this thread...had no idea playeractivated is after map zone changes too

thanks baertram

i used the function GetPlayerActiveSubzoneName() to get the name of the zone/subzone, and that worked for me


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

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