Chat parse to out-game services

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
Stionowl1943
Posts: 35
Joined: Thu Jun 04, 2015 11:57 am

Chat parse to out-game services

#1 Post by Stionowl1943 » Sat Jul 11, 2015 11:00 pm

Hello, i work on redirect ingame chat to my website via micromacro in real time.
I have problem with correctly parse strings with items name.

Example chat message catched by mm:

Code: Select all

SELL1 |Hitem:3466e 3 141264 c998c9d4 c844ca38 c9c0c9fc 7f26a 7f242 7f454 7f206 45e5 a498|h|cffa37d50[ITEMNAME1]|r|h SELL2 |Hitem:334ac 3 141264 c998c9d4 c844ca38 c9c0c9fc 7f26a 7f242 7f454 7f206 45e5 a498|h|cffa37d50[ITEMNAME2]|r|h
for delete useless strings i used:

Code: Select all

local parsemsg = str:gsub("|Hitem:.-|h|(%x+)","")
local parsemsg2 = parsemsg:gsub("|r|h", "")
print(parsemsg2)
effect

Code: Select all

SELL1 [ITEMNAME1] SELL2 [ITEMNAME2]
now im interested in to catch hex values with id/runes/attributes for build completly view of item. From my example i expect:

Code: Select all

3466e 3 141264 c998c9d4 c844ca38 c9c0c9fc 7f26a 7f242 7f454 7f206 45e5 a498
334ac 3 141264 c998c9d4 c844ca38 c9c0c9fc 7f26a 7f242 7f454 7f206 45e5 a498
i used

Code: Select all

local str_hex1 = string.match(str, "|Hitem:.+.|h|c");
local str_hex2 = str_hex1:gsub("|Hitem:","")
local str_hex3 = str_hex2:gsub("|h|c", "")
print("HEX: "..str_hex3)
but it works good only for 1 item.
In that example effect is:

Code: Select all

3466e 3 141264 c998c9d4 c844ca38 c9c0c9fc 7f26a 7f242 7f454 7f206 45e5 a498ffa37d50[Dagger of Extremes]|r|h SELL2 334ac 3 141264 c998c9d4 c844ca38 c9c0c9fc 7f26a 7f242 7f454 7f206 45e5 a498
I triend use parseItemLink(itemLink) from micromacro/rom/functions.lua but u have the same problem.
I spend a lot of hours for read LUA documentation about string modification and patterns, but i cant find good method.
So.. any idea how catch HEX values when i have more than 1 item?

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Chat parse to out-game services

#2 Post by rock5 » Sun Jul 12, 2015 2:54 am

".+" will match the largest matching string so from the first "|Hitem:" to the last "|h|c". If you use ".-" it will match the smallest string so would give you only the first item. If you want both you could use gmatch.

Code: Select all

for str_hex1 in str:gmatch("|Hitem:.-.|h|c") do
    str_hex2 = str_hex1:gsub("|Hitem:","")
    str_hex3 = str_hex2:gsub("|h|c", "")
    print("HEX: "..str_hex3)
end
I just tested that and it worked.

Code: Select all

HEX: 3466e 3 141264 c998c9d4 c844ca38 c9c0c9fc 7f26a 7f242 7f454 7f206 45e5 a498
HEX: 334ac 3 141264 c998c9d4 c844ca38 c9c0c9fc 7f26a 7f242 7f454 7f206 45e5 a498
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 24 guests