Page 1 of 1

Multiple variable input alias

Posted: Tue Jul 12, 2016 7:25 pm
by Config
I am on a MOO, and want to program expressions for my character to make. This works with pose. For example I can type "pose wave name says, "Hello" ". The MOO will turn it into: "You wave at name and say, "Hi". That's pretty cool but it is a lot to type. I'm trying to automate the feature. So basically I need something like this:

pose wave $1 says, "$2" (where $1 is the target name, and $2 is what I want to say.

Re: Multiple variable input alias

Posted: Wed Jul 13, 2016 2:19 am
by Config
I solved the problem, first you need the right pattern:
^waveme (.*) (.*)$

Then you need the right script:
send("pose wave to " .. matches[2] .. " with a devilish grin and say \"" .. matches[3] .. "\"")

Then I just type: waveme name message


I love this client. Do you think you will ever get it running on a phone?

Re: Multiple variable input alias

Posted: Wed Jul 13, 2016 3:43 am
by Config
Actually I've discovered that the above solution didn't work. This one does:
pattern:
^wave1 *(\w*) .*?(.*)

script:
send( "pose wave to "..matches[2].." and says, \""..matches[3].."\" " )

Re: Multiple variable input alias

Posted: Wed Aug 31, 2016 8:28 am
by Buck
^wave1 *(\w*) .*?(.*)

Will still give you trouble in some cases. Better would be

^wave1\s+(\w+)\s+(.+)

* matches 0 or more
+ matches 1 or more

Since the two arguments are not optional, you want to use + instead of *. Between the arguments, you only want to match whitespaces, so don't use . which matches any character; use \s instead.