Use of variables in targetting

Posted by Tamkul on Thu 20 Mar 2008 12:41 AM — 12 posts, 39,181 views.

#0
Hey everyone, I'm new to using the MUSHclient, and recently, I've been experiencing a lot of trouble trying to set up an alias which will allow me to 'target' things. For instance, I want the alias to set a variable(The thing I'm targetting), then have another alias be able to do something with that variable.

For instance, I'd use 't' to 'set variable "target"', then I'd make another alias to do 'kt' to 'kick "target"'. Any help(If you made sense of my babbling)?
Australia Forum Administrator #1
See http://mushclient.com/faq points 21 and 22.
#2
I've tried using that, but when I type in "target rat" or something, it doesn't do anything at all, and the variable is never set. What's the problem?

EDIT: Also, my alias is set to pt, which does "punch @target". Is that right?
Amended on Thu 20 Mar 2008 10:33 PM by Tamkul
Australia Forum Administrator #3
Can you copy both of your aliases and paste them here please? See http://www.mushclient.com/copying

Your "pt" is correct *if* you have checked "expand variables".
#4
<aliases>
<alias
match="pt"
enabled="y"
sequence="100"
>
<send>punch @target</send>
</alias>
</aliases>





<aliases>
<alias
match="target *"
enabled="y"
variable="target"
send_to="9"
sequence="100"
>
<send>%1</send>
</alias>
</aliases>
Australia Forum Administrator #5
Quote:

when I type in "target rat" or something, it doesn't do anything at all ...


When I tried your alias it set the variable "target" to be "rat". Check the "variables" tab in the world configuration.

As for your "pt" alias, I said you need to check "expand variables" which you didn't do. Try this:

<aliases>
  <alias
   match="pt"
   enabled="y"
   expand_variables="y"
   sequence="100"
  >
  <send>punch @target</send>
  </alias>
</aliases>


That worked for me, I typed "pt" and it sent "punch rat".
Australia Forum Administrator #6
For your target alias, you can make it echo the new target like this (if you have your scripting language set to Lua):


<aliases>
  <alias
   match="target *"
   enabled="y"
   echo_alias="y"
   send_to="12"
   sequence="100"
  >
  <send>
SetVariable ("target", "%1")
ColourNote ("white", "blue", "Target is now '%1'")
</send>
  </alias>
</aliases>


Of course, to save typing you can make it match on "t *" rather than "target *".
#7
Thanks! Though, is there any way you could do the expand variable thing with just the window instead of copy pasting all the time?
Australia Forum Administrator #8
Check the "expand variables" checkbox in the dialog box.
#9
Cool. Thanks a lot!
#10
And one more question... How would you make a macro change a variable? Like, I have a variable, defined as "arrow", and I want the macro to be able to change that when I hit the macro. How would I go about doing that?
Australia Forum Administrator #11
Basically as described in http://mushclient.com/faq point 17.

Make an alias that does what you want it to do (eg. change a variable) and then put that alias match as a macro.