Easy TADS hack for HELLO [ACTOR]

It can be counterintuitive sometimes to remember the correct syntax for a typical text adventure greeting/farewell: ACTOR, HELLO
This little tidbit will accommodate players who enter HELLO ACTOR or HELLO,ACTOR (or any combo of hi/hello/bye etc.) by converting the entered text to the parser-approved format:

StringPreParser
   hiByePat = R'<NoCase>(^<space>*(?:hi|hello|bye|goodbye|good-bye|good<Space>bye))(<Space|,>+)(.+)'

   doParsing(str, which) { 
        local hiBye = rexMatch(hiByePat,str);
        if(hiBye!=nil) str = str.substr(rexGroup(1)[2]+rexGroup(2)[2]+1) + ',' + rexGroup(1)[3];
        return str;
        }
;

I made it on adv3 but I expect it will work for Lite as well.
Of course, if you already have a general-purpose preparser, you could just pull the statements out and paste them into the body…

6 Likes