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 ➜ General ➜ Targets

Targets

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


Posted by Nat   (1 post)  Bio
Date Sun 23 Dec 2001 03:22 PM (UTC)
Message
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.
Top

Posted by Magnum   Canada  (580 posts)  Bio
Date Reply #1 on Mon 24 Dec 2001 08:55 AM (UTC)
Message
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. :)

Get my plugins here: http://www.magnumsworld.com/muds/

Constantly proving I don't know what I am doing...
Magnum.
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #2 on Wed 26 Dec 2001 12:03 AM (UTC)

Amended on Wed 26 Dec 2001 12:06 AM (UTC) by Nick Gammon

Message
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.




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


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