Thread Tools Display Modes
07/15/22, 06:44 PM   #1
hilarityensues
AddOn Author - Click to view addons
Join Date: Jul 2022
Posts: 7
Question Help needed using LibHistoire

I'm working on pulling in bank history using LibHistoire. The initial pull should bring in the full history and store in savedvariables. But, when I'm executing I'm only getting the first 6 records of the 20k+ I should be getting from my guilds. Could anybody help out on what I'm missing here?
Attached Files
File Type: lua GuildBancair.lua (4.7 KB, 123 views)
  Reply With Quote
07/15/22, 07:39 PM   #2
DakJaniels
AddOn Author - Click to view addons
Join Date: Mar 2021
Posts: 27
I've been using this tool.

https://www.esoui.com/downloads/info...x-Updated.html

need a lua program to work it though,

https://sourceforge.net/projects/lua...20Executables/
  Reply With Quote
07/15/22, 08:04 PM   #3
hilarityensues
AddOn Author - Click to view addons
Join Date: Jul 2022
Posts: 7
Yeah that was the tool I had that actually inspired me to make this. I wanted to clean up a lot of the functions that aren't used in the code and enable a price lookup with TTC & MM to help with guild donation tracking. So I decided to build what I'm working on. I'm just stuck on getting the full history.
  Reply With Quote
07/15/22, 08:05 PM   #4
Sharlikran
 
Sharlikran's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 626
First use SetEventCallback not SetNextEventCallback. Second, your comment for GetMmPrice is wrong. MM does not take from a specific focus unless you press the corresponding modifier such as Shift or Ctrl. However, those modifiers are useless when using the function to get the price. You can not get any of the focuses through the function when requesting the pricing information from MM.

Also keep this the way I put it or there is a very big chance your mod could just break if I make changes.

function GuildBancair:GetMmPrice(itemLink)
local mmStats = MasterMerchant:itemStats(itemLink, false)
return mmStats
end

Then read the link mentioned on the LibHisatorie site.

https://github.com/esoui/esoui/blob/...hared.lua#L268

You are passing param3, which is the quantity to everything. So eventType is the first, but that is the Bank, or sales, or alliance war. The param1 is seller, and the itemLink is param4.

Then lastly you have to set your saved variables file as a default not each and every time.

GuildBancair.savedVariables['guilds'][guildId]['lastEvent'] = "0" has to be the default and set only once. The reason is that you will set it to be 0 and then LibHistoire will import every single bank event you have since you started using LibHistoire. It will just keep going, and going, and going, and going, and going, and going, and going, for 5 minutes or ten minutes or however long it takes. Until the process completes. Then after that you have to make sure all your bank events are linked and click the Rescan button on the LibHistoire GUI.

You should probably rewrite GuildBancair.Initialize() and have it call the GuildBancair.SetupListener(guildId, guildName) last in a separate function. You don't really want it to start until you are done setting up everything else.

Then lastly don't convert the id64 eventID to a number. For NA it is approaching the limit for a 32 bit integer and it's already past what a 32 bit integer can use for EU. So just don't do that. Compare it as a string and save it in your saved variables as a string.

I don't know if I got everything but more like what I have in the attached file. It isn't perfect and isn't tested.

Most of the MM functions will become internal and unusable without breaking your mod. So what I provided you is what you should use. It returns a table. If you need it to be in text format then create your own function and use string.format().

Last edited by Sharlikran : 07/15/22 at 08:21 PM.
  Reply With Quote
07/15/22, 08:21 PM   #5
Sharlikran
 
Sharlikran's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 626
Wrote that in a hurry. I don't recomend setting the bank events to 0 when you start because it will be endless for someone like me with almost 2 years of events.

You need to save the last event time though at some point and reset it after the next Kiosk flip. Then when someone loggs in get the last event time received but subtract 6 hours or something and check for duplicates.

Last edited by Sharlikran : 07/15/22 at 08:23 PM.
  Reply With Quote
07/15/22, 08:33 PM   #6
Sharlikran
 
Sharlikran's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 626
Okay the code is all over the place for what I suggested because I really don't do it this way. The thing is you want to do the following.

- Check If a Kiosk flip occurred, if so change the saved variables entry to indicate the beginning of the week.
- If Kiosk flip did not occur, then use the last saved variables timestamp minus 6 hours or so.
Attached Files
File Type: lua GuildBancair.lua (5.7 KB, 111 views)

Last edited by Sharlikran : 07/15/22 at 08:38 PM.
  Reply With Quote
