lotrointerface.com
Search Downloads


Go Back   LoTROInterface > LotRO > Developer Discussions > Lua Programming Help (L)

Reply
Thread Tools Display Modes
  #1  
Unread 04-19-2012, 05:21 PM
Niwashi's Avatar
Niwashi Niwashi is offline
The Undefeated
Interface Author - Click to view interfaces
 
Join Date: Feb 2011
Posts: 7
wallet

I'm working on a plugin to keep track of the items in our barter wallet that are now pooled across our account, tracking which of them should belong to which character. (And in the process, I'm working on learning LUA, which I've never worked with before.)

Looking through other people's code (Garan's Wallet and AltInventory plugins, and RandomAugury's WalletTracker) I've come across the GetWallet() function and the GetName(), GetQuantity(), and IsAccountItem() functions on individual currencies listed within that wallet. None of this, however, seems to be included in the LUA documentation I downloaded from this site. Is there a more up-to-date version of the documentation that includes these and (more importantly) would tell me what other methods and events are available to work with? Specifically, I'm looking for an event (and I'm hoping there is one) when a character either earns or spends Marks, Medallions, Commendations, etc.

So far, I've taken care of setting up a table of currencies and characters, identifying who owns how many of which, and I've set up a UI window in which the player can assign their available currencies between their characters. That sort of manual assignment will be necessary during initial setup, and useful later on if a player wants to transfer some skirmish marks (or whatever) from one of their characters to another. But for the most part, I envision this plugin keeping track of them more automatically, so when a character earns skirmish marks, they're automatically assigned to that character, and when they're spent, they automatically come from the pool assigned to the character who's spending them. That part's going to require some event handling (which I still need to learn how to do in LUA).
Reply With Quote
  #2  
Unread 04-19-2012, 06:31 PM
Brygard2007's Avatar
Brygard2007 Brygard2007 is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Sep 2007
Location: http://www.youtube.com/user/Brygard2009
Posts: 183
http://www.lotrointerface.com/downlo...-TitanBar.html

Titan bars is already doing some of the stuff your doing but you take a peek and see what else or more you can do.
Reply With Quote
  #3  
Unread 04-19-2012, 11:07 PM
Niwashi's Avatar
Niwashi Niwashi is offline
The Undefeated
Interface Author - Click to view interfaces
 
Join Date: Feb 2011
Posts: 7
Ok, that's not much like what I'm doing, but going through the code I found where it adds the callback for "QuantityChanged" on each of the wallet items, and that piece looks straightforward enough. That at least should give me a trigger for knowing that something has happened.

Now the tricky part. I need to figure out what has happened. I can look up how many of the given item are in the wallet when the QuantityChanged event occurs, but in order to turn that into knowing how many were just added/removed, I would also need to know how many there had been just prior to the change.

In my initial draft of this Per Character Wallet plugin (which, as I mentioned before, just has the manual assignments so far) I first tried initializing what currencies are in the wallet when the plugin was loaded, but found there's nothing there then. I switched it to initializing the first time the user invokes the plugin, which works well enough for something that only has display and manual input. Of course, it won't work so well once event triggers are added into the mix. I have no way of knowing whether the player will look at the plugin before earning any barter currencies. Is there any point at which I can safely do initializations? Sometime after the game loads the wallet information (which apparently occurs after plugins are loaded), but before any point when the player might earn or spend wallet currency?
Reply With Quote
  #4  
Unread 04-19-2012, 11:11 PM
Adra's Avatar
Adra Adra is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Jun 2011
Location: France
Posts: 171
Sir Garan has also released an very good Wallet plugin :

http://www.lotrointerface.com/downlo...12-Wallet.html
__________________
JRR skins collection download page
JRR Azure Glass download page
Extended and enhanced panels
Adra/Adragor/Osred from Sirannon.
Derelos/Prurit/Karnaj from Evernight.
Reply With Quote
  #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: 340
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
  #6  
Unread 04-20-2012, 06:37 PM
Niwashi's Avatar
Niwashi Niwashi is offline
The Undefeated
Interface Author - Click to view interfaces
 
Join Date: Feb 2011
Posts: 7
Thanks. I'll try that workaround with Update to get the initializations done. Then I can work with the QuantityChanged and ItemAdded events to deal with assigning earned/spent currency. I think that gives me enough to work with for now, though I might have other questions come up as I get further into the project.
Reply With Quote
  #7  
Unread 04-23-2012, 03:34 PM
Niwashi's Avatar
Niwashi Niwashi is offline
The Undefeated
Interface Author - Click to view interfaces
 
Join Date: Feb 2011
Posts: 7
Quote:
Originally Posted by Garan
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.
Can I count on the events not firing? I.e. are new currencies discovered during the Update work-around simply being loaded from previous game sessions whereas new currencies found after an ItemAdded event are newly earned currencies that should be assigned to my current character? And if a new currency is earned in-game, would the ItemAdded event occur before the next Update?

And I'm still not quite sure when to decide the initialization is over and any currencies still not in the wallet are not available and should be deleted from my assignments. Maybe I'll just leave that part at when the player first opens my Per Character Wallet window like I had before. Hopefully, by the time the player is in game and opening windows, the game has finished loading.


Quote:
Originally Posted by Garan
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.
Either may be sufficient for your application, but if they end up firing the same ItemAdded event on loading pre-existing currencies that they fire to indicate the character actually earning a new currency in-game which he/she simply hadn't had before, then I'm not going to know which events mean I should assign the currency to my character and which don't.


Quote:
Originally Posted by Garan
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.
Well, your Wallet plugin is a lot prettier than my Per-Character Wallet plugin is likely to end up being. So if you ever get around to adding it, it'll probably be an improvement over what I'll have available.


EDIT:
Oh, and another question: Besides the ItemAdded event, is there a corresponding ItemDeleted event or something of the sort? Or does "ItemAdded" really mean any change in which items are included in the wallet? The wallet contains only currencies that the character has, so a currency would disappear from the wallet when a character spends their last of it.

Last edited by Niwashi : 04-23-2012 at 03:38 PM.
Reply With Quote
Reply


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
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Minimalistic Wallet JonatanRaven Interface Requests (L) 3 04-21-2011 02:55 PM


All times are GMT -5. The time now is 01:52 PM.


Our Network
EQInterface | EQ2Interface | Minion | WoWInterface | ESOUI | LoTROInterface | MMOUI | Swtorui