[MudWalker] MudWalker triggers

Ryan circlethetree at gmail.com
Wed Aug 26 09:13:09 PDT 2009


So from the message board I sort of put together all the posts that helped
me learn alittle bit about making triggers.... here they are...


"Write the trigger as:

   Match:
     ^\S+ attacks (.*)$

   Script:
     use strike to injure at $$arg[1]


Explanation:

The ^ and $ indicate that what is between them must be the entire line.

\S+ matches one or more characters which are not space - that is, a
single word.

.* matches any text.

(.*) puts that text in arg[1]. Further parentheses go into arg[2], etc.


-------------"

and....
I know this may sound like a really simple question, but I cant for
> the life of me figure out how to do this.  I want to have a trigger,
> be able to extract text from that trigger, and use it on the commnad.
>
> Example:
> Input:
> [name] has arrived.
> Output:
> say Hi [name], how are you?
>
>
> Obviously thats not what I would be doing with it, but if I had that
> much I can figure out the rest on my own.

Quick answer:

In the settings dialog, triggers group, input pane:
^(\w+) has arrived\.$

Output pane (Lua):
message( "greeting trigger fired -- remove this line if you like" )
send( "Hi " .. arg[1] .. ", how are you?" )


More detailed answer:

On the input pane, type:
^(\w+) has arrived\.$

Mudwalker uses perl-compatible regular expressions (pcre) for its input
pattern patching.  See here for more information:
http://www.perldoc.com/perl5.8.0/pod/perlre.html

Here's a basic explanation:
^ and $ anchor tags.  They mean to anchor the pattern against the start
and end of the input.
\w+ means one or more word characters.
The parens mean to extract the input matched by the pattern inside and
put it in a special arg[n] variable.  The text matched by the first
paren group goes into arg[1], the second into arg[2], etc.

So \w+ matches the name and the parens extract the name to the lua
arg[1] variable.

On the output pane, you should be using Lua or Lua (in substitution).

Lua:
message( "greeting trigger fired -- remove this line if you like" )
send( "Hi " .. arg[1] .. ", how are you?" )

Lua (in substitution):
@@message( "greeting trigger fired -- remove this line if you like" )
Hi $(arg[1])$, how are you?


This sends a message to the MudWalker window (not the MUD!) that the
trigger has been fired, and then sends the response string to the mud.
In the Lua mode, the '..' operator joins two strings together (such as
"Hi " and the matched name from the input) into one string.  In the Lua
substitution mode, we use the $(arg[1])$ to substitute in a lua
variable to the text stream sent to the MUD.

Note: The particular input pattern used above won't recognize names
with more than one word, or names with punctuation in them.  Consider
it an exercise for the reader.
-- 
Michael Beatty
----------------------------------------------------------
and.......
------------------------------------
Alias Name: Set Target
Command: target
Script:
@@target=arg[1]
@@message("You have targeted " .. target .. ".  Have a nice day!")

The @@ tells MudWalker that this line is written entirely in Lua, and
the text is not to be sent literally to the MUD server.
arg[1], arg[2], arg[3], and so forth are additional arguments that you
can add to the script directly from the prompt.  For example, if you
wanted to target a werewolf, you would type TARGET WEREWOLF into your
prompt.  After that, for every instance that arg[1] appears in the
script, it would be replaced by the text "werewolf".
target=arg[1] sets a global variable named "target" to whatever
argument you added in for arg[1].  A global variable is a variable that
remains constant until you quit MudWalker or change the variable,
whichever comes first.
message("whatever") causes text to appear on your screen.  It doesn't
do it for anyone else, just you.  This could be reminder text,
confirmation text, etc.  If you have a variable that you wish to
include in your text, close the quote, add two periods, the variable
name, then two more periods, then open the quote again.

Alias Name: Punch Target
Command: pt
Script:
punch $(target)$

Very simple script:  It calls upon the variable "target" that you set
using the above script and sends the command to punch that target to
the server.  The only thing of note is that you can use Lua commands
inside a line that does not start with @@ by enclosing them in dollar
signs and parentheses $(like this.)$  Doing this will cause the Lua
commands to execute, then place whatever results they return into the
place where the commands were in the text.

Alias Name: Crystalism-Tremors Vibration
Command: tremors
Script:
outr egg
outr disc
spin egg
spin disc
embed tremors

