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 ➜ alias limitations

alias limitations

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


Posted by Girdy   (9 posts)  Bio
Date Sun 14 Apr 2002 05:12 AM (UTC)
Message
Okay, tell me if this is possible.

I'd like to have floating variables that different aliases can assess. For example, lets say that I have three attacks, kick, punch and jab.

I'd like to create a targetting variable:

alias: tt *
does: $target= %1

And then use other aliases using the target variable.

alias: k
does: kick $target


Is this possible?
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #1 on Sun 14 Apr 2002 11:58 AM (UTC)
Message
It is possible. First the second, easy part. You can refer to a variable in an alias by preceding it by "@" provided you check the "Expand variables" box.

eg.


kick @target


To set the variable, you can make an alias to do that, however the alias needs to call a small script. eg.


alias: tt *
send: (nothing)
label: settarget
script: OnSetTarget


In the script file:


sub OnSetTarget (strName, strLine, aryWildcards) 
  world.setvariable "target", aryWildcards (1)
end sub


If you don't want to make a script, you can do it manually providing scripting is enabled. Just type:


/world.setvariable "target", "dragon"

- Nick Gammon

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

Posted by Girdy   (9 posts)  Bio
Date Reply #2 on Sun 14 Apr 2002 07:56 PM (UTC)
Message
alias: tt *
send: (nothing)
label: settarget
script: OnSetTarget

I understand that script calls the Sub OnSetTarget script, but what does the label do?
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #3 on Sun 14 Apr 2002 09:59 PM (UTC)
Message
The label gives the alias a name. It is required because the script routine gets the name passed to it. However the name is fairly arbitrary. I suggested recently to someone else they use the names to organise their trigger and aliases. eg. the name could just as well be:

label: alias_to_set_the_target_variable

That way you can browse through the labels in the alias window to see what each one does.

- Nick Gammon

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

Posted by Girdy   (9 posts)  Bio
Date Reply #4 on Sun 14 Apr 2002 10:32 PM (UTC)
Message
Really? So any subroutine I write has to have at least (strName, strLine) as predeclared variables?
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #5 on Mon 15 Apr 2002 02:14 AM (UTC)
Message

Not exactly. See Callback routines for details about the arguments you should use for each subroutine.


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


21,874 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.