defpattern: regexp, my old ennemy

Alayne

New member
Messages
345
Points
0
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!

 
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.

 
Ok so basically, this should work, is it?

Code:
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;
 
Code:
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);
 
Oh okay. Absolutely never used this ~= operator, so I don't know how it works.

Allright, I'll give it a shot, thanks.

 
Back
Top