View Single Post
  #4  
Unread 12-20-2011, 08:40 PM
Stever1388 Stever1388 is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Nov 2010
Posts: 33
Quote:
Originally Posted by lunarwtr
You can capture the item ids from lorebook mediawiki articles, or from the item event when u drag inventory item to a quickslot (forget event name offhand). You can call GetData on the quickslot shortcut (or maybe its the getitem method of quickslot.. I forget off top of my head) and keep track of those. Either way, you can create yourself a little database of the items you want prefab quickslots to. You can create the quickslot regardless of whether the item is in inventory. I use this for id analysis tool I use for Compendium development. If the item isn't in inventory the quickslot will be grayed out and not do much when clicked.
The problem I'm having is this:

You have a stack of morale potions and you set those potions into a quickslot. You then completely run out of that stack of potions. You buy more of the same exact type of potions. When you unload the plugin and reload it, your quickslot will be empty, or the Quickslot:SetShortcut() method will throw an error. Basically, the Shortcut:GetDat() is returning an invalid string, even though they are the same item. From my testing, a stack in your inventory of an item always returns the same Shortcut:GetData() but a different stack of the same item will return a different Shortcut:GetData(). You can test this by having two separate stacks in your inventory of an item and placing them on a quickslot that has the ShortcutChanged event function handled and have it print out Turbine.Shell.WriteLine(Quickslot:GetShortcut():Ge tData()). When you place both stacks on the quickslot you'll get different values returned.

As a very simple example of what I could do with this, is create 75 quickslots, and place each item in your inventory into each of the slots. The code would look something like this:

Code:
backpack = Turbine.GamePlay.LocalPlayer:GetInstance():GetBackpack()
quickslots = {}

for i=1, backpack:GetSize() do
      item = backpack:GetItem(i)
      quickslots[i] = Turbine.UI.Lotro.Quickslot()
      quickslots[i]:SetShortcut(Turbine.UI.Lotro.Shortcut(Turbine.UI.Lotro.ShortcutType.Item, ITEMDATA)
end
However, I have no idea how to get the ITEMDATA needed to create the shortcut. Normally you can use the Shortcut:GetData() method to get that, but in this case I don't have the quickslot/shortcut set up yet and I'm trying to build it dynamically regardless of what is actually in the users inventory.

I'd also like to know how you get the grayed out icons. If I run out of an item it goes gray but if I unload the plugin and then load it back in the plugin will either throw an error or it will be blank.
Reply With Quote