WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   get ItemLinks from GetItemInfo() (https://www.wowinterface.com/forums/showthread.php?t=54772)

nicarao 10-31-16 08:52 PM

get ItemLinks from GetItemInfo()
 
Hi people,

it is 3:30 am here and i am still having this issue, maybe you guys can help me out:

Goal

I want to make an Addon based on Ashran Commander. It should have Buttons which on click send messages in the chat (RAID_WARNING + INSTANCE_CHAT). The idea is to include Links for Items and Spells in the commands, so that people can click on the links and understand better how to play in Ashran(or later in other BGs).

Problem

Right now i fetch the spell link with this code (spellID 2825 = bloodlust):
Quote:

spellLink1 = select(1,GetSpellLink(2825));
And output the link with
Quote:

SendChatMessage("Use your cooldowns! like "..spellLink1.." and so on","RAID_WARNING");
specc: http://wowprogramming.com/docs/api/GetSpellLink

This works fine for spells, but for items it doesnt work (itemID 114982 = song flower) ->
Quote:

itemLink1 = select(2,GetItemInfo(114982));
Quote:

SendChatMessage("Rebuff! Use Bufffood and "..itemLink1.." please.","RAID_WARNING");
specc: http://wowprogramming.com/docs/api/GetItemInfo

Or i should say: it works sometimes for a couple of items, then it returns again nil. I know this has to do with the Cache/Server response for getItemInfo() but i dont know how to solve this problem in my Addon.

Please help me out. Any kind of information can bring me foward, i can also post more informations about my Addon if necessary.

Sinc. Nicarao/Priskah

Edit: If you want to see the whole code:
http://www.nicarao.eu/downloads/Ashr...kahEdition.zip

Lombra 11-01-16 05:12 AM

Easiest way would probably be to hardcode the whole link. I think that will work every time.
Code:

SendChatMessage("Rebuff! Use Bufffood and |cffffffff|Hitem:114982|h[Song Flower]|h|r please.", "RAID_WARNING")

nicarao 11-01-16 06:39 AM

Quote:

Originally Posted by Lombra (Post 320565)
Easiest way would probably be to hardcode the whole link. I think that will work every time.
Code:

SendChatMessage("Rebuff! Use Bufffood and |cffffffff|Hitem:114982|h[Song Flower]|h|r please.", "RAID_WARNING")

I tried that, unfortunatly it doesnt work, the message is not sent at all.
Honestliy i would like to create the item links hardcoded because they are always the same. But i havent figured out how.
|cffffffff|Hitem:114982|h[Song Flower]|h|r only works with DEFAULT_CHAT_FRAME:AddMessage

Lombra 11-01-16 08:06 AM

I removed some bits from the link that I thought were unnecessary, but maybe they're not. Try this:
Code:

SendChatMessage("Rebuff! Use Bufffood and |cffffffff|Hitem:114982::::::::110:::::|h[Song Flower]|h|r please.", "RAID_WARNING")

nicarao 11-01-16 09:44 AM

Quote:

Originally Posted by Lombra (Post 320572)
I removed some bits from the link that I thought were unnecessary, but maybe they're not. Try this:
Code:

SendChatMessage("Rebuff! Use Bufffood and |cffffffff|Hitem:114982::::::::110:::::|h[Song Flower]|h|r please.", "RAID_WARNING")


Thanks for your help :)

Altought it doesnt work.

I also tried
Lua Code:
  1. DEFAULT_CHAT_FRAME:AddMessage("|cff9d9d9d|Hitem:7073:846:0:0:0:0:924:0|h[Broken Fang of the Gorilla]|h|r");
  2. SendChatMessage("|cff9d9d9d|Hitem:7073:846:0:0:0:0:924:0|h[Broken Fang of the Gorilla]|h|r","SAY");
  3. SendChatMessage("test","SAY");

And the output is:
1. the Itemlink in my Chatframe (only visible for me)
2. nothing
3. "test"
So this would mean that a hardcoded link is not outputable via SendChatMessage function. :<

Voyager 11-01-16 04:02 PM

Just force it to be cached on ui load.

Lua Code:
  1. local f = CreateFrame("Frame")
  2. f:RegisterEvent("PLAYER_LOGIN")
  3. f:SetScript("OnEvent", function(self, event, ...)
  4.     f:UnregisterEvent("PLAYER_LOGIN")
  5.     f:SetScript("OnEvent", nil)
  6.     GetItemInfo(114982)
  7. end)


All times are GMT -6. The time now is 03:17 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI