lotrointerface.com
Search Downloads


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

Reply
Thread Tools Display Modes
  #1  
Unread 12-20-2011, 05:01 PM
Stever1388 Stever1388 is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Nov 2010
Posts: 33
Creating Shortcuts from Items in Inventory

Basically I want to take items that are in the inventory and create shortcuts out of them, so that I can then create quickslots. However, you need the string Data of the item to be able to create the quickslot, and as far as I can tell, the only way to get that string is to add the item to a quickslot and then output the result. Is there someway to gather the data string needed to create a shortcut from items in your inventory without knowing what is actually in your inventory?

I've tried using ItemControl, but it doesn't create the type of quickslot that you have on your mainbar, for instance you can't left click on a potion to use it, you either have to right click it or double left click it (as if it were in your inventory).

Any help would be appreciated. Thanks.
Reply With Quote
  #2  
Unread 12-20-2011, 07:46 PM
lunarwtr's Avatar
lunarwtr lunarwtr is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Feb 2011
Posts: 121
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.
__________________
Author of Lotro Compendium, Waypoint, and Lotro Plugin Compendium (LPC)
Reply With Quote
  #3  
Unread 12-20-2011, 07:55 PM
lunarwtr's Avatar
lunarwtr lunarwtr is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Feb 2011
Posts: 121
Convert the item ids from lorebook to hex value and u can then

Code:
...
local shortcut = Turbine.UI.Lotro.Shortcut(Turbine.UI.Lotro.ShortcutType.Item , string.format( '0x0000000000000000,0x%s', hex ))
quicks:SetShortcut( shortcut );
__________________
Author of Lotro Compendium, Waypoint, and Lotro Plugin Compendium (LPC)
Reply With Quote
  #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
  #5  
Unread 12-20-2011, 08:47 PM
lunarwtr's Avatar
lunarwtr lunarwtr is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Feb 2011
Posts: 121
There is no API way of getting the item id directly from an item unless it is dragged to a quickslot -or- linked to chat from a vendor.

However, on lorebook they show ~340 potions total. A person could make a name to id mapping and keep that in one of their plugin files. That way when you scan through your bag, if any match one of those 340, then you have the id to convert to hex and thus make quickslot.

If you download LOTRO Compendium addon (shamless plug), you can grep through the item database for rows that have a category of potion and get all the ids :

Code:
$ grep '"Potion"' Items/CompendiumItemsDB.lua | more
{rl=1,l=15,n="+1 Hope Token (15 min)",c={"Potion"},q="Rare",id="70027FE6"},
{rl=25,l=25,n="+2 Hope Token (15 min)",c={"Potion"},q="Rare",id="70027FE3"},
{rl=30,l=30,n="+3 Hope Token (15 min)",c={"Potion"},q="Rare",id="70027FE5"},
{rl=35,l=35,n="+4 Hope Token (15 min)",c={"Potion"},q="Rare",id="70027FE7"},
{rl=40,l=40,n="+5 Hope Token (15 min)",c={"Potion"},q="Rare",id="70027FE8"},
{rl=51,l=51,n="+5 Hope Token (30 min)",c={"Potion"},q="Rare",id="70027FE4"},
{rl=35,l=35,c={"Potion","Champion","Craftable"},n="Artisan Potion of Fervour",cl="Champion",q="Uncommon",id="70024348",lb="Artisan Potion of Fervour Recipe"},
{rl=35,l=35,c={"Potion","Hunter","Craftable"},n="Artisan Potion of Focus",cl="Hunter",q="Uncommon",id="70024345",lb="Artisan Potion of Focus Recipe"},
{rl=51,l=66,n="Asteric Edhelharn Token",c={"Potion","Craftable"},q="Incomparable",id="70028075",lb="Vitreous Edhelharn Token Recipe"},
{rl=1,l=1,c={"Potion"},ib="BoA",n="Battle Potion of Defilement",q="Common",id="70028F9A"},
{rl=1,l=1,c={"Potion","Quest Reward"},ib="BoA",n="Battle Potion of Restoration",q="Common",id="70026944",qu="Vol. III, Book 4, No Mercy for Traitors"},
{rl=1,l=1,c={"Potion"},ib="BoA",n="BOO!",q="Common",id="70022C5A"},
{rl=75,l=75,n="Bottled Orc Scream",c={"Potion"},q="Common",id="7001985B"},
{rl=75,l=75,n="Bottled Spider Chitter",c={"Potion"},q="Common",id="7001985E"},
{rl=75,l=75,n="Bottled Uruk Effluvium",c={"Potion"},q="Common",id="7001985C"},
__________________
Author of Lotro Compendium, Waypoint, and Lotro Plugin Compendium (LPC)
Reply With Quote
  #6  
