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.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ VBscript ➜ Macro Swapper

Macro Swapper

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


Posted by PJ   USA  (48 posts)  Bio
Date Sat 10 Aug 2002 04:27 AM (UTC)
Message
I play a PK mud and I have trouble with people triple teaming me because I can never keep my macros set for the people I want to kill at certain times. I want to make MUSHclient swap them for me by using a scrip/plugin of some sort.

My idea is this:
A and B are attacking me, I want to be able to have a command to swap my macros from Bodyslam A to Bodyslam B.

The problem with that is that I dont use just one character class, so I'm often using macros like Cast 'Lightning' A or Backstab A..

Is there a way to have it leave the base of my macro alone while it changes A to B?
Top

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #1 on Sat 10 Aug 2002 06:51 AM (UTC)
Message
An interesting problem. :)

First, I assume by "macros" you are referring to MUSHclient macros, which are things that happen when you press F2, F3 etc.? In that case, we need to migrate the actions that happen into aliases, because aliases give us the power to call scripts, do variable substitution, and so on.

To do that, edit each macro and make them send a string you wouldn't normally use in the MUD - I'll take the example of F2 sending "macro_F2+++" and so on.

To do this quickly, copy the stuff between the lines, and go to the File Menu -> Import -> Clipboard.



<!-- macros -->

<macros>

  <macro name="F2" type="send_now" >
  <send>macro_F2+++</send>
  </macro>

  <macro name="F3" type="send_now" >
  <send>macro_F3+++</send>
  </macro>

  <macro name="F4" type="send_now" >
  <send>macro_F4+++</send>
  </macro>

  <macro name="F5" type="send_now" >
  <send>macro_F5+++</send>
  </macro>
</macros>




Next, we need some aliases to do the actual work (bodyslam, backstab, cast spells etc.). We will target a variable with them so we can quickly modify who they will affect, eg. "bodyslam @target".

Here are some example aliases that do that, note how we match on the string sent by the macro. If you don't want to use F2, F3 etc. but actually type an alias, just make the match string shorter and more meaningful (eg. "bs" for bodyslam).




<aliases>
  <alias
   match="macro_F2+++"
   enabled="y"
   expand_variables="y"
  >
  <send>bodyslam @target</send>
  </alias>
  <alias
   match="macro_F3+++"
   enabled="y"
   expand_variables="y"
  >
  <send>backstab @target</send>
  </alias>
  <alias
   match="macro_F4+++"
   enabled="y"
   expand_variables="y"
  >
  <send>Cast 'Lightning' @target</send>
  </alias>
</aliases>




(You can import those too through the File -> Import if you want to).

Next we want a way of setting up our targets (your A and B) and swapping them. So we need four more aliases, and a small bit of scripting...

Below are the aliases, I am using "seta" to set target A, "setb" to set target B, "swap" to swap between them, and "list_targets" to show what they currently are.




<aliases>
  <alias
   script="On_List_Targets"
   match="list_targets"
   enabled="y"
  >
  </alias>
  <alias
   script="On_Set_A"
   match="seta *"
   enabled="y"
  >
  </alias>
  <alias
   script="On_Set_B"
   match="setb *"
   enabled="y"
  >
  </alias>
  <alias
   script="On_Swap"
   match="swap"
   enabled="y"
  >
  </alias>
</aliases>





The scripts below set and swap the variables - copy and paste into your script file (VBscript). You might make the "swap" one bind to a macro key (eg. make F9 send "swap" would do it).




sub On_Set_A (aliasname, full_line, wildcards)

dim target

  target = wildcards (1)
  world.setvariable "A", target
  world.note "Target A set to " & target

  world.setvariable "target", target
  world.note "Current target now " & target
end sub

sub On_Set_B (aliasname, full_line, wildcards)

dim target

  target = wildcards (1)
  world.setvariable "B", target
  world.note "Target B set to " & target

end sub

sub On_List_Targets (aliasname, full_line, wildcards)

  world.note "Target A = " & world.getvariable ("A")
  world.note "Target B = " & world.getvariable ("B")
  world.note "CURRENT target = " & world.getvariable ("target")

end sub

sub On_Swap (aliasname, full_line, wildcards)

dim A, B

  A = world.getvariable ("A")
  B = world.getvariable ("B")

  if world.getvariable ("target") = A then
     world.setvariable "target", B
  else
     world.setvariable "target", A
  end if

  world.note "Current target now " & world.getvariable ("target")

end sub




To use, set up your targets when required, eg.


seta Wiciedan
setb Miriradon


Then hit your function keys to attack them, and type "swap" (or the function key you have set up to send "swap" to swap between them). Say you made it F9, then you could do this ...


F2 F9 F2


That would send:


bodyslam Wiciedan
bodyslam Miriradon

- Nick Gammon

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

Posted by PJ   USA  (48 posts)  Bio
Date Reply #2 on Sat 10 Aug 2002 07:31 AM (UTC)
Message
Thanks a ton, Nick, it all worked like a charm!

~Monkey
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.


13,979 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.