Thread Tools Display Modes
03/13/23, 08:43 AM   #1
cabwav
Join Date: Aug 2020
Posts: 7
Question How to get Trading House Listing data

I am rather new to AddOn development. I would like to write Trading House listing data to SavedVariables so that I can process these listed items outside ESO in order to keep track of what I listed for sale.
I am a member of two Guilds: one is my 'regular' guild that has no trader, and the other one is the Trading guild that I use for selling things. I am using this code:

Lua Code:
  1. for j = 1, GetNumGuilds() do
  2.         local guildId = GetGuildId(j)
  3.         if (SelectTradingHouseGuildId(guildId)) then
  4.             local currentListingCount, maxListingCount = GetTradingHouseListingCounts()
  5.             if(currentListingCount > 0) then
  6.                 for i = 1, currentListingCount do
  7.                     local _,itemName,displayQuality,stackCount,_,timeRemaining,salePrice = GetTradingHouseListingItemInfo(i)
  8.                     local link = GetTradingHouseListingItemLink(i,j)
  9.                     local linkItemId = GetItemLinkItemId(link)
  10.                   table.insert(mytable,string.format("%s;%s;%s;%s;%s",guildId,linkItemId,itemName,salePrice,timeRemaining))
  11.                 end
  12.             end
  13.          end
  14.       end
This returns a table that contains twice the number of items, exactly the same for each guild although one of the guilds has no sellable items. What am I missing here?

The above code only works when I visit the bank, and open the listing from the guild trader.
Is there a way to access the listing data in the bank without actually visiting the bank?

Thank you in advance

Last edited by cabwav : 03/13/23 at 10:14 AM.
  Reply With Quote
03/13/23, 09:35 AM   #2
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,912
This returns a table that contains twice the number of items, exactly the same for each guild although one of the guilds has no sellable items.
Before "SelectTradingHouseGuildId" You need to check if the guild trader is active at the guildId to prevent building data for a guild where there is no way to list items.

Lua Code:
  1. local gotTrader = (IsPlayerInGuild(guildId) and DoesGuildHavePrivilege(guildId, GUILD_PRIVILEGE_TRADING_HOUSE)) or false
  2. local isPlayerAllowedToSell = DoesPlayerHaveGuildPermission(guildId, GUILD_PERMISSION_STORE_SELL)

The IsPlayerInGuild(guildId) part can be skipped in your code as you already loop over the guilds you are in via GetNumGuilds() before!


The above code only works when I visit the bank, and open the listing from the guild trader.
Afaik there is no way to do this without opening the guild trader as the data is not created/build properly before. But I might be wrong.


Edit:
Btw GetTradingHouseListingItemLink only needs 1 parameter, the index of the item. There is no second param
local link = GetTradingHouseListingItemLink(i)


And a hint: If you post code use the code or lua highlight tags around it please. It eases the reading!

Last edited by Baertram : 03/13/23 at 09:43 AM.
  Reply With Quote
03/13/23, 10:31 AM   #3
cabwav
Join Date: Aug 2020
Posts: 7
Thank you for your reply. I changed the code as follows:
Lua Code:
  1. for j = 1, GetNumGuilds() do
  2.         local guildId = GetGuildId(j)
  3.         local gotTrader = DoesGuildHavePrivilege(guildId, GUILD_PRIVILEGE_TRADING_HOUSE) or false
  4.         local isPlayerAllowedToSell = DoesPlayerHaveGuildPermission(guildId, GUILD_PERMISSION_STORE_SELL)
  5.  
  6.         if gotTrader and isPlayerAllowedToSell then
  7.             if (SelectTradingHouseGuildId(guildId)) then
  8.                 local currentListingCount, maxListingCount = GetTradingHouseListingCounts()
  9.                 if(currentListingCount > 0) then
  10.                     for i = 1, currentListingCount do
  11.                         local _,itemName,displayQuality,stackCount,_,timeRemaining,salePrice = GetTradingHouseListingItemInfo(i)
  12.                         local link = GetTradingHouseListingItemLink(i)
  13.                         local linkItemId = GetItemLinkItemId(link)
  14.                         table.insert(mytable,string.format("%s;%s;%s;%s;%s",guildId,linkItemId,itemName,salePrice,timeRemaining))
  15.                     end
  16.                 end
  17.             end
  18.         end
  19.     end

Unfortunately, I am still getting the double amount of items, i.e. the items that are actually sold in the Trading Guild, plus the same number of items for the 'regular' guild (that has no trader)

Did I understand your answer correctly?

thanks again,

cabwav
  Reply With Quote
03/13/23, 11:04 AM   #4
Sharlikran
 
Sharlikran's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 626
Something to keep in mind, if you have Awesome Guild Store installed then getting information from the trader will not work the same as when you don't have AGS installed. The vanilla routines won't work with AGS.

I am really not a fan of exporting to spreadsheets. It takes time to do it and the output will always be in Lua and not CSV or something more convenient.