07/15/22, 08:38 PM   #7
hilarityensues
AddOn Author - Click to view addons
Join Date: Jul 2022
Posts: 7
Awesome feedback, really appreciate it Sharlikran. I already had a few of those items on my to do list, I knew the mm portion wasn't right and you just saved me a ton of time.

Question on your timestamp comment. The LibHistoire says addon page says to use the `GetKey()` response to log the last event. Should I disregard that, or use it in some combination with the timestamp?

Thanks again.
  Reply With Quote
07/15/22, 08:51 PM   #8
Sharlikran
 
Sharlikran's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 626
Oh last thing I forgot to mention. You can not make a mod to track player donations, for the player using LibHistoire because a GM will usually restrict that. This would become, once completed, a GM only tool.

Last edited by Sharlikran : 07/15/22 at 08:54 PM.
  Reply With Quote
07/15/22, 08:53 PM   #9
Sharlikran
 
Sharlikran's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 626
GetKey(), I don't use it. I never tried it. That was probably added after I started using LibHistoire or I got MM working a different way and never saw it.

Last edited by Sharlikran : 07/15/22 at 09:03 PM.
  Reply With Quote
07/15/22, 09:12 PM   #10
hilarityensues
AddOn Author - Click to view addons
Join Date: Jul 2022
Posts: 7
Originally Posted by Sharlikran View Post
Oh last thing I forgot to mention. You can not make a mod to track player donations, for the player using LibHistoire because a GM will usually restrict that. This would become, once completed, a GM only tool.
Yes, that's the idea for this to help with donation tracking for the GM. Not sure how much demand is out there outside of our guild, but figured it was a good one for a learning experience .

Originally Posted by Sharlikran View Post
GetKey(), I don't use it. I never tried it. That was probably added after I started using LibHistoire.
Roger that! Hey thanks again really appreciate it!
  Reply With Quote
07/24/22, 11:51 AM   #11
hilarityensues
AddOn Author - Click to view addons
Join Date: Jul 2022
Posts: 7
Just following up on this thread in case anybody arrives here from a search.

1. The root issue I had where only a small amount of items were being returned from LibHistoire was actually a result of my TTC integration attempt. LibHistoire was delivering all the items but when I asked TTC what the values were it would return `nil` which I then passed along to the saved variables that make that row `nil` and not appear. So I introduced handling for `nil` values for both MasterMerchant and TTC and problem is solved.

2. For retrieving the data from LibHistoire, I ended up using `SetNextEventCallback`instead of `SetEventCallback`. This is because the `SetNextEventCallback` will keep the response from Libhistoire ordered and allows for retrieving from specific time ranges easier and duplicates to handle. There appears to be a risk in missing events however from the LibHistoire documentation so I may reverse this decision as I understand more how it works.

3. I also ended up using the LibHistoire GetKey() function to find the last saved event for update and to handle potential duplicates. This eliminates the need to write a function to assess guild trader flips to establish start times for data pulls.

To review the code (still a work in progress), it is here: Github: esoGuildBookkeeper

Thanks again @Sharlikran!
  Reply With Quote
07/24/22, 12:00 PM   #12
Sharlikran
 
Sharlikran's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 626
Just a quick note, checking for duplicates you use the id64 event I'd in the form of a string as mentioned and loop over the events. If looping over the events more then once takes time then organize your data differently. Such as using the id64, in the form of a string as the key.

Even if SetNextEventCallback() says it is in order Lua does not save anything in order. Meaning if I have an array starting with [1] and then I add [2] the next time the game loads it could read it as 2, 1.
  Reply With Quote
07/24/22, 10:27 PM   #13
hilarityensues
AddOn Author - Click to view addons
Join Date: Jul 2022
Posts: 7
Originally Posted by Sharlikran View Post
Just a quick note, checking for duplicates you use the id64 event I'd in the form of a string as mentioned and loop over the events. If looping over the events more then once takes time then organize your data differently. Such as using the id64, in the form of a string as the key.

Even if SetNextEventCallback() says it is in order Lua does not save anything in order. Meaning if I have an array starting with [1] and then I add [2] the next time the game loads it could read it as 2, 1.
Yes, two things I'm trying to avoid 1) O(n) when assessing duplicates and 2) having to store a variable for the last key (eventId, timestamp, key, whatever).

So the idea is, if we have the array store in the order in which the events are passed using `SetNextEventCallback()`, that means I can take care of both by identifying the last rec'd eventId:
Lua Code:
  1. dataTable[#dataTable][eventId]
At least that's the idea. The existence of SetMissedEventCallback() makes me nervous.
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Help needed using LibHistoire

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