Targets

Posted by Nat on Sun 23 Dec 2001 03:22 PM — 3 posts, 13,719 views.

#0
I was wondering how exactly you set up a target alias within Mushclient.

On Zmud it used to be
set alias to: t
set command to: target=%1

then you just set up macros or other aliases for your attacks as (for example):
bs for backstab @target
tt for throttle @target

so if i typed: t Azrael
then typed: tt
the command sent would be: throttle azrael


I've tried this on mushclient but its obviously not the same system, so I'm a bit stumped. I tried looking through the help files for this topic but there was nothing avaliable.

Cheers,
Nat.
Canada #1
With an alias, you could setup something like:

Alias: bs *
Send : backstab %1

...but in order to assign a value to a variable, you MUST invoke a script routine. Although programming can seem far too complicated for most people, it's actually not very difficult to do simple things like this small project you would like to accomplish.

Alias : t *
Send : LEAVE THIS AREA BLANK.
Label : Alias_Set_Target
Script: Set_Target

In order to call a script routine, you MUST give your alias a name, which you enter in the "Label" box. Below that (in the "Script" box), you enter the name of the subroutine you wish to have executed when the alias is called.

Mushclient allows you to program in one of three languages. Most beginners use VisualBasicScript.

A script file is basically a text (.txt) file, except it uses a different extension on the filename. VisualBasicScript files will end with .vbs .

You could open up "Notepad" in windows, and type (or Copy&Paste) the following:

Dim Target

Sub Set_Target (AliasName, TriggerLine, arrWildcards)
World.SetVariable "Target", arrWildcards(1)
World.Note "Target: " & World.GetVariable("Target")
End Sub

That's it. (Don't include this line). The first line "Dim Target" tells VBS to create a variable with the name "Target".

The line that starts with "Sub" marks the beginning of the subroutine, and assigns it the name "Set_Target". The three words in brackets are variables, and they automatically get filled in with data that MushClient passes along. "AliasName" is the name of the alias that made a call to this subroutine. "TriggerLine" is the line of output from the MUD that caused the trigger to go off. (Not applicable when an alias is calling the subroutine). "arrWildcards" are the wildcards that were caught by the alias or trigger. It's actually possible to capture up to 10 wildcards, but in this case, we just grab 1.

The "World.SetVariable" line is saying we want to put a value into the variable in quotes, which is "Target", and the value we are giving is the first wildcard, which is signified by 'arrWildcards(1)'. If you wanted to work with a second wildcard, it would be 'arrWildcards(2)'.

The "World.Note" line is a command to send output to the mud screen. Essentially, we are just providing output to confirm the variable was set.

"End Sub" indicates the subroutine is finished, and returns control back to the source that made the call to this routine. (Mushclient).

Once you have those 5 lines in NotePad, you would save it to a directory on your hard drive. I would recommend putting it in the same place your .MCL file for this MUD is stored. Give it a name that suits the MUD too. For example "Realms Of Despair.vbs".

Once all that is done, you go into mushclient and bring up the world properties. In the section marked "Scripting | Scripts", you would want to:

Set the scripting language as "VBscript"
Check the box marked "Enable Script"
Script File: <Point to the File you created on your hard drive>

Click Ok, and you are done setting up the script.

Now, to access the variable with another alias, you would begin the process of creating a new alias, and use these values:

Alias : tt
Send : throttle @Target

You also MUST check the box marked "expand variables", which tells Mushclient that "@Target" is an alias name.

You are all done. :)
Australia Forum Administrator #2
That was an excellent reply, but I might just comment on one statement:

Quote:

...but in order to assign a value to a variable, you MUST invoke a script routine.


There are two ways of assigning a value to a variable without using scripting:

  1. Type a direct script command, this isn't too hard:


    /world.setvariable "target", "dragon"


    This uses "immediate" scripting to set the variable "target" to the value "dragon". You can then use @target in triggers and aliases as Magnum described.
  2. Use a trigger, and set the trigger to send the response to "Variable (label is name)".

    Thus you could make a trigger, that for instance, matched on:


    Trigger: * attacks you!
    Send: %1
    Send to: Variable (label is name)
    Label: Target


    Thus, every time something attacks you it becomes the "target" that you can then use in aliases.