Alayne 99 Posted June 21, 2017 Hello peoples! I'd like to create an event based on defpattern, as player may repeat a world generated randomly. Therefor, according to the level, the event may be partly in capital case. But I can't find a correct regexp to get the defpattern to match the word (and this only) with the right case. Knowing that here are some example of words that can be generated: aerght arhtGET aErgEHt Please, help! Quote Share this post Link to post Share on other sites
0 meko 170 Posted June 21, 2017 defpattern is case insentive, but pcre_match (and the regex operator) is not. This means you could just use "^(.*)$" with defpattern and then filter a second time (the variable is $@p0$) with pcre_match (or ~=) when the event is invoked. 1 AnnieRuru reacted to this Quote Share this post Link to post Share on other sites
0 Alayne 99 Posted June 22, 2017 Ok so basically, this should work, is it? deletepset 1; defpattern 1, "(.*)", "QuoteALL"; activatepset 1; setnpctimer 0; set .Winner,0; waitingroom($seekedWord$, 0); end; QuoteALL: if($seekedWord$ ~= $@p0$) { //case sensitive check success, do sthg } end; Quote Share this post Link to post Share on other sites
0 meko 170 Posted June 22, 2017 OnTalkNearby: .@str$ = $@p0$; if (.@str$ ~= "your regex here") { // do something } else if (.@str$ ~= "another regex") { // do something else } // etc end; OnInit: .pid = 1; // regex pattern id defpattern(.pid, "^(.*)$", "OnTalkNearby"); activatepset(.pid); Quote Share this post Link to post Share on other sites
0 Alayne 99 Posted June 22, 2017 Oh okay. Absolutely never used this ~= operator, so I don't know how it works. Allright, I'll give it a shot, thanks. Quote Share this post Link to post Share on other sites
0 meko 170 Posted June 22, 2017 Then you might want to read more about it: https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L755 https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L8020 Quote Share this post Link to post Share on other sites
0 Alayne 99 Posted June 23, 2017 It worked correctly after that edit. Thanks for the help ^^ Quote Share this post Link to post Share on other sites
Hello peoples!
I'd like to create an event based on defpattern, as player may repeat a world generated randomly.
Therefor, according to the level, the event may be partly in capital case.
But I can't find a correct regexp to get the defpattern to match the word (and this only) with the right case.
Knowing that here are some example of words that can be generated:
aerght
arhtGET
aErgEHt
Please, help!
Share this post
Link to post
Share on other sites