Plugin and Aliases

Posted by Semper on Fri 04 Mar 2011 10:55 PM — 8 posts, 31,375 views.

#0
Hello,

I have been playing around with pluggins, triggers, sound and aliases for a bit since I downloaded Mushclient a week ago.

Here are three questions that have me stuck, as I am trying to figure out how to get my Targetting Pluggin to work.

I play wotmud.org.

The four questions I have been trying to figure out are the following:

1. To get the targetting pluggin to work with aliases, how do I get a client alias to reference itself to the targetting pluggin ?
2. To get the targetting pluggin to work with aliases, should I ? and if yes, how do I add the alias for a command directly to the targetting pluggin ?
3. Is it possible to allow 2 aliases to follow each other ? e.g. al z channel 'hail' and al 1 xyz so I can type z 1 and it reads channel 'hail' xyz ?
4. when I add a command to the list of commands the targetter pluggin reads, if I set k (short for kill, k is inbuilt into the mud, and not a personalised in mud/client alias) to the list, then set target deer. I can type k and it engages the deer. The problem is, unlike with aliases, the pluggin overides commands. [the aliases override the pluggin, ] E.G. I still have k in the targetter command list, then I type knock oakdoor. Since there is K in it, or starts with K, it will read the K command instead, and automatically target t1. So knock oakdoor becomes k t1. How can I fix this ? or is it better to bypass it and find one of the other solutions ?
#1
Here is the trigger pluggin I used, without the k command in the list:

Quote:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE muclient>
<!-- Saved on Wednesday, November 06, 2002, 9:25 AM -->
<!-- MuClient version 3.30 -->

<!-- Plugin "TargetSwitch" generated by Plugin Wizard -->

<!--


See: http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=1947
-->

<muclient>
<plugin
name="TargetSwitch"
author="Nick Gammon"
id="2adec0ac37689537f9e3daf2"
language="VBscript"
purpose="Demonstrates switching targets"
save_state="y"
date_written="2002-11-06 09:20:06"
requires="3.23"
version="1.0"
>
<description trim="y">
<![CDATA[
Demonstrates how you can switch targets with a couple of aliases.

Usage
-----

t1 = person (set target 1)
t2 = person (set target 2)
t3 = person (set target 3) ... and so on up to 9 ...

t1 (choose target 1)
t2 (choose target 2)
t3 (choose target 3) ... and so on up to 9 ...

punch (punch target)
kick (kick target)

eg.

t1=Bill (target 1 is Bill)
t2=Benjamin (target 2 is Benjamin)
t1 (choose Bill)
kick (kick Bill)
t2 (choose Benjamin)
kick (kick Benjamin)
t1 (choose Bill again)
punch (punch Bill)
kick (kick Bill)
t2 (choose Benjamin again)
punch (punch Benjamin)
kick (kick Benjamin)


TargetSwitch:help <-- this help
]]>
</description>

</plugin>


<!-- Aliases -->

<aliases>
<alias
script="SetTarget"
match="^t([1-9])\s*\=\s*(.+)$"
enabled="y"
regexp="y"
>
</alias>
<alias
script="ChooseTarget"
match="^t([1-9])$"
enabled="y"
regexp="y"
>
</alias>
<alias
match="^(channel 'hail'|stab|channel 'flame strike'|channel 'ice spikes'|channel 'call lightning'|channel 'fireball'|channel 'freeze'|channel 'sleep'|channel 'fear'|channel 'contagion'|channel 'blind'|channel 'chill'|channel 'hammer of air'|channel 'incinerate'|channel 'locate life'|channel 'poison'|channel 'silence'|charge|kill)"
enabled="y"
expand_variables="y"
regexp="y"
>
<send>%1 @target</send>
</alias>
</aliases>

<!-- Script -->


<script>
<![CDATA[
sub SetTarget (sName, sLine, wildcards)
dim which, to_whom
which = wildcards (1)
to_whom = wildcards (2)
world.SetVariable "target" & which, to_whom
world.ColourNote "moccasin", "darkgreen", _
"Target " & CStr (which) & " now '" & to_whom & "'"
end sub

sub ChooseTarget (sName, sLine, wildcards)
world.SetVariable "target", _
world.GetVariable ("target" & wildcards (1))
world.ColourNote "moccasin", "darkgreen", _
"Target now '" & _
world.GetVariable ("target") & "'"
end sub


]]>
</script>


<!-- Plugin help -->

<aliases>
<alias
script="OnHelp"
match="TargetSwitch:help"
enabled="y"
>
</alias>
</aliases>

<script>
<![CDATA[
Sub OnHelp (sName, sLine, wildcards)
World.Note World.GetPluginInfo (World.GetPluginID, 3)
End Sub
]]>
</script>

</muclient>
Australia Forum Administrator #2
First on a point of spelling, it's "plugin" not "pluggin". It will help in future searches.

Semper said:

1. To get the targetting pluggin to work with aliases, how do I get a client alias to reference itself to the targetting pluggin ?


If a client alias does "send to execute" then a plugin will detect it. That is because the "execute" target goes through command evaluation again.

Semper said:

2. To get the targetting pluggin to work with aliases, should I ? and if yes, how do I add the alias for a command directly to the targetting pluggin ?


I didn't quite get the first part of the question. To add aliases either copy and paste the general idea in the plugin, and make modifications, or do this:

  • Make an alias in the GUI interface (a client alias)
  • Hit the "Copy" button in the alias list (this copies the alias XML to the clipboard)
  • Remove the alias from the client GUI list
  • In the plugin, near the other aliases, paste the XML you just copied


Semper said:

3. Is it possible to allow 2 aliases to follow each other ? e.g. al z channel 'hail' and al 1 xyz so I can type z 1 and it reads channel 'hail' xyz ?


I think what you want in this case is for the "1" to be a variable, so the hail alias could look up 1 in the variable list.


Semper said:

4. when I add a command to the list of commands the targetter pluggin reads, if I set k (short for kill, k is inbuilt into the mud, and not a personalised in mud/client alias) to the list, then set target deer. I can type k and it engages the deer. The problem is, unlike with aliases, the pluggin overides commands. [the aliases override the pluggin, ] E.G. I still have k in the targetter command list, then I type knock oakdoor. Since there is K in it, or starts with K, it will read the K command instead, and automatically target t1. So knock oakdoor becomes k t1. How can I fix this ? or is it better to bypass it and find one of the other solutions ?


I don't see a "k" alias in what you posted, but what you want is an exact match, not k<something>.

So if you do not use regular expressions, just match on "k". If you want to use regular expressions (I don't know why you would in this particular case) you would match on "^k$".
#3
Thank you for the swift reply.

I didn't quite grasp how to do all the things you said above, but it makes some sense, so I will study it.

As for the last question, in the pluggin I had copied, I had said I removed the k from the command list. the list with |channel 'hail'|kill|k.

I mean I tested it with k in it, and it works, since k corresponds to the alias kill, which is inbuilt into the mud. but since it overrides the command knock, when I type knock oakdoor, unless I set an alias al xx knock oakdoor, I removed it from the command list, trying to look for a different solution.


on point 3, doesn't it come down to the same thing as putting in 2 aliases one after another ? it doesn't work in the mud, but in point 1 you suggested a hint at sending the commands to and "execute" command, which encompasses both aliases instead of 1 following the other. When I said I would study it, this is what I would try to figure out, unless I misunderstood.

Thank you again Nick Gammon, I really appreciate this.

Semper
Australia Forum Administrator #4
Quote:

As for the last question, in the pluggin I had copied, I had said I removed the k from the command list. the list with |channel 'hail'|kill|k.


Oh I see. In your alias you have:


match="^(channel 'hail'|stab|...|charge|kill)"


This matches starting with the above, so it would match, for example, "killer" or "charger".

To match that exact word, put a $ at the end, like this:


match="^(channel 'hail'|stab|...|charge|kill)$"


Or if you don't want to do that, do a "word boundary" assertion, like this:


match="^(channel 'hail'|stab|...|charge|kill)\b"


That checks that what you matched ends on a word boundary, and isn't part-way through a word.
Amended on Sat 05 Mar 2011 01:03 AM by Nick Gammon
#5
Awsome, thank you Nick :D

That solves part of the problem and lets me spam k 'target' with the targetter.

Now I have to be able to set a client or an ingame alias for the commands like channel 'ice spikes' or channel hail.

I can try to put it in the plugin, but I like to put it in ingame alias, since I often delete those aliases and replace them with similar commands, when I repractice.

e.g. channel 'ice spikes' would become channel 'fireball' on the same alias. and I could erase the backstab alias I use in game on one character (b) and put in bash (b) that I don't have in the command list and use for another character.

I can use client alias, but it is a tiny bit longer to change and affects all my characters, where as in game alias is for one character.

The plugin affects all characters. So putting the alias directly into it isn't so good an idea. Especially since you have to close the client and start up again for it to register changes.

Under your quote of 3. you said I want the target to be variable. that is the targetting script.


Now the problem is typing out the whole command.
Quote:

Semper said:

1. To get the targetting pluggin to work with aliases, how do I get a client alias to reference itself to the targetting pluggin ?

Nick Gammon said:

If a client alias does "send to execute" then a plugin will detect it. That is because the "execute" target goes through command evaluation again.


Except when I set a game or client alias to do something, it executes the aliased command. e.g. al z channel 'flame strike'
then command channel 'flame strike' is in the plugin's command list. Except it doesn't pick it up. I get back a message: Hit who ? Or That person isn't there. (I forget the exact answer I get in this case, along those lines though)

So it doesn't pick it up.

I understood it should pick it up, but my mud doesn't.

The solution would be to put the alias both directly into the Plugin and the client alias list. Except for practicality, that isn't an answer, though it is possible.


I may be missing something.
#6
For the note:

the exact $ stops the command at the space, so it allows me to then still set target t1 = deer, and type 1 to k deer. and at without setting a target type k oak without the command changing.

the \b doesn't count the space.

Tahnk you again for helping me solve that first major problem Nick :) *smiles*

Australia Forum Administrator #7
Semper said:

The plugin affects all characters. So putting the alias directly into it isn't so good an idea. Especially since you have to close the client and start up again for it to register changes.


Well, no. For one thing you can just "reload the plugin". No need to close the client, I rarely do that.

For another thing, things that you want in a plugin, but be different for different characters, are what plugin variables are for, because it saves those per world (character).

So, for example, if you have an alias that sets a target variable, and then save the world, that plugin's variable gets saved in its own file, which is different for every world (as long as you enabled "save state").