-
Posted by Jacatola on Sat, 14 Mar 2009 22:55:48
Hi, I am new to this forum and new to writing add-ons and lua but not new to programming in general
I am trying to make an add-on that will notify me in the chat window when someone is actually selling something in the trade channel. I am using the CHAT_MSG_CHANNEL event and was able to successfully verify the message was in the trade chat and that somewhere in the message there was "WTS". But in my notification I would like to include the link from the message.
I have tried to find the position of the start of the entire like using strfind(message, "\")
I have also tried to find the position of the start of the name using strfind(message, "[")
both of these return an error in the game telling me I have an unfinished string in this line
I also tried to find the name of the item using findpatter(arg1, '[..*]') and variations of the same patterns (don't know if i am uisng thes patterns correctly)
this returns an error that my pattern returned a nil value.
I have done significant research and could not find any documentation about dealing with itemlinks.
any help would be greatly appreciated, Thank you
-
Posted by Jacatola on Sat, 14 Mar 2009 22:55:49
Hi, I am new to this forum and new to writing add-ons and lua but not new to programming in general
I am trying to make an add-on that will notify me in the chat window when someone is actually selling something in the trade channel. I am using the CHAT_MSG_CHANNEL event and was able to successfully verify the message was in the trade chat and that somewhere in the message there was "WTS". But in my notification I would like to include the link from the message.
I have tried to find the position of the start of the entire like using strfind(message, "\")
I have also tried to find the position of the start of the name using strfind(message, "[")
both of these return an error in the game telling me I have an unfinished string in this line
I also tried to find the name of the item using findpatter(arg1, '[..*]') and variations of the same patterns (don't know if i am uisng thes patterns correctly)
this returns an error that my pattern returned a nil value.
I have done significant research and could not find any documentation about dealing with itemlinks.
any help would be greatly appreciated, Thank you
-
Posted by jnwhiteh on Sun, 15 Mar 2009 06:12:31
Going off the information on WoWWiki regarding item links: http://www.wowwiki.com/ItemLink
The following code will print a message to your chatframe anytime someone posts an item link in a chat channel:
if not ItemCatchFrame then
ItemCatchFrame = CreateFrame("Frame")
end
local frame = ItemCatchFrame
frame:RegisterEvent("CHAT_MSG_CHANNEL")
frame:SetScript("OnEvent", function(self, event, ...)
local msg, user = ...
for itemLink in msg:gmatch("|%x+|Hitem:.-|h.-|h|r") do
print("item link posted by " .. user .. ": " .. itemLink)
end
end) -
Posted by Jacatola on Sun, 15 Mar 2009 11:55:18
Thank you very much, That pattern works great.
I did read that page, my problem was that I was trying to use findpattern() instead of string.find or gmatch
Thank you again :)