+ Reply to Thread
Results 1 to 8 of 8
  1. #1
    Senior Member Online status: Stever1388 is online now Reputation: Stever1388 the Wary Stever1388 the Wary Stever1388 the Wary Stever1388 the Wary Stever1388 the Wary
    Join Date
    May 2008
    Posts
    166

    Post 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.

    You can read about some of the problems with stacks and quickslots in the LOTRO Alerts plugin page and the Bevy o' Bars plugin page.

  2. #2
    Member Online status: Kamindra is offline Reputation: Kamindra the Wary Kamindra the Wary
    Join Date
    Jun 2007
    Posts
    61

    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

    Try it out

  3. #3
    Senior Member Online status: Stever1388 is online now Reputation: Stever1388 the Wary Stever1388 the Wary Stever1388 the Wary Stever1388 the Wary Stever1388 the Wary
    Join Date
    May 2008
    Posts
    166

    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

  4. #4
    Member Online status: Kamindra is offline Reputation: Kamindra the Wary Kamindra the Wary
    Join Date
    Jun 2007
    Posts
    61

    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...

  5. #5
    Senior Member Online status: Stever1388 is online now Reputation: Stever1388 the Wary Stever1388 the Wary Stever1388 the Wary Stever1388 the Wary Stever1388 the Wary
    Join Date
    May 2008
    Posts
    166

    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:

    Code:
    ... get localplayer backpack instance...
    itemInSlotOne = backpack:GetItem(1);
    shortcutTypeOfItem = itemInSlotOne:GetShortcutType();
    dataStringOfItem = itemInSlotOne:GetDataString();
    shortcut = Turbine.UI.Lotro.Shortcut(shortcutTypeOfItem, dataStringOfItem);
    This would also solve the problem a bit. Add in some event handlers to watch for changes in the backpack and update the shortcuts when needed.

  6. #6
    Poster of Note Online status: Garan is online now Reputation: Garan has disabled reputation
    Join Date
    Mar 2007
    Posts
    837

    Re: Allow Shortcuts to take an Item to create the Shortcut

    Quote Originally Posted by Stever1388 View Post
    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

  7. #7
    Member Online status: Kamindra is offline Reputation: Kamindra the Wary Kamindra the Wary
    Join Date
    Jun 2007
    Posts
    61

    Re: Allow Shortcuts to take an Item to create the Shortcut

    If you do something like this:
    Turbine.Shell.WriteLine(tostri ng(theItem)); -- where theItem is a reference to an item
    you get a result like this:
    table: 3F24B650
    That looks awefully like the value you want.... Is it?

    if not, it might be the implementation data for the item, which you can get to like this:
    Turbine.Shell.WriteLine(tostri ng(theItem.__implementation));

    userdata: 325AB3D8
    It doesn't make sense for it not to be one of those two!

    Kam

  8. #8
    Member Online status: Kamindra is offline Reputation: Kamindra the Wary Kamindra the Wary
    Join Date
    Jun 2007
    Posts
    61

    Re: Allow Shortcuts to take an Item to create the Shortcut

    After (finally) doing my homework, I realise I was wrong about the IDs above. There is a complete separation of userdata and internal Lua IDs.

    Please please please, can we have the mechanisms to create these shortcuts?

    Either that or add an Item:GetData() that allows us to create one?


    Kamindra

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts