Not sure if it's actually a problem or not, but your match for the direction will also include the period at the end of the sentence, so if you do get the line "There is a door in the way, to the east.", your matches[2] will be "east." and you'll send "open door east.". I don't know if a period at the end of that command will make a difference or not. If so, you can change your pattern to
^There is a door in the way, to the (\w+)\.$
The important bit there is the \. at the end, which matches the period explicitly so that it's not contained in the capture. Changing the .+ to \w+ just makes it a little more specific (\w matches letters, numbers, and underscores, no spaces or other special characters), which is generally considered good practice, but won't actually affect your pattern matching in this case.
In general, good first steps for debugging this sort of thing are to
1) Make sure that the trigger is enabled, and that the pattern is set to the correct type (perl regex, in this case)
2) Add a highlight (with the highlight checkbox) or an echo at the beginning of the script to verify that the trigger is actually firing - if not, the pattern most likely isn't matching, so look for typos, or things like extra spaces at the beginning or end
3) Check the error window in the script editor and see if the script is giving you any errors that might point to a problem. In this particular case, that's unlikely, since the script is so simple, but it's a good place to look in general.
4) If you don't have it set normally, click Settings, go to the Input Line tab, and turn on the "show text you sent" option. That'll let you see what you're sending to the game, and see if that's somehow coming out incorrectly. You can always turn it off again when you're done debugging, if you don't like it.
A couple other small general tips:
a) If you're declaring a variable in a trigger/alias/script that's only going to be used within that script, it's usually a good idea to declare it as local, so that you don't have to worry about name conflicts if you use the same variable name elsewhere. Again, not going to fix your problem here, but good practice in general.
b) You don't actually need to declare an intermediate variable here. You can just use matches[2] directly in the concatenation.
So, for example, you could do
local door_shut = matches[2]
send("open door "..door_shut)
or just
send("open door "..matches[2])
More than you asked for, but I hope some of that's helpful for future debugging, as well. If none of that helps with this particular problem, let us know here and I'm sure others will be happy to chime in with anything I missed.
I do think the period is actually important there, as if it's not stated in the trigger line, the (\w+) will also capture the period, and I'm not very soon if when you type for example "Open door North." it works. could be wrong though!
Aurora says, "Tharvis, why are you always breaking things?!" Artemis says, "You are so high maintenance, Tharvis, gosh." Tecton says, "It's still your fault, Tharvis."
I do think the period is actually important there, as if it's not stated in the trigger line, the (\w+) will also capture the period, and I'm not very soon if when you type for example "Open door North." it works. could be wrong though!
\w won't catch a period. If you made it ^There is a door in the way, to the (\w+)$, it wouldn't match at all.
Aurora says, "Tharvis, why are you always breaking things?!" Artemis says, "You are so high maintenance, Tharvis, gosh." Tecton says, "It's still your fault, Tharvis."
\w only matches non-whitespace alphanumeric characters.
And underscore.
\w is shorthand for [A-Za-z0-9_]
\s for [ \t\f]
\d for [0-9]
capital is reverse
\D is [^0-9] or [^\d]
\W is [^\w]
\S is [^\s]
edit: be careful of doubling up reverses.
[^\d\s] is anything not a number or whitespace
[\D\S] is anything not a number OR not whitespace (which, since they don't overlap and both exclude anything, mean that is the same as a period - everything)
This seems like a good place to pose a Mudlet question! What would the regex be for the following?
Oaken vial165951 a renewal balm 138 120
I'm trying to match it so it captures only 'vialxxxx' 'a renewal balm' '138' and '120'. I want to account for and exclude the spaces, but because the words I want to capture are numerous, if I use (.*) or (.+) it captures the spaces, \s+ doesn't differentiate from (.*) for spaces and so they still get captured if I use \s+ and the only other regex patterns I know are for single words only. It needs to also work for variations such as:
Mostly the same as @Keneanung's, except that it captures just the vial number instead of "Vial1234", and a couple of the other specifiers are slightly more specific (but not in a way that's likely to affect anything here).
and I want to remove "Person2" from the table. Now, this might be the initial state of the table, but soon enough Person2 would be inserted into the end (fourth) position of the table, and Person3 would be moved into the second position of the table and so on, so I can't really predict where in the table everyone is at any point in time (Apart from initialization).
I could only find documentation on removing things from a table based on their position rather than actual value.
If you're sure the entries are going to be unique, you can get the position with table.index_of:
local pos = table.index_of(testTable, "Person3")
table.remove(testTable,pos)
If "Person3" occurs twice, I believe this will just remove the first instance. If there are duplicates, I think something like this should work:
for i=#testTable,1,-1 do
if testTable[i]=="Person3" then table.remove(testTable,i) end
end
The idea there is to iterate in reverse so that you don't miss any instances because of the reindexing that table.remove does. Always makes me a little nervous to change a table I'm iterating over like that, but I think that version's safe. Someone else might have a better idea.
Yeah, use table.index_of to find the position out. You can even chain them if you're confident the value is there: table.remove(testTable, table.index_of(testTable, "myvalue"))
For an experiment with striking, I want to make a table that functions similarly to a last-in-first-out 'stack', where I can push striking attack locations (neck, shoulder, etc), and once I do a slash/strike attack, the first value is popped to serve as the striking attack. When I do the next combo, the next last stacked attack is popped, and so on and so forth.
What's a good way to do that in mudlet? Or is there a better way to do that for BMs?
Adding the value at index 1 will move everything down, so then just calling the first value will be the last entered thing. Removing the value from index 1 using table.remove will move everything up an index so it will be last in first out. I think anyway.
I wouldn't of thought it would be the best way to queue striking though, because you have to think backwards which is an irritation with venoms that you get to avoid being a blademaster, but each to their own.
Hm, actually @Accipiter is somewhat right. I think I was stuck thinking in a venoms-user way. First-in-first-out would be a better approach, but would I have to think about moving all the contents up when I 'pop' a value in a FIFO 'stack'(is it still called a stack in this case, or is there another programmer term for it?), or are there already functions that do that?
Comments
Artemis says, "You are so high maintenance, Tharvis, gosh."
Tecton says, "It's still your fault, Tharvis."
Artemis says, "You are so high maintenance, Tharvis, gosh."
Tecton says, "It's still your fault, Tharvis."
Site: https://github.com/trevize-achaea/scripts/releases
Thread: http://forums.achaea.com/discussion/4064/trevizes-scripts
Latest update: 9/26/2015 better character name handling in GoldTracker, separation of script and settings, addition of gold report and gold distribute aliases.
Second you can make the regex for the second column non-greedy by appending a ? to the quantifier. All in all, your regex could look like this:
GMCP documentation: https://github.com/keneanung/GMCPAdditions
svof github site: https://github.com/svof/svof and documentation at https://svof.github.io/svof
local org1 = matches[2]
local org2 = matches[3]
local org3 = matches[4]
send("readlog " ..org1 ..org2 ..org3)
but it never works
Svof
Mudlet Discord join up
Results of disembowel testing | Knight limb counter | GMCP AB files
Svof
Mudlet Discord join up
Svof
Mudlet Discord join up
He wants last-in-first-out, where the last thing he entered is the first thing he sent out.
ETA: actually, sounds like he wants it to alternate between them or something.