Thread Tools Display Modes
01/19/18, 04:10 PM   #1
Rhyono
AddOn Author - Click to view addons
Join Date: Sep 2016
Posts: 659
Housing Zone Event

I don't seem to be finding the correct way to detect this. Anyone know what event is triggered when you enter a house?
  Reply With Quote
01/19/18, 04:32 PM   #2
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,912
Afaik there is no event for that. Otherwise Mana would log who entered her houses
Maybe "EVENT_ZONE_CHANGED" can help if the zoneName or subZoneName says something else than the ones where the house is located (e.g. Shadowfen).
  Reply With Quote
01/19/18, 04:36 PM   #3
Rhyono
AddOn Author - Click to view addons
Join Date: Sep 2016
Posts: 659
I had wondered about that, so I had thrown a sloppy function together to just output it to chat like so:

lua Code:
  1. function zonedata(code,zonename,subzonename,newsubzone,zoneid,subzoneid)
  2.     d(zonename.." "..subzonename.." "..newsubzone.." "..zoneid.." "..subzoneid)
  3. end
  4.  
  5. EVENT_MANAGER:RegisterForEvent('TEST',EVENT_ZONE_UPDATE,zonedata)

But it didn't do anything. I'm not logged in at the moment, but I'm now wondering if the chat is unloaded at the time of the function call...
  Reply With Quote
01/19/18, 04:43 PM   #4
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,912
Did you put this code into event_player_activated? If not the code was maybe not loaded properly and you need to logut and back in.

You could try to use functions like these here to get the zone info too:

Code:
* GetCurrentMapIndex()
** _Returns:_ *luaindex:nilable* _index_

* GetMapIndexByZoneId(*integer* _zoneId_)
** _Returns:_ *luaindex:nilable* _index_

* GetCyrodiilMapIndex()
** _Returns:_ *luaindex:nilable* _index_

* GetImperialCityMapIndex()
** _Returns:_ *luaindex:nilable* _index_

* GetCurrentMapZoneIndex()
** _Returns:_ *luaindex* _zoneIndex_

* GetZoneNameByIndex(*luaindex* _zoneIndex_)
** _Returns:_ *string* _zoneName_

* GetMapNameByIndex(*luaindex* _mapIndex_)
** _Returns:_ *string* _mapName_

* GetNumMaps()
** _Returns:_ *integer* _numMaps_

* MapZoomOut()
** _Returns:_ *[SetMapResultCode|#SetMapResultCode]* _setMapResult_

* WouldProcessMapClick(*number* _normalizedClickX_, *number* _normalizedClickY_)
** _Returns:_ *bool* _wouldProcess_, *luaindex:nilable* _resultingMapIndex_

* ProcessMapClick(*number* _normalizedClickX_, *number* _normalizedClickY_)
** _Returns:_ *[SetMapResultCode|#SetMapResultCode]* _setMapResult_

* GetMapInfo(*luaindex* _index_)
** _Returns:_ *string* _name_, *[UIMapType|#UIMapType]* _mapType_, *[MapContentType|#MapContentType]* _mapContentType_, *integer* _zoneId_, *string* _description_

* GetZoneDescription(*integer* _zoneIndex_)
** _Returns:_ *string* _description_

* GetZoneNameById(*integer* _zoneId_)
** _Returns:_ *string* _name_

* GetZoneDescriptionById(*integer* _zoneId_)
** _Returns:_ *string* _description_

* GetMapParentCategories(*luaindex* _index_)
** _Uses variable returns..._
** _Returns:_ *string* _categoryName_, *luaindex* _categoryIndex_

* GetMapNumTiles()
** _Returns:_ *integer* _numHorizontalTiles_, *integer* _numVerticalTiles_

* GetMapTileTexture(*luaindex* _tileIndex_)
** _Returns:_ *string* _tileFilename_

* GetMapName()
** _Returns:_ *string* _mapName_

* GetMapType()
** _Returns:_ *[UIMapType|#UIMapType]* _mapType_

* GetMapContentType()
** _Returns:_ *[MapContentType|#MapContentType]* _mapContentType_
Maybe the map texture names somehow use a pattern that say "We are in a house now". And you can read it from there in event_player_activated,
  Reply With Quote
01/19/18, 05:39 PM   #5
Ayantir
 
Ayantir's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 1,019
When you're in a house GetCurrentZoneHouseId() returns something ~= 0

so check with EVENT_PLAYER_ACTIVATED per example.

ID is http://wiki.esoui.com/Houses
  Reply With Quote
01/19/18, 07:36 PM   #6
Rhyono
AddOn Author - Click to view addons
Join Date: Sep 2016
Posts: 659
I don't know what I'm doing wrong: check for addon load, register player activated, when player activates, it should call the house test, which grabs the zone ID and if the ID is greater than 0, it knows it is a house. So then it checks if I own the house. There are chat messages for all of them and I included a variable just to see. It isn't triggering. So now I feel that I've likely made some dumb, obvious mistake that is breaking it:

lua Code:
  1. local Test = {
  2. name = "Test",
  3. author = "Rhyono",
  4. version = 1}
  5.  
  6. local function OnAddOnLoaded(event, addonName)
  7.     if addonName == Test.name then
  8.         d("Loaded.")
  9.         EVENT_MANAGER:RegisterForEvent(Test.name,EVENT_PLAYER_ACTIVATED,Test.HouseTest)
  10.         EVENT_MANAGER:UnregisterForEvent(Test.name, EVENT_ADD_ON_LOADED)
  11.     end
  12. end
  13.  
  14. function Test.HouseTest()
  15.     d("Function called.")
  16.     if GetCurrentZoneHouseId() > 0 then
  17.         if IsOwnerOfCurrentHouse() then
  18.             d("My house.")
  19.             myHouse = true
  20.         else
  21.             d("Not my house.")
  22.             myHouse = false
  23.     else
  24.         d("Not a house.")
  25.         myHouse = false
  26.     end
  27. end
  28.  
  29. EVENT_MANAGER:RegisterForEvent(Test.name, EVENT_ADD_ON_LOADED, OnAddOnLoaded)
  Reply With Quote
01/20/18, 03:25 AM   #7
votan
 
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 577
Originally Posted by Rhyono View Post
I don't know what I'm doing wrong: check for addon load, register player activated, when player activates, it should call the house test, which grabs the zone ID and if the ID is greater than 0, it knows it is a house. So then it checks if I own the house. There are chat messages for all of them and I included a variable just to see. It isn't triggering. So now I feel that I've likely made some dumb, obvious mistake that is breaking it:
Short: siri.exe
Long: Is this really a copy of your source?
I corrected the missing "end" and it works with my house.
  Reply With Quote
01/20/18, 06:09 AM   #8
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,912
Code:
if IsOwnerOfCurrentHouse() then
            d("My house.")
            myHouse = true
        else
            d("Not my house.")
            myHouse = false

--> END missing here
  Reply With Quote
01/20/18, 11:58 AM   #9
Rhyono
AddOn Author - Click to view addons
Join Date: Sep 2016
Posts: 659
That wasn't an exact copy, so that wasn't the issue. But once you guys pointed that out and I went and checked, I realized the character I'm logging into (because I had to use my main elsewhere and didn't feel like hopping back and forth) does not have the test addon activated.

  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Housing Zone Event

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