You don't have to use any Lua code at all, if you don't want it.
Aliases can be used simply for automating tedious tasks.  Or, if you
want, you could set a longer command to be executed by one or two
letters, for instance, touching a shield tattoo, which generates a
handy, protective magical shield, would ordinarily be "touch shield",
which might be tough to type in combat, but "ts" would be very easy to
type.

Now, on to some triggers.

Trigger Name: Follow Detector
Match Patterns: ^(.*) begins to follow you.
Make command link: Yes
Command Link command: lose $(arg[1])$
Substitute text: Yes
Substitute text text: $(arg[1])$ begins to follow you.  Click here to
give 'em the boot.
Script: None

This is a deceptively complicated script, but it shows you just how
powerful the MudWalker trigger engine is.  When someone starts
following you, this script will change the "Whomever begins to follow
you." into "Whomever begins to follow you.  Click here to give 'em the
boot." and make it into a clickable link that will lose whomever
started to follow you.
^(*.) is used whenever you want MudWalker to recognize one word of text
in a line sent to you and use it in a script.  arg[1], arg[2], etc.
will recognize each ^(*.) and use it in a command.


And now for my awe-inspiring power-up script...
Alias Name: Start Powering Up
Command: Powerup
Script:
@@ message("Beginning powerup sequence.")
channel earth
@@ powerup=1
@@ message("Channels 25% open.")

Trigger Name: Continue Powerup Sequence
Match Patterns: You have recovered equilibrium.
Script:
@@ if powerup==1 then
    channel fire
@@    powerup=2
@@ message("Channels 50% open.")
@@ elseif powerup==2 then
    channel water
@@    powerup=3
@@ message("Channels 75% open.")
@@ elseif powerup==3 then
    channel air
@@    powerup=4
@@ message("Channels 100% open.  Now casting defensive spells.")
@@ elseif powerup==4 then
    cast stoneskin
@@    powerup=5
@@ message("Stoneskin armor cast.")
@@ elseif powerup==5 then
    cast reflection at me
@@    powerup=6
@@ message("Reflection cast.")
@@ elseif powerup==6 then
    cast chargeshield at me
@@    powerup=7
@@ message("Electric dispersal shield cast.")
@@ elseif powerup==7 then
@@    powerup=0
@@ message("Startup sequence complete. You are at full combat
readiness.")
@@ end

Big, complicated script.  The alias sets it all in motion, and the
trigger continues it until you finish powering up.  In the MUD I play,
equilibrium is temporarily lost when you cast a spell, although you
automatically regain it after a brief duration.
You can have MudWalker test existing conditions by using the
if/elseif/else/end command.  YOU MUST USE TWO EQUALS SIGNS INSTEAD OF
ONE WHEN TESTING VARIABLES!  Otherwise, the if statement would set the
variable to whatever it was looking for instead of testing to see if
the variable is what you were looking for.

Hm, I think that's about it.  If you have any questions or anything,
don't hesitate to send me a reply.

--------------------------------------------

Those are the best ones....
-Ryan



On Wed, Aug 26, 2009 at 8:52 AM, Taylor Telford <
Taylor.Telford at grandview.edu> wrote:

>  I've set up some very easy triggers on mudwalker dealing with a situation
> happening and doing something but nothing with variables or whatnot.
>
> I play medievia and would really like to figure out how to do triggers for
> mudwalker for situations.
>
> There's lots of spells to cast in med but sometimes you fumble the spell
> and don't cast it and my current dilemma is creating a trigger with a common
> start line but a different spell ending.
>
> The screen looks like this:
>
> You fumble over the correct inflection to cast Refresh.
>
> All spell fumbles start with the You until the cast and after it just says
> the spell name.  Sometimes it s a two word spell like "Sense Life".
>
> I want on the script line to:
>
> c Refresh
>
> Or whatever other spell it is.
>
> This is just one general problem..I'd really like to know how to do as much
> as possible with triggering and making my own triggers and scripts.
>
>
> _______________________________________________
> MudWalker mailing list
> MudWalker at cubik.org
> http://lists.puremagic.com/cgi-bin/mailman/listinfo/mudwalker
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/mudwalker/attachments/20090826/e0c15166/attachment.htm>


More information about the MudWalker mailing list