For example:
Code:
["SALES"] = 
{
["version"] = 1,
["YourGuildName"] = 
{
[1] = "@Ashjunkie&@Lcs_Flores&|H0:item:46129:30:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h&200&1630085615&false&4000&Real Guild Best Guild&Quicksilver Ingot&rr01 white normal materials",
},
The developers do not allow us to export in specific file formats or to specific file names when we save to the saved variables file.

So the question is, do you absolutely "need" to export it? Would 180 days worth of information available in game with search capabilities be sufficient? For the items you have listed to sell on a trader for all the different guilds you are in.

Last edited by Sharlikran : 03/13/23 at 11:19 AM.
  Reply With Quote
03/13/23, 02:06 PM   #5
cabwav
Join Date: Aug 2020
Posts: 7
Thank you for your reply. I do have AGS installed as an addon, so that may well be the explanation for this problem. I am developing this specific addon because I am new to addon development and I just wanted to see how they work. I am fairly skilled in C# development but LUA is new to me so I thought I would give it a try.

The code that I described in my post above gives me lines like e.g.:
Code:
[1] = "400042;156825;Style Page: Opal Bloodspawn Mace;9200;951966",
[2] = "400042;190025;Style Page: Witchmother's Servant's Gloves;8600;951978",
[3] = "400042;147707;Crafting Motif 73: Anequina Legs;1300;2184002",
and I have written some C# code that retrieves the SavedVariables file for further processing.
The addon and its output is intended for my own personal use, and as a way to become more familiar with the inner workings of AddOns/LUA in general.
  Reply With Quote
03/13/23, 04:41 PM   #6
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,912
Yes, looks okay to me. Not sure why you get items of a guildId where no trader exists though. How should one list any item there?

Did you testreset the SV table before trying new so there is no old data in it?
Add d() debit messages to your code to see where it runs through, which items are added at what loop etc.



Originally Posted by cabwav View Post
Thank you for your reply. I changed the code as follows:
Lua Code:
  1. for j = 1, GetNumGuilds() do
  2.         local guildId = GetGuildId(j)
  3.         local gotTrader = DoesGuildHavePrivilege(guildId, GUILD_PRIVILEGE_TRADING_HOUSE) or false
  4.         local isPlayerAllowedToSell = DoesPlayerHaveGuildPermission(guildId, GUILD_PERMISSION_STORE_SELL)
  5.  
  6.         if gotTrader and isPlayerAllowedToSell then
  7.             if (SelectTradingHouseGuildId(guildId)) then
  8.                 local currentListingCount, maxListingCount = GetTradingHouseListingCounts()
  9.                 if(currentListingCount > 0) then
  10.                     for i = 1, currentListingCount do
  11.                         local _,itemName,displayQuality,stackCount,_,timeRemaining,salePrice = GetTradingHouseListingItemInfo(i)
  12.                         local link = GetTradingHouseListingItemLink(i)
  13.                         local linkItemId = GetItemLinkItemId(link)
  14.                         table.insert(mytable,string.format("%s;%s;%s;%s;%s",guildId,linkItemId,itemName,salePrice,timeRemaining))
  15.                     end
  16.                 end
  17.             end
  18.         end
  19.     end

Unfortunately, I am still getting the double amount of items, i.e. the items that are actually sold in the Trading Guild, plus the same number of items for the 'regular' guild (that has no trader)

Did I understand your answer correctly?

thanks again,

cabwav
  Reply With Quote
03/13/23, 07:25 PM   #7
cabwav
Join Date: Aug 2020
Posts: 7
I found the solution. It turns out that Sharlikran's remark about AGS is correct. I temporarly removed the AGS addon and now it works as expected. Which is a bit of a pity, because I really want to keep using AGS.
So I guess that means that this is the end of my endeavour to process listing data outside ESO
OTOH I learned that some AddOns apparently change the 'standard' ESO API calls in unexpected ways (I never would have figured this out myself )

thank you for your help

cabwav
  Reply With Quote
03/14/23, 05: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
OTOH I learned that some AddOns apparently change the 'standard' ESO API calls in unexpected ways
Yeah, that's normal. ESO addons can interfer with others a lot, as you change API functions (overweite them, PrehOok and prevent them, PreHook and do checks, PostHook and react on them, ...) or events or other code (ZO_* class functions e.g. ZO_Smithing, or objects created from those e.g. SMITHING).

You should always disable all other addons if you test yours! Only keep those helpers like merTorchbug updated, ZGOO, LibDebugLogger, DebugLogViewer enabled and the needed dependencies like LibAddonMenu etc.


Here are some best practices and helper tools for new addon devs, if you haven't seen that already:
https://www.esoui.com/forums/showthread.php?t=9867
  Reply With Quote
03/14/23, 06:38 AM   #9
cabwav
Join Date: Aug 2020
Posts: 7
Thank you Baertram, another lesson learnt . I admit that I didn't read the guidelines you linked above but I assure you that I did read everything this time!
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » How to get Trading House Listing data

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