[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Variables & the command line

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Variables & the command line

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page


Posted by Callista   (3 posts)  [Biography] bio
Date Sat 28 Jun 2008 01:33 AM (UTC)  quote  ]
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.
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Sat 28 Jun 2008 03:01 AM (UTC)  quote  ]

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
[Go to top] top

Posted by Callista   (3 posts)  [Biography] bio
Date Reply #2 on Sat 28 Jun 2008 03:59 AM (UTC)  quote  ]
Message
Worked well, Thanks.
[Go to top] 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.


1,170 views.

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]