Question on Aliases

Post Reply
Ath
Posts: 3
Joined: Sun Nov 13, 2011 11:08 pm

Question on Aliases

Post by Ath »

Hi, i'm a new user of mudlet and had a quick question on aliases.

So basically i would like to make an alias to work as the second word.. example: "half-elf"
i tried: send (matches[2] .. " half-elf") pattern: ^(.*) he$

This worked but not to the extent that i need it to work. Normally the first word(letter) would be an alias itself which is making this tough for me to figure out.

Help is appreciated! I love the client!

User avatar
Omit
Posts: 190
Joined: Sun Aug 01, 2010 10:54 pm
Location: Middle Earth
Contact:

Re: Question on Aliases

Post by Omit »

Check the manual.... I don't quite follow what you are tring to do but maybe this will help...

matches[1] is the entire line
matches[2] is the first wildcard value
matches[3] is the second wildcard value
...

Ath
Posts: 3
Joined: Sun Nov 13, 2011 11:08 pm

Re: Question on Aliases

Post by Ath »

More or less I'm trying to have 2 aliases go off at the same time.. not sure if its possible.

Say fh is full heal and he is half-elf

I would like to simply do
fh he
and get
cast 'full heal' half-elf as the final product

User avatar
Omit
Posts: 190
Joined: Sun Aug 01, 2010 10:54 pm
Location: Middle Earth
Contact:

Re: Question on Aliases

Post by Omit »

You will need to do something with the second varible as it will change(unless I don't understand the problem) so
maybe alias a pattern like...
^fh (.*)$ (assumes you want to fully heal the target)

you will need some way to interpert the target... I would use a table

raceTable= {}
raceTable["he"]= "half-elf"
raceTable["e"]= "elf"
raceTable["ho"]= "hobbit"

then....
m2=matches[2]
if raceTable[m2] then
target = raceTable[m2]
send("full heal "..target)
end


Edited to fix braces on table...oops

(have not tried any of this code but it should be close to what you want.... if not let me know.)

Delrayne
Posts: 159
Joined: Tue Jun 07, 2011 7:07 pm
Contact:

Re: Question on Aliases

Post by Delrayne »

Or you could make seperate aliases on for each one, and use expandAlias() when you need to call one.

For example:
Code: [show] | [select all] lua
Alias: ^eh$
code:
send("half-elf")
Code: [show] | [select all] lua
Alias: ^fh$
code:
send("full heal")
expandAlias("eh")
In z/cmud you could just use the alias itself without any special precursors. Which made infinite looping of an alias a problem if you weren't careful. Eitherway, its worth a read if you haven't used expandAlias() before.

Ath
Posts: 3
Joined: Sun Nov 13, 2011 11:08 pm

Re: Question on Aliases

Post by Ath »

Excellent, thanks alot for the info. I think i'm going to try both... and will look at the manual.

Post Reply