Thread Tools Display Modes
04/25/15, 08:19 PM   #1
hisdad
AddOn Author - Click to view addons
Join Date: Dec 2014
Posts: 33
Finding Current Location

Hi, I'm trying to keep track of area the char is in. GetMapName() is pretty good, except that it doesn't
distinguish between Davon's watch and Steamfont Cavern, for example.

The EVENT_ZONE_CHANGED seems useless, it's triggered going near a wayshrine and its naming doesn't seem consistant with GetMapName()

Does anyone have advice?
--Dad
  Reply With Quote
04/26/15, 05:05 AM   #2
Ayantir
 
Ayantir's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 1,019
You got

Lua Code:
  1. local zone, subzone = select(3,(GetMapTileTexture()):lower():find("maps/([%w%-]+)/([%w%-]+_[%w%-]+)"))

from Garkin,

Or http://www.esoui.com/downloads/info601-LibGPS.html from sirinsidiator.
  Reply With Quote
04/26/15, 06:19 AM   #3
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
http://www.esoui.com/forums/showthre...=8875#post8875
  Reply With Quote
04/26/15, 02:46 PM   #4
Sasky
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 231
Originally Posted by hisdad View Post
The EVENT_ZONE_CHANGED seems useless, it's triggered going near a wayshrine and its naming doesn't seem consistant with GetMapName()
The EVENT_ZONE_CHANGED fires whenever the zone OR subzone changes. Wayshrine counts as a different subzone, and there are several others that fire off. If you're just interested in the main zone, just store that and see if it's changed since the last event to filter it out.

If you are interested in subzones, you could potentially filter out things like wayshrines. However, if someone's running around right along the border between 2 subzones you could have the event firing off a lot. You could filter out repeated changes by something like this:

Lua Code:
  1. local lastTimestamp = 0
  2. local lastZone = ""
  3. local lastSubzone = ""
  4. function onZoneChange()
  5.    lastTimestamp = GetTimeStamp()
  6. end
  7.  
  8. local fuzzAmount= 5 --Number of seconds for zone to be stable
  9. local lastZone = ""
  10. local lastSubzone = ""
  11. --Put this in a 1s or so OnUpdate
  12. function runUpdate()
  13.     if lastTimestamp and GetDiffBetweenTimeStamps(GetTimeStamp(), lastTimestamp) > fuzzAmount then
  14.        local curZone, curSubzone = GetUnitZone("player")
  15.        if curZone ~= lastZone or curSubzone ~= lastSubzone then
  16.            --Fire your actual zone change event
  17.        end
  18.     end
  19. end

Note that it does delay events by 5 seconds, but that's unavoidable if you want to avoid it firing every time you step across a boundry. The higher this 'fuzzAmount', the longer it takes to execute the event, but the fewer repeated fires you'll run across. (Note: it would be possible to fire immediately then block all updates for X seconds. This would need a corrective event update though if someone stepped back into the zone.)
  Reply With Quote
04/28/15, 05:33 PM   #5
hisdad
AddOn Author - Click to view addons
Join Date: Dec 2014
Posts: 33
Thanks Team,

Some good stuff there..

I would never have figured that out..

--Dad
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » Finding Current Location

Thread Tools
Display Modes

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