Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
 Entire forum ➜ MUSHclient ➜ General ➜ help with using a var or alias within a typed command

help with using a var or alias within a typed command

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Guest1   USA  (256 posts)
Date Thu 28 Aug 2003 05:07 AM (UTC)
Message
Don't know if this can be done or how, but here's a little problem I have.

I am currently using a container held in my inventory that has a fairly long name to type in. What I'd like to do is to be able to type in an alias of sorts to substitute for the container name, but there are so many different things I may want to do with it that I don't really want to make masses of aliases for all the possible things I may use it for..

eg:
instead of typing in and sending to the mud

"put knife bag-of-goodies" or
"l i bag-of-goodies" (look in)

and many many other possibilities where doing an alias that sends "put * bag-of-goodies" just won't really cover everything for me, is there any way to set it up to replace an 'alias' of sorts (say 'bag') with 'bag-of-goodies' in any line of text I happen to type in and send to the mud?

If not, this would be a pretty kewl feature if used carefully..
Top

Posted by Guest1   USA  (256 posts)
Date Reply #1 on Thu 28 Aug 2003 05:16 AM (UTC)
Message
umm.. actually would regex work for this as an alias? like

* (bag) *

would send to the mud

%1 bag-of-goodies %2

..and would this also cover if there was no value for %2?

..actually I may have answered my own question.. best I log on and test it :)
Top

Posted by Guest1   USA  (256 posts)
Date Reply #2 on Thu 28 Aug 2003 05:21 AM (UTC)
Message
nope that didn't work.. also using

* bag *

%1 could be more than one word, as could %2, or indeed %2 could be no words at all...
Top

Posted by Shadowfyr   USA  (1,788 posts)  Bio
Date Reply #3 on Thu 28 Aug 2003 06:37 AM (UTC)
Message
First off. In regexp * mean only 'one or more of', you need to tell it 'what' you want it to find one of more of. This means that .* is the same thing as * in a normal trigger, since '.' tells it to look for 'anything'.

This means that you trigger would need to be:

.* (bag) .*

However, none of this will do what you are looking for. However, using a regular expression, you may just have to do:

<alias>
match="bag"
regexp="y"
enabled="y"
<send>
bag-of-goodies
</send>
</alias>

I am not sure of this though. It should in thery replace any instance of 'bag' with bag-of-goodies. This could however cause issues.

An alternative is this:

<alias>
match = "^(put .*|l i) bag"
regexp="y"
enabled="y"
<send>
%1 bag-of-goodies
</send>
</alias>

This 'should' match on:

put <someitem> bag
l i bag

or anything else you add with another "|" between the items. This will allow you to add as many commands for the bag into the alias as you like.

It is a very good idea when you start playing with regular expressions to actually read the docs on them. If you are making such elementary mistakes as using * instead of .*, then you will have serious trouble getting them to work right. Also, in regexp, a word by itself is just that, a word. Unlike in normal triggers and aliases, there is no automatic implied start or end of line, to make it 'not' match on any part of the like actually requires telling it to look for the start '^' or end '$' of a line. ;)
Top

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #4 on Thu 28 Aug 2003 06:57 AM (UTC)

Amended on Thu 28 Aug 2003 06:58 AM (UTC) by Nick Gammon

Message
Read this post. It is about almost exactly the same thing ...

http://www.gammon.com.au/forum/?bbsubject_id=3129

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Guest1   USA  (256 posts)
Date Reply #5 on Thu 28 Aug 2003 07:05 AM (UTC)

Amended on Thu 28 Aug 2003 07:10 AM (UTC) by Guest1

Message
Thanks Shadowfyr. The second option works, but I'm trying to get away from using multiple aliases to do it. I actually put in
^(.*?) \(bag\) (.*?)$
on the alias, but just didn't bother typing all that in on here :)

Cheers Nick, going to check that thread now :)


minutes later..

Yup gotchya Nick. The 3 aliases will be the way to go, just wondered if there was another option, but it could be too dangerous going by what Meerclar wrote. I'll be using a variable with it too as that container name can very occasionally change when pthiefs are around :)

Thanks for help!
Top

Posted by Poromenos   Greece  (1,037 posts)  Bio
Date Reply #6 on Thu 28 Aug 2003 09:14 AM (UTC)
Message
Or, my personal favorite, put bag-of-goodies in the tab completion box and type "ba" and press tab...

Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it!
Top

Posted by Guest1   USA  (256 posts)
Date Reply #7 on Thu 28 Aug 2003 09:21 PM (UTC)
Message
We have 'restring tokens' on the mud I play, so I solved the 'problem' by renaming the eq to something entirely different (Bag of the Infinitely Prolonged) and changed the ID word for it to 'bag' :)
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


22,149 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.