wildcards

by Yurika

Back to Mechanic's Corner.

Yurika2009-05-22 00:10:31
Ok, I'm using vbscript, but I want to know how to make a wildcard target, so that in place of a set target, I can put any name there by typing it in rather than doing x=cow and then doing another alias for the set target.

example: tea
outd teacher
fling teacher @ %1 (?) <---- that being either me/target to be typed in as such:

outd teacher, fling teacher @ me, dog, cat without setting a prior variable for a target for any of those.

Basically, what variable makes that possible?
Unknown2009-05-22 00:17:08
It's not so much the script language that's important. Should we assume MUSHclient?
Yurika2009-05-22 00:27:24
yeah, its mushclient
Aerotan2009-05-22 00:45:25
I BELIEVE the wildcard for a string is (\\w)

So the alias would be "^tea (\\w)$"

Generally, I make two aliases one with and one without that wildcard, so if I do have a target set, I can just "tea" and it'll assume "tea @target"

Or more accurately, I'd set "^tea$" to do "outd teacher;fling teacher @target" and "^tea (\\w)$" to set the target variable to %1, then do the same bit of code as above.
Unknown2009-05-22 01:08:22
For a proper regular expression, you'd use (\\w+) for your wildcard. The + is important, or else you can only have one character matches.

It might help you to look at my MUSHclient tutorial to get a handle on making a basic alias or two. If that doesn't do it, ask more questions!
Shaddus2009-05-22 11:04:23
I always use something like this.


QUOTE
Alias: tea *
does

outd hangedman
fling hangedman at %1


Will this not work for your purposes?

Yurika2009-05-22 18:18:14
That worked just perfectly using the * thing and the %1.
Much appreciated!!!

And thank you to all the others that offered their advice as well. content.gif
Shaddus2009-05-22 21:04:41
QUOTE (Yurika @ May 22 2009, 01:18 PM) <{POST_SNAPBACK}>
That worked just perfectly using the * thing and the %1.
Much appreciated!!!

And thank you to all the others that offered their advice as well. content.gif

Also, you can use multiples. For instance, I have something like this on one of my characters, a telepath. The exact channels aren't correct, writing this from memory

QUOTE
tp * * *

does

psi id (target alias) %1
psi sub (target alias) %2
psi super (target alias) dominate %3


so I can use
QUOTE
tp phobia recklessness tumble down


and it uses

QUOTE
psi id target phobia
psi sub target recklessness
psi super target dominate tumble down


Or whatever I want.
Unknown2009-05-22 22:09:27
These simple patterns are useful for certain things, but they won't cover everything. For example, you couldn't put that "tumble down" as the first or second argument.

With regular expressions, you get greater control. I can make aliases, for example, such that one matches on "auto on/off" and another matches on "auto show" or "auto deaf" or anything else that might otherwise confuse an alias that was just "auto *". (Not a great example, but I do other, similar sorts of things with regex aliases, just not posting them here.)