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.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ General
➜ Variables & the command line
Variables & the command line
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Callista
(3 posts) Bio
|
Date
| Sat 28 Jun 2008 01:33 AM (UTC) |
Message
| How do you use a variable from the command line? Every time I try, the program doesn't know what I'm doing.
For example: The variable "sword1" is given a value of "sword134878". But when I type in "examine @sword1", the program returns that I don't have such an item. When I use it as a part of a script it works just fine. What am I doing wrong?
Second question: I want to use an alias with variables in it, like so:
<aliases>
<alias
match="vv * *"
enabled="y"
expand_variables="y"
sequence="100"
>
<send>envenom @sword1 with @%1
envenom @sword2 with @%2
</send>
</alias>
</aliases>
The asterisks are both going to be aliases referring to different types of venoms. I don't want to type out the whole name because it would take overly long. And it's really, really inelegant to type out all possible combinations of venoms and make an alias for each. That would be ridiculous.
I think this is connected to the "using a variable from the command line" problem because of course this particular alias is sending variables to the command line. | Top |
|
Posted by
| Nick Gammon
Australia (23,140 posts) Bio
Forum Administrator |
Date
| Reply #1 on Sat 28 Jun 2008 03:01 AM (UTC) Amended on Sat 28 Jun 2008 06:36 AM (UTC) by Nick Gammon
|
Message
| For expanding variables on the command line, see this post:
http://www.gammon.com.au/forum/?id=8557
Look for the short plugin Expand_Variables - with that installed it will expand variables.
However to solve your particular case you can save having to use the @ at all, if you use this alias:
<aliases>
<alias
match="vv * *"
enabled="y"
send_to="12"
sequence="100"
>
<send>
require "var"
Send ("envenom " .. var.sword1 .. " with " .. var ["%1"])
Send ("envenom " .. var.sword2 .. " with " .. var ["%2"])
</send>
</alias>
</aliases>
With that you could just type: vv v1 v2
And if v1 was a variable for venom1, and v2 was a variable for venom2, then they would both be looked up, and the appropriate swords envenomed.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | 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.
11,263 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top