Allow Shortcuts to take an Item to create the Shortcut
Right now the only way to create a shortcut is to know the ShortcutType and the string data for the object you want to put into the shortcut. This is fine when you know what item is already in a shortcut and you are saving that shortcut information for reloading later, but doesn't work too well when you need or want to dynamically build shortcuts based on what might be in the players inventory.
As an example, you want to build a quickslot which will have as many quickslots in it as the player has morale potions in his/her bag, regardless of how many they actually have and which ones they actually have. You can't know how many they have or which ones they have without scanning the inventory. Currently, you can only do this is if you scan the bags for all known morale potions, and then have a table setup in your code files that lists all known morale potions and their data strings (which you have to manually get from the Lorebook), and then create the quickslots for those potions. However, you can't know what the stack data string is for each potion, so you can only create a generic quickslot for it, which causes a few problems when clicking on the shortcuts. Also when a stack of potions runs out and another stack needs to take its place in the quickslot, things can be messed up which requires the user to click twice to actually use the item, which could be a problem if the user is in the middle of a fight.
My suggestion would be to allow a Shortcut to be initialized by passing an Item object into the constructor. For example, if you wanted to make a quickslot for whatever item was in the players first slot in the backpack:
Code:
...get localplayer backpack instance...
itemInSlotOne = backpack:GetItem(1);
if itemInSlotOne ~= nil then
shortcut = Turbine.UI.Lotro.Shortcut(itemInSlotOne);
end
Quickslot:SetShortcut(shortcut);
or something to that effect.
This would make solving some of the problems that have arisen with the Update 6 changes to quickslots/LUA.
Re: Allow Shortcuts to take an Item to create the Shortcut
I just releasEd a plugin called ItemManager on LotroInterface. It can manage morale pots for you if you want. It does this by synchronising a view of your backpack based on string matches rather than Item IDs.
It's always up to date and items can be used directly out of the windows. You simply drag items in in order to tell the window to show items of that type. As you use and add or remove items the view stays in synch
Re: Allow Shortcuts to take an Item to create the Shortcut
I saw your plugin the other day and it's definitely interesting and I may use it in a similar way that you use if, for alts and stuff. Unfortunately it doesn't really solve the problem I have in the way that I would like it to, since it doesn't use the Quickslots/Shortcuts to create the icons in the window, it uses the ItemControl to display the items, which is more akin to the way the backpack works (you can't left click to use items in an ItemControl, whereas you can left click if it's in a Quickslot/Shortcut).
I've dabbed with using ItemControls to solve the problem in the past because you can take items from the backpack and insert them into an item control (as the backpack offers a GetItem(index) function and the ItemControl allows you to SetItem() to display a given item), but I just don't like the look and feel of ItemControls compared to Shortcuts.
Thank you for the recommendation though and very nice plugin for us altoholics
Re: Allow Shortcuts to take an Item to create the Shortcut
Hmmmm - I see what you mean. I must confess that I haven't used Quickslots yet.
The documentation says that one can set the shortcut for a quickslot. Can you make a shortcut if you have the item reference? Maybe something like:
local myShortcut = Shortcut(Turbine.UI.Lotro.Shor tcutType["Item"], theItem);
Where theItem is an item you've identified in the backpack. This way you could iterate through items in the backpack and see if their name matches. If it does, then you could make a shortcut to the item.
I must confess that I haven't played with shortcuts yet. I've only used them in conjunction with drag-and-drop scenarios. It would be nice if the documentation contained more information on the intended use and function of objects...
Re: Allow Shortcuts to take an Item to create the Shortcut
In order to set a quickslot's shortcut, you have to know the item's type and the item's data. The type is a ShortcutType and the data is a string associated with the item/skill/etc. The data string is composed of two parts: a part that points to a stack in the backpack, and the actual item. An example of a data string: 0x030A0002C46A5372,0x7002830F with the first part before the ',' being the stack pointer, and everything after being the item pointer. Any one item (for example, in this case, the lvl 75 morale potions I think) will have the same second half string (all lvl 75 morale potions will have 0x7002830F as the second half of their data string). The first half is unique to a single stack in the players inventory - if you have two stacks of the same type of morale potions in your backpack, the first half of the string will be different, while the second half will be the same.
You cannot know what the stack reference will be until you actually move an item onto a quickslot and get that information from it. This means you can't build a quickslot with items from the backpack in it because you can't know what the stack data string will be. You can know the item data string part, as that information actually comes from the lorebook, and since it never changes you can build a catalog of sorts of item references. You used to be able to replace the first half with all zeros to point to "non-specific" stacks but with the changes made in Update 6 that doesn't work so well anymore.
An alternative would be to add methods to the Item class that allows us to pull the data string and ShortcutType information we need off of the item itself. For example:
Re: Allow Shortcuts to take an Item to create the Shortcut
Originally Posted by Stever1388
An alternative would be to add methods to the Item class that allows us to pull the data string and ShortcutType information we need off of the item itself.
You wouldn't even need to get the type since all backpack items are of type 'Item'. I made a post back in February of last year (amazing how time flies) requesting an Item:GetData() method http://forums.lotro.com/showthread.p...Item-GetData()
Gnashtooth - Rank 10 Warg - My breath's worse than my bite - but what d'ya want? I eat Hobbitsess fer cryin' out loud
Garan - Captain of little note - got parked at a Fell Scrying Pool so long it dried up and blew away
and many, many others...
"No, no, the hamsters are for the forums. The servers run on chinchillas!"-Patience 7/20/2007