<font size="4">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...</font><br><br><br>"Write the trigger as:<br><br> Match:<br> ^\S+ attacks (.*)$<br>
<br> Script:<br> use strike to injure at $$arg[1]<br><br><br>Explanation:<br><br>The ^ and $ indicate that what is between them must be the entire line.<br><br>\S+ matches one or more characters which are not space - that is, a <br>
single word.<br><br>.* matches any text.<br><br>(.*) puts that text in arg[1]. Further parentheses go into arg[2], etc.<br><br><br>-------------"<br><br>and....<br>I know this may sound like a really simple question, but I cant for<br>
> the life of me figure out how to do this. I want to have a trigger,<br>> be able to extract text from that trigger, and use it on the commnad.<br>><br>> Example:<br>> Input:<br>> [name] has arrived.<br>
> Output:<br>> say Hi [name], how are you?<br>><br>><br>> Obviously thats not what I would be doing with it, but if I had that<br>> much I can figure out the rest on my own.<br><br>Quick answer:<br><br>
In the settings dialog, triggers group, input pane:<br>
^(\w+) has arrived\.$<br><br>Output pane (Lua):<br>message( "greeting trigger fired -- remove this line if you like" )<br>send( "Hi " .. arg[1] .. ", how are you?" )<br><br><br>More detailed answer:<br>
<br>On the input pane, type:<br>^(\w+) has arrived\.$<br><br>Mudwalker uses perl-compatible regular expressions (pcre) for its input <br>pattern patching. See here for more information:<br><a href="http://www.perldoc.com/perl5.8.0/pod/perlre.html">http://www.perldoc.com/perl5.8.0/pod/perlre.html</a><br>
<br>Here's a basic explanation:<br>^ and $ anchor tags. They mean to anchor the pattern against the start <br>and end of the input.<br>\w+ means one or more word characters.<br>The parens mean to extract the input matched by the pattern inside and <br>
put it in a special arg[n] variable. The text matched by the first <br>paren group goes into arg[1], the second into arg[2], etc.<br><br>So \w+ matches the name and the parens extract the name to the lua <br>arg[1] variable.<br>
<br>On the output pane, you should be using Lua or Lua (in substitution).<br><br>Lua:<br>message( "greeting trigger fired -- remove this line if you like" )<br>send( "Hi " .. arg[1] .. ", how are you?" )<br>
<br>Lua (in substitution):<br>@@message( "greeting trigger fired -- remove this line if you like" )<br>Hi $(arg[1])$, how are you?<br><br><br>This sends a message to the MudWalker window (not the MUD!) that the <br>
trigger has been fired, and then sends the response string to the mud. <br>In the Lua mode, the '..' operator joins two strings together (such as <br>"Hi " and the matched name from the input) into one string. In the Lua <br>
substitution mode, we use the $(arg[1])$ to substitute in a lua <br>variable to the text stream sent to the MUD.<br><br>Note: The particular input pattern used above won't recognize names <br>with more than one word, or names with punctuation in them. Consider <br>
it an exercise for the reader.<br>-- <br>Michael Beatty <br>----------------------------------------------------------<br>and.......<br>------------------------------------<br>Alias Name: Set Target<br>Command: target<br>
Script:<br>@@target=arg[1]<br>@@message("You have targeted " .. target .. ". Have a nice day!")<br><br>The @@ tells MudWalker that this line is written entirely in Lua, and <br>the text is not to be sent literally to the MUD server.<br>
arg[1], arg[2], arg[3], and so forth are additional arguments that you <br>can add to the script directly from the prompt. For example, if you <br>wanted to target a werewolf, you would type TARGET WEREWOLF into your <br>
prompt. After that, for every instance that arg[1] appears in the <br>script, it would be replaced by the text "werewolf".<br>target=arg[1] sets a global variable named "target" to whatever <br>argument you added in for arg[1]. A global variable is a variable that <br>
remains constant until you quit MudWalker or change the variable, <br>whichever comes first.<br>message("whatever") causes text to appear on your screen. It doesn't <br>do it for anyone else, just you. This could be reminder text, <br>
confirmation text, etc. If you have a variable that you wish to <br>include in your text, close the quote, add two periods, the variable <br>name, then two more periods, then open the quote again.<br><br>Alias Name: Punch Target<br>
Command: pt<br>Script:<br>punch $(target)$<br><br>Very simple script: It calls upon the variable "target" that you set <br>using the above script and sends the command to punch that target to <br>the server. The only thing of note is that you can use Lua commands <br>
inside a line that does not start with @@ by enclosing them in dollar <br>signs and parentheses $(like this.)$ Doing this will cause the Lua <br>commands to execute, then place whatever results they return into the <br>
place where the commands were in the text.<br>
<br>Alias Name: Crystalism-Tremors Vibration<br>Command: tremors<br>Script:<br>outr egg<br>outr disc<br>spin egg<br>spin disc<br>embed tremors<br><br>You don't have to use any Lua code at all, if you don't want it. <br>
Aliases can be used simply for automating tedious tasks. Or, if you <br>want, you could set a longer command to be executed by one or two <br>letters, for instance, touching a shield tattoo, which generates a <br>handy, protective magical shield, would ordinarily be "touch shield", <br>
which might be tough to type in combat, but "ts" would be very easy to <br>type.<br><br>Now, on to some triggers.<br><br>Trigger Name: Follow Detector<br>Match Patterns: ^(.*) begins to follow you.<br>Make command link: Yes<br>
Command Link command: lose $(arg[1])$<br>Substitute text: Yes<br>Substitute text text: $(arg[1])$ begins to follow you. Click here to <br>give 'em the boot.<br>Script: None<br><br>This is a deceptively complicated script, but it shows you just how <br>
powerful the MudWalker trigger engine is. When someone starts <br>following you, this script will change the "Whomever begins to follow <br>you." into "Whomever begins to follow you. Click here to give 'em the <br>
boot." and make it into a clickable link that will lose whomever <br>started to follow you.<br>^(*.) is used whenever you want MudWalker to recognize one word of text <br>in a line sent to you and use it in a script. arg[1], arg[2], etc. <br>
will recognize each ^(*.) and use it in a command.<br><br><br>And now for my awe-inspiring power-up script...<br>Alias Name: Start Powering Up<br>Command: Powerup<br>Script:<br>@@ message("Beginning powerup sequence.")<br>
channel earth<br>@@ powerup=1<br>@@ message("Channels 25% open.")<br><br>Trigger Name: Continue Powerup Sequence<br>Match Patterns: You have recovered equilibrium.<br>Script:<br>@@ if powerup==1 then<br> channel fire<br>
@@ powerup=2<br>@@ message("Channels 50% open.")<br>@@ elseif powerup==2 then<br> channel water<br>@@ powerup=3<br>@@ message("Channels 75% open.")<br>@@ elseif powerup==3 then<br> channel air<br>
@@ powerup=4<br>@@ message("Channels 100% open. Now casting defensive spells.")<br>@@ elseif powerup==4 then<br> cast stoneskin<br>@@ powerup=5<br>@@ message("Stoneskin armor cast.")<br>@@ elseif powerup==5 then<br>
cast reflection at me<br>@@ powerup=6<br>@@ message("Reflection cast.")<br>@@ elseif powerup==6 then<br> cast chargeshield at me<br>@@ powerup=7<br>@@ message("Electric dispersal shield cast.")<br>
@@ elseif powerup==7 then<br>@@ powerup=0<br>@@ message("Startup sequence complete. You are at full combat <br>readiness.")<br>@@ end<br><br>Big, complicated script. The alias sets it all in motion, and the <br>
trigger continues it until you finish powering up. In the MUD I play, <br>equilibrium is temporarily lost when you cast a spell, although you <br>automatically regain it after a brief duration.<br>You can have MudWalker test existing conditions by using the <br>
if/elseif/else/end command. YOU MUST USE TWO EQUALS SIGNS INSTEAD OF <br>ONE WHEN TESTING VARIABLES! Otherwise, the if statement would set the <br>variable to whatever it was looking for instead of testing to see if <br>
the variable is what you were looking for.<br><br>Hm, I think that's about it. If you have any questions or anything, <br>don't hesitate to send me a reply.<br><br>--------------------------------------------<br>
<br><font size="4">Those are the best ones....<br>-Ryan</font><br><br><br><br><div class="gmail_quote">On Wed, Aug 26, 2009 at 8:52 AM, Taylor Telford <span dir="ltr"><<a href="mailto:Taylor.Telford@grandview.edu">Taylor.Telford@grandview.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div>
<p><font size="2">I've set up some very easy triggers on mudwalker dealing with a situation happening and doing something but nothing with variables or whatnot.<br>
<br>
I play medievia and would really like to figure out how to do triggers for mudwalker for situations.<br>
<br>
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.<br>
<br>
The screen looks like this:<br>
<br>
You fumble over the correct inflection to cast Refresh.<br>
<br>
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".<br>
<br>
I want on the script line to:<br>
<br>
c Refresh<br>
<br>
Or whatever other spell it is.<br>
<br>
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.<br>
<br>
</font>
</p>
</div>
<br>_______________________________________________<br>
MudWalker mailing list<br>
<a href="mailto:MudWalker@cubik.org">MudWalker@cubik.org</a><br>
<a href="http://lists.puremagic.com/cgi-bin/mailman/listinfo/mudwalker" target="_blank">http://lists.puremagic.com/cgi-bin/mailman/listinfo/mudwalker</a><br>
<br></blockquote></div><br>