Multiple variable input alias

Post Reply
Config
Posts: 3
Joined: Tue Jul 12, 2016 7:13 pm

Multiple variable input alias

Post 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.

Config
Posts: 3
Joined: Tue Jul 12, 2016 7:13 pm

Re: Multiple variable input alias

Post 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?

Config
Posts: 3
Joined: Tue Jul 12, 2016 7:13 pm

Re: Multiple variable input alias

Post 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].."\" " )

Buck
Posts: 19
Joined: Tue Aug 30, 2016 8:11 pm

Re: Multiple variable input alias

Post 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.

Post Reply