As you will have noticed, having a lot of work making WLAs means lot's of incoming posts about the topic. I've planned at least another two or three more, but I'll try to talk about other topics too. Anyway, let's get to the topic.
Sometimes, we might need to create a Catch-all pattern like the default "+ CATCH=Anything" , for example to get every user input under a filter under specific conditions.
For example, we could be doing a search and want everything that the user types to be checked for available responses (instead of using multiple patterns, centralized in one).
+ PASS=Anything {score=200}
VALID = false
if (PASS == "abracadabra")
VALID = true
if (VALID)
- Congratulations, you guessed the magic word :)
else
- Invalid!
This code will only work if the user types correctly "abracadabra" in lowercase. Else it will fail. We have functions to do lowercasing and even thawed versions of a variable, but the less code the better, so go and take a look at \BuddyScriptLib\Required\BasicMatching.pkg library...
Change the first line to the following:
+ KEYWORD=AnythingThawed {score=200}
Voila! Now "AbraCaDaBrA" will work too, and if we add more ifs/checks, we only have to make sure they are typed in thawed version (lowercase and no special characters), no need to worry for formatting PASS.
Tags: Development