ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Lua/XML Help (https://www.esoui.com/forums/forumdisplay.php?f=175)
-   -   Housing Zone Event (https://www.esoui.com/forums/showthread.php?t=7577)

Rhyono 01/19/18 04:10 PM

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?

Baertram 01/19/18 04:32 PM

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).

Rhyono 01/19/18 04:36 PM

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...

Baertram 01/19/18 04:43 PM

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,

Ayantir 01/19/18 05:39 PM

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

Rhyono 01/19/18 07:36 PM

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)

votan 01/20/18 03:25 AM

Quote:

Originally Posted by Rhyono (Post 33663)
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.

Baertram 01/20/18 06:09 AM

Code:

if IsOwnerOfCurrentHouse() then
            d("My house.")
            myHouse = true
        else
            d("Not my house.")
            myHouse = false

--> END missing here


Rhyono 01/20/18 11:58 AM

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.



All times are GMT -6. The time now is 03:08 AM.

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