Thread: wallet
View Single Post
  #5  
Unread 04-20-2012, 09:43 AM
Garan's Avatar
Garan Garan is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Oct 2010
Posts: 341
Quote:
Originally Posted by Niwashi
Is there any point at which I can safely do initializations?
The barter wallet object has an ItemAdded event which you are supposed to be able to use to detect when an item is added to the wallet. Unfortunately, there is an initialization bug which was already reported to Turbine. What is happening is that the barter wallet is getting initialized over time after the plugin is loaded but the events are not firing for currencies that already exist in the wallet but are just being initialized. So what happens is your plugin will not see any of the existing currencies until an undefined amount of time has passed after which the currencies will magically start to appear but no event was fired. To work around this, I added a simple Update event handler on my wallet window that just checks the size of the wallet, localPlayer:GetWallet():GetSize(),- if it has changed, then I know I need to poll the currencies and find what has changed. This has minimal impact on the user's frame rate since it only performs a single comparison unless something has actually changed.

What should happen when Turbine fixes their bug is that either all of the currencies that are already in the wallet should be available when the plugin loads or the ItemAdded event will fire as each existing currency gets initialized. Either mechanism will be sufficient to get away from the Update handler.

As to knowing what has changed when a QuantityChanged event fires, you have to track the old value yourself and perform the comparison to see what change occured.

Character contribution to shared currencies is something I was already considering for Wallet, but it seems to have limited usefulness so it got a pretty low priority on the ToDo list.

Last edited by Garan : 04-20-2012 at 09:52 AM.
Reply With Quote