Unread 12-20-2011, 08:59 PM
lunarwtr's Avatar
lunarwtr lunarwtr is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Feb 2011
Posts: 121
To answer your other questoin Its my understanding that in item shortcuts..

Turbine.UI.Lotro.Shortcut( 2, '0x0000000000000000,0x70004842');

The digits to left of comma in the data string differentiates where a distinct stack in inventory is refering to, and as a result its quantity. The right hand side is the hex for what kind of item the item will be. If you zero the left side out the game seems to take a guess at which inventory slot you mean that happens to match the item id.
__________________
Author of Lotro Compendium, Waypoint, and Lotro Plugin Compendium (LPC)
Reply With Quote
  #7  
Unread 12-20-2011, 09:09 PM
Stever1388 Stever1388 is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Nov 2010
Posts: 33
Quote:
Originally Posted by lunarwtr
To answer your other questoin Its my understanding that in item shortcuts..

Turbine.UI.Lotro.Shortcut( 2, '0x0000000000000000,0x70004842');

The digits to left of comma in the data string differentiates where a distinct stack in inventory is refering to, and as a result its quantity. The right hand side is the hex for what kind of item the item will be. If you zero the left side out the game seems to take a guess at which inventory slot you mean that happens to match the item id.
Wow thank you! I've messed with those numbers so much and I was sure the whole number was different but the only the first part is.

Where are you getting the id numbers from the Lorebook?
Reply With Quote
  #8  
Unread 12-20-2011, 09:24 PM
lunarwtr's Avatar
lunarwtr lunarwtr is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Feb 2011
Posts: 121
if your desire is for a few items.. you can get item codes by viewing the "source" of the wiki article for the item in question...

i.e.

http://lorebook.lotro.com/index.php?title=Item:%2B1_Hope_Token_%2815_min%29& action=edit

results in

Code:
<noedit>
<seo title="Item DB: - Items - +1 Hope Token (15 min)" metak="lotro, Lord of the Rings Online, wiki, database, Lorebook, LOTR, Middle-earth, Tolkien, Item DB: , Items , +1 Hope Token (15 min),Potion" metad="+1 Hope Token (15 min): In the darkest of times, even the faintest glimmer of hope can make all the difference." />
<official type="game">
<item id="1879212006" name="+1 Hope Token (15 min)" />
</official>
[[Category:Potion|+1 Hope Token (15 min)]]
</noedit>

the id="........." portion is what you want.

In the past it was much easier as the JSON response of the search form returned them all en mass.
__________________
Author of Lotro Compendium, Waypoint, and Lotro Plugin Compendium (LPC)
Reply With Quote
  #9  
Unread 12-20-2011, 09:34 PM
Stever1388 Stever1388 is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Nov 2010
Posts: 33
Quote:
Originally Posted by lunarwtr
if your desire is for a few items.. you can get item codes by viewing the "source" of the wiki article for the item in question...

i.e.

http://lorebook.lotro.com/index.php?title=Item:%2B1_Hope_Token_%2815_min%29& action=edit

results in

Code:
<noedit>
<seo title="Item DB: - Items - +1 Hope Token (15 min)" metak="lotro, Lord of the Rings Online, wiki, database, Lorebook, LOTR, Middle-earth, Tolkien, Item DB: , Items , +1 Hope Token (15 min),Potion" metad="+1 Hope Token (15 min): In the darkest of times, even the faintest glimmer of hope can make all the difference." />
<official type="game">
<item id="1879212006" name="+1 Hope Token (15 min)" />
</official>
[[Category:Potion|+1 Hope Token (15 min)]]
</noedit>

the id="........." portion is what you want.

In the past it was much easier as the JSON response of the search form returned them all en mass.
I very much appreciate the help, thank you!
Reply With Quote
  #10  
Unread 12-20-2011, 09:42 PM
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 lunarwtr
If you have the Rich Text Editor on, you have to click on "Disable rich editor" to see the actual source text.
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
Help with toolbar items Pam Interface Help (L) 1 09-19-2010 10:21 PM
Inventory/Equipment Ideas Sorane LotRO Wish List (L) 0 11-02-2007 02:25 AM
simulated all-in-one-inventory Aalwein Beta Interfaces (L) 3 04-21-2007 01:31 AM
All-In-One Inventory Dandeak Interface Requests (L) 2 03-01-2007 12:07 PM


All times are GMT -5. The time now is 01:16 AM.


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