ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Lua/XML Help (https://www.esoui.com/forums/forumdisplay.php?f=175)
-   -   easy port to your own primary house? (https://www.esoui.com/forums/showthread.php?t=10447)

sinnereso 02/08/23 02:39 PM

easy 1line port to your own primary house?
 
Hey im looking for a simple 1 liner if possible to port to my own primary house outside if possible..

something like:

local playerId = GetDisplayName()
JumpToHouse(playerId)

one that actually works... I cant for the life of me get any of these functions todo it.

everything i try reports back either "cannot port to yourself" or "character not found".

Baertram 02/08/23 02:59 PM

RequestJumpToHouse(GetHousingPrimaryHouse(), false)

true if jump inside

Can be found by inspecting the button at your collections where you can show the menu to jump in/outisde your house e.g. move the mouse above and use /zgoo mouse or merTorchbug /tbm to show the name of the control.
ZO_HousingBook_KeyboardContentsHousingInteractButtonsTravelToHouse
Then search the end of the name "TravelToHouse" in the ESOUI sources and you'll find the ShowMenu (shows the context menu) call in function HousingBook_Keyboard:RequestJumpToCurrentHouse():


Lua Code:
  1. function HousingBook_Keyboard:RequestJumpToCurrentHouse()
  2.     local collectibleData = self.navigationTree:GetSelectedData()
  3.     if collectibleData then
  4.         local houseId = collectibleData:GetReferenceId()
  5.         if collectibleData:IsLocked() then
  6.             -- Preview, behavior will always be inside
  7.             RequestJumpToHouse(houseId)
  8.             SCENE_MANAGER:ShowBaseScene()
  9.         else
  10.             ClearMenu()
  11.  
  12.             AddMenuItem(GetString(SI_HOUSING_BOOK_ACTION_TRAVEL_TO_HOUSE_INSIDE), function()
  13.                 local TRAVEL_INSIDE = false
  14.                 RequestJumpToHouse(houseId, TRAVEL_INSIDE)
  15.                 SCENE_MANAGER:ShowBaseScene()
  16.             end)
  17.             AddMenuItem(GetString(SI_HOUSING_BOOK_ACTION_TRAVEL_TO_HOUSE_OUTSIDE), function()
  18.                 local TRAVEL_OUTSIDE = true
  19.                 RequestJumpToHouse(houseId, TRAVEL_OUTSIDE)
  20.                 SCENE_MANAGER:ShowBaseScene()
  21.             end)
  22.  
  23.             ShowMenu(self.travelToHouseButton)
  24.         end
  25.     end
  26. end

sinnereso 02/08/23 03:01 PM

omg thank you soo much!

sinnereso 02/09/23 07:34 AM

Quote:

Originally Posted by Baertram (Post 47160)
RequestJumpToHouse(GetHousingPrimaryHouse(), false)

true if jump inside

Can be found by inspecting the button at your collections where you can show the menu to jump in/outisde your house e.g. move the mouse above and use /zgoo mouse or merTorchbug /tbm to show the name of the control.
ZO_HousingBook_KeyboardContentsHousingInteractButtonsTravelToHouse
Then search the end of the name "TravelToHouse" in the ESOUI sources and you'll find the ShowMenu (shows the context menu) call in function HousingBook_Keyboard:RequestJumpToCurrentHouse():


Lua Code:
  1. function HousingBook_Keyboard:RequestJumpToCurrentHouse()
  2.     local collectibleData = self.navigationTree:GetSelectedData()
  3.     if collectibleData then
  4.         local houseId = collectibleData:GetReferenceId()
  5.         if collectibleData:IsLocked() then
  6.             -- Preview, behavior will always be inside
  7.             RequestJumpToHouse(houseId)
  8.             SCENE_MANAGER:ShowBaseScene()
  9.         else
  10.             ClearMenu()
  11.  
  12.             AddMenuItem(GetString(SI_HOUSING_BOOK_ACTION_TRAVEL_TO_HOUSE_INSIDE), function()
  13.                 local TRAVEL_INSIDE = false
  14.                 RequestJumpToHouse(houseId, TRAVEL_INSIDE)
  15.                 SCENE_MANAGER:ShowBaseScene()
  16.             end)
  17.             AddMenuItem(GetString(SI_HOUSING_BOOK_ACTION_TRAVEL_TO_HOUSE_OUTSIDE), function()
  18.                 local TRAVEL_OUTSIDE = true
  19.                 RequestJumpToHouse(houseId, TRAVEL_OUTSIDE)
  20.                 SCENE_MANAGER:ShowBaseScene()
  21.             end)
  22.  
  23.             ShowMenu(self.travelToHouseButton)
  24.         end
  25.     end
  26. end

I didnt even realize it untill late last night about 2hrs before servers went down for maint but "false" is putting me inside instead of outside. but at the same time if IsUnitOnline(savedPlayer) == "isOnline" suddenly started passing the check even when player was offline. seemed like game running backwards last night or is the "false" for RequestJumpToHouse(GetHousingPrimaryHouse(), false) incorrect for outside?

Baertram 02/09/23 10:53 AM

I've copied you the code of the base game above showing you the function call, and even named you the function:
HousingBook_Keyboard:RequestJumpToCurrentHouse(

In the example code you can see:

local TRAVEL_INSIDE = false
RequestJumpToHouse(houseId, TRAVEL_INSIDE)

local TRAVEL_OUTSIDE = true
RequestJumpToHouse(houseId, TRAVEL_OUTSIDE)


This should be very obvious wha the API function RequestJumpToHouse uses for inside and outside then :-)

What was wrong was my text "true if jump inside", but I always assume you guys tests stuff before actually releasing it.

sinnereso 02/09/23 02:54 PM

haha ya i did test it but was testing other things at the same time and didnt. "clue in" that it was going inside till later.

I am however still having issues with some of the isunitonline and ingroup etc... its messy cuz ive been trying everything to get them passing and not passing when they should but heres a sample of what im trying todo. it shold not continue if im incombat or the target player isnt online or isnt in group and should execute the basic jumpto only giving the error in the top right corner which im happy with.

Code:

-- Travel to player
function RidinDirty.TravelToPlayer()
        local savedPlayer = RidinDirty.savedVariables.savedPlayer
        local effectId = RidinDirty.savedVariables.effectId
        local effectDelay = RidinDirty.savedVariables.effectDelay
        if savedPlayer  == nil or savedPlayer  == "" then return end
        if not IsUnitInCombat(player) then
                if IsUnitOnline(savedPlayer) then
                        if IsPlayerInGroup(savedPlayer) then
                                if IsCollectibleUnlocked(effectId) and IsCollectibleUsable(effectId) and GetCollectibleCooldownAndDuration(effectId) == 0 then
                                        UseCollectible(effectId)
                                        zo_callLater(function() JumpToGroupMember(savedPlayer) end, effectDelay)
                                        if effectId == 347 then
                                                df("|c9900FF[RidinDirty]|r There's a blood mist forming near %s", savedPlayer)
                                        end
                                else
                                        JumpToGroupMember(savedPlayer)
                                end
                        else
                                JumpToGroupMember(savedPlayer)
                        end
                else
                        JumpToGroupMember(savedPlayer)
                end
        else
                JumpToGroupMember(savedPlayer)
        end
end


Baertram 02/09/23 03:05 PM

You always should read the API documentation txt file for the parameters and parameter TYPES used! unitTags are not the same as character names or displaynames!

Afaik IsUnitInCombat(unitTag) only accepts unittags like "player" (yourself), "group1" to "groupN", "boss1" to "bossN" or "reticleover" and not any charactername or displayname!
So you cannot test IsUnitInCombat for any name on the server, only for yourself or grouped players.
There exist API group functions to check what name the group1, group2 etc. tags have but I'm not sure anymore, you need to search the API documentation txt file for them

I think it was a loop over group members by
Code:

for i=1, GetGroupSize() do
  local unitTag = GetGroupUnitTag(i)
end

or something similar.

sinnereso 02/09/23 03:20 PM

sweet ty... i was missing the quotes in the unitag ones.. theyre working now but your correct the isunitonline wont work for other players :( ill have to find a workaround cuz its semi important as well.. dont want the code firing off effects if they player isnt even online to port to.

sinnereso 02/09/23 03:26 PM

and i have been reading all the documentation and wiki and api function pages but am very new at this and imo my logic is ok but im having the most difficulties with strings boolean etc like how and when to use them or say it is one or the other etc.. i cant find that info yet online so had to resort to creeping other addons to give insight on theyre usage.

Baertram 02/10/23 05:37 AM

Yeah I get that. The WIKI is outdated at many api pages so you better check the API version list ->
https://wiki.esoui.com/APIVersion
there you'll find the txt documentation attached at each version (e.g. current live server or PTS).
API TXT Documentation: https://www.esoui.com/forums/attachm...6&d=1663783675

In the txt files you'll find the API functions which are valid, there parameters and there types. Search within these files then, not at the Wiki!
e.g. for GetGroup or GetUnit or IsPlayer or IsDisplayName or IsCharacter etc. to find API functions for that purpose.

If you search the Wiki you might get extr info (about events etc.) but it ight be outdated, so always take the txt API files as the "what is currently the state of the art".

sinnereso 02/10/23 09:39 AM

Quote:

Originally Posted by Baertram (Post 47165)
I think it was a loop over group members by
Code:

for i=1, GetGroupSize() do
  local unitTag = GetGroupUnitTag(i)
end

or something similar.


its all working flawlessly now except i had to remove the isunitonline(savedPlayer). this player would have to be in group and me not to be incombat for it to fire off. I was hoping to cover them not being online as well but havent been able to test if the isplayeringroup(savedPlayer) might kick back an error if theyre offline and work just as well. I just dont want the effects firing off for porting and then getting an error theyre offline is all. rest is flawless now.

sinnereso 02/11/23 02:35 PM

Quote:

Originally Posted by Baertram (Post 47165)
You always should read the API documentation txt file for the parameters and parameter TYPES used! unitTags are not the same as character names or displaynames!

Afaik IsUnitInCombat(unitTag) only accepts unittags like "player" (yourself), "group1" to "groupN", "boss1" to "bossN" or "reticleover" and not any charactername or displayname!
So you cannot test IsUnitInCombat for any name on the server, only for yourself or grouped players.
There exist API group functions to check what name the group1, group2 etc. tags have but I'm not sure anymore, you need to search the API documentation txt file for them

I think it was a loop over group members by
Code:

for i=1, GetGroupSize() do
  local unitTag = GetGroupUnitTag(i)
end

or something similar.

Ive been working with this gem but cant get it working.. i know im close but cant seem to put my finger on why. any suggestions?

Code:

function RidinDirty.TravelToPlayer()
        local savedPlayer = RidinDirty.savedVariables.savedPlayer -- target saved player
        local effectId = RidinDirty.savedVariables.effectId
        local effectDelay = RidinDirty.savedVariables.effectDelay
        local savedPlayerId = nil -- savedID reset
        for i = 1, GetGroupSize() do
                local savedPlayerId = GetGroupUnitTagByIndex(i)
                if not GetUnitDisplayName("savedPlayerId") == savedPlayer then
                        df("|c9900FF[RidinDirty]|r unit online is %s", savedPlayer) -- trying to execute this ONLY if previous line matches original savedPlayer
                end
        end


ExoY 02/11/23 02:57 PM

Quote:

Originally Posted by sinnereso (Post 47186)
Ive been working with this gem but cant get it working.. i know im close but cant seem to put my finger on why. any suggestions?

Code:

function RidinDirty.TravelToPlayer()
        local savedPlayer = RidinDirty.savedVariables.savedPlayer -- target saved player
        local effectId = RidinDirty.savedVariables.effectId
        local effectDelay = RidinDirty.savedVariables.effectDelay
        local savedPlayerId = nil -- savedID reset
        for i = 1, GetGroupSize() do
                local savedPlayerId = GetGroupUnitTagByIndex(i)
                if not GetUnitDisplayName("savedPlayerId") == savedPlayer then
                        df("|c9900FF[RidinDirty]|r unit online is %s", savedPlayer) -- trying to execute this ONLY if previous line matches original savedPlayer
                end
        end



The quotation marks in GetUnitDisplayName shouldnt be there. It should be:
Code:

GetUnitDisplayName(savedPlayerId)
also i had a look at your addon.
Instead of creating and overwriting your save variables 6 times during initialization, i recommend doing it once and provide your default values within one table.

sinnereso 02/11/23 04:58 PM

Quote:

Originally Posted by ExoY (Post 47187)
The quotation marks in GetUnitDisplayName shouldnt be there. It should be:
Code:

GetUnitDisplayName(savedPlayerId)
also i had a look at your addon.
Instead of creating and overwriting your save variables 6 times during initialization, i recommend doing it once and provide your default values within one table.

Thank you that fixed it up :) Ill look at the saved variables thing next.


All times are GMT -6. The time now is 05:16 PM.

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