Hello, I'm new to Achea, and I'm using the default flash client that the game offers (seems the least complicated for my newbie mind). Recently I've been trying to set up some basic reflexes such as automatically opening doors during travel, as well as some basic reflexes for defense, but have been having great difficulty so far. In filling out the "New Trigger" tab in Achaea's client I run into problems when I reach the "custom script" line. Since I know nothing about scripting, naturally I don't know what to enter.
Can someone please help me to set up some basic stuff like:
1. Automatically standing up when you wake.
2. Automatically opening doors on your way.
3. Any one defensive reflex, so I have an example of script to modify for other afflictions.
Thank you very much in advance.
0
Comments
We're working on developing a helpful package of triggers for people using the default client, but it's still very much in-development.
A basic defensive reflex (to cure paralysis) though would work like this in the client:
Command to stand is just STAND not 'stand up'.
HELP BASIC COMMANDS is a good place to start to make sure you're inputting the correct bits![:) :)](https://forums.achaea.com/resources/emoji/smile.png)
The trigger you've made looks correct, so the only other thing I can see to check is that it's actually enabled. In the Triggers tab in the Client Settings, click on the trigger group (GENERAL in your case) and make sure the On? checkbox next to that trigger is checked. Then in the main client window (the one you actually play the game in), click on the Triggers tab in the top-right corner and ensure that the GENERAL group as a whole is enabled (the checkbox is checked).
Only one other comment regarding that trigger: There are two lines for waking up. The first one - "You open your eyes and yawn mightily." - you'll see most of the time. There's a second one that you'll see when you wake up if you're at maximum health and endurance (I think, may be wrong on this); the line for that is "You open your eyes and stretch languidly, feeling deliciously well-rested."
You can make that one trigger handle both of those cases, just change the Match Criteria value to:
^You open your eyes and yawn mightily\.$|^You open your eyes and stretch languidly, feeling deliciously well-rested\.$
Some notes on that since it may be a little confusing:
The ^ means "beginning of line" so the trigger won't fire if you saw that text but it wasn't at the beginning of the line.
The $ means "end of line" so the trigger won't fire if there's any text on that line after that message.
That general process above is called "anchoring".
The \. means that it's literally a full stop/period. In regular expressions the dot character has a special meaning (it matches anything), but we don't want anything - we want an actual dot - so we need to escape it (that's what the \ does).
The | (pipe) is essentially an OR, and can be used to separate entire messages or parts of messages. In this case, we have two separate patterns, so we split them with the pipe - if the text received from the game matches either of them the regular expression will match and the commands will be sent.
Okay, since we've covered all of that, let's move on to creating a trigger for opening a door if there's one in your way. If you were to try to move south, but there was a door blocking you, you'd see this line: There is a door in the way, to the south.
That's pretty straight forward, but that last word will be different depending on which direction you're trying to move. You could create separate triggers, one for each direction, and send the relevant commands, but there's a way to do it with a single trigger using what's called a capture group. The pattern would look like this:
^There is a door in the way, to the (\w+)\.$
Again I've anchored to the beginning and end of the line using ^ and $, respectively, and also escaped the dot so that it's only matching an actual period. The only new thing is the (\w+) in place of the direction. That's the capture group, but what does that mean? A capture group is a dynamic part of the message (a direction, in this case) that you want to store (capture) to do something with (use as part of the command to send to Achaea, in this case).
The brackets, ( and ), denote the capture group. Again these are special characters in regular expressions; if you wanted an actual ( or ) you'd have to use \( or \).
The \w inside the brackets means "an alphanumeric character" (a to z, A to Z, 0 to 9). The + applies to the \w and means "one or more" (that's -another- special character, there are quite a few of them). So, tying all that together, the (\w+) means match one or more alphanumeric characters and store that portion of the text for use later.
We have our pattern, but now we need to send the command to the game. Since we have a dynamic aspect to it (the direction the door is in, stored in our capture group) we're going to ignore the Send to MUD: box and instead use the Custom Script: one. There's a built-in function called send_direct in the HTML5 client that can be used in that box to send a command to the game. In our case we want to send "open door <direction>", where <direction> is the value of our capture group, so we'd do:
send_direct("open door " + args[1])
Just in case that doesn't make any sense to you, we're creating the command to send from two parts: the static "open door " part (the double quotes denote a string literal) and the dynamic args[1] part. The + operator when working with strings in JavaScript means string concatenation (joining the two parts together). The args[1] part contains the value of the capture group in our pattern, so is the direction in which you want to open the door.
That's probably enough explanation for now, and should hopefully be enough to get you started. If you have any questions feel free to post them, and I or somebody else will probably be able to help you with them.
Results of disembowel testing | Knight limb counter | GMCP AB files
Many thanks for taking a big chunk of your time and explaining this in such detail. Info in the "for dummies" format is invaluable for the likes of me-- you explain very clearly.
With that said, in the "stand" trigger all the boxes you mentioned were checked before, but it started working only after I anchored it like you said and excluded the dot with an \. Still not sure why this helped. As I understand, it should have worked without doing so, right? Also not quite sure, do I need to "escape" other signs such as "!" or "?" as well? The door trigger worked well.
For now I only have two questions/problems:
1. Do I need to worry about any format issues for the commands I enter into the "send to Mud" box other than the "pipe" symbol to separate them?
2. For some reason, I can't get the client to highlight the "match". I put down the foreground/background colors correctly, and check the box, but the matched text does not highlight. Althouh the trigger itself now works perfectly.
Any ideas?
2. I think it says that gagging and highlighting are experimental right now, so they may not actually work at all.
Might be worth asking about gagging and highlighting in the HTML5 Client questions thread: http://forums.achaea.com/discussion/65/html5-client-questions-and-such
Results of disembowel testing | Knight limb counter | GMCP AB files
Yes for ?, you shouldn't need to for !. However, escaping a character that isn't a special character shouldn't make a difference: \! and ! should both work identically. I know some people who escape all punctuation characters just to be safe.
A couple of useful links:
Regular expression cheatsheet
MDN entry for JavaScript's RegExp object
Worth noting that JavaScript doesn't have a full regex implementation. It doesn't support lookbehind assertions, but does support lookahead. I can't imagine that being an issue for you, though.
Results of disembowel testing | Knight limb counter | GMCP AB files
@Qahnaarin, if you messaged Cidusii he might be able to help you.
He's a pretty busy fella but there might be a chance he's look over what you're inputting and tell you where the error is. He's gotten pretty good manipulating that client.