Quantcast string patterns are so confusing... - WoWInterface
Thread Tools Display Modes
02-12-18, 10:13 PM   #1
Engavi
A Fallenroot Satyr
Join Date: Nov 2017
Posts: 27
string patterns are so confusing...

I am aware of that Wowpedia has a great tutorial(?) for pattern matching, but this is still sooooooooooooooo confusing!
Even for simple ones, I really can't figure out how

So, I'm currently playing around with COMBAT_LOG_EVENT_UNFILTERED and willing to separate its subEvent into prefix and suffix. It would have been easier if each prefix or suffix had a single word, but some of them are combination of two words including underscores (e.g. _EXTRA_ATTACKS, SPELL_PERIODIC).

Any helps, please?
  Reply With Quote
02-13-18, 01:02 AM   #2
myrroddin
A Molten Giant
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 865
Instead of pattern matching, if you need several sub-events, create a table:
Lua Code:
  1. local sub_events = {
  2.     "PARTY_KILL" = true,
  3.     "UNIT_RESURRECTION" = true,
  4.     -- etc
  5. }
Register COMBAT_LOG_EVENT_UNFILTERED as usual, then check the event arg
Lua Code:
  1. if sub_events[event] then
  2.     -- found it, do something
  3. end
  Reply With Quote
02-13-18, 03:17 AM   #3
Engavi
A Fallenroot Satyr
Join Date: Nov 2017
Posts: 27
That's a great idea
Since I only need six sub events at the moment, I would use it for now.

But, I would like to learn pattern matching as well for later use.
Maybe I was a bit impatient and should re-visit Wowpedia's tutorial, tho

Last edited by Engavi : 02-13-18 at 03:36 AM.
  Reply With Quote
02-13-18, 05:24 AM   #4
Kanegasi
A Chromatic Dragonspawn
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 190
If you donít mind using the scenic route, find any tutorial on regular expressions (commonly known as regex), then learn Lua pattern matching. Same concepts and mostly same implementation, Lua just isnít as extensive or versatile. There should be a ton of resources on regex online, since it is widely used. It should help you understand better knowing how and where Lua pattern matching gets its ideas.
  Reply With Quote
02-13-18, 05:53 AM   #5
Engavi
A Fallenroot Satyr
Join Date: Nov 2017
Posts: 27
That would be much better!

Lua has an official documentation as well as couple of tutorials (like Wowpedia's one), but I personally find them not clear :/

Thanks for the tip

Last edited by Engavi : 02-13-18 at 05:56 AM.
  Reply With Quote
02-13-18, 11:33 PM   #6
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,434
http://lua-users.org/wiki/PatternsTutorial
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » string patterns are so confusing...

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