Thought I'd make a thread for quick coding question!
My Questions: I'm trying to make a alias for throwing phials looking something like this ^en (n|s|e|w|ne|nw|se|sw|u|d|in|out)$ or ^en something that matches those or nothing at all$
in order to execute a script that if matches[2] == nil(is that the right thing to put?) then it throws at the ground else it throw it in whatever direction.
How do I get the alias to match the direction or nothing at all?
0
Comments
(?:stuff)? matches 0 or 1 "stuff" and the ?: prevents it from being captured.
send("throw endorphin at " .. (matches[2] or "ground"))
I think. Going by what @Klendathu said.
send("throw endorphin " .. (matches[2] or "at ground"))
It gets thwarted, however, when this happens (my prompt getting in the way and being on the same line):
So how can I fix this/make a working trigger?
It should be pretty clear, btw, that my knowledge of coding, triggers and aliases is rudimentary at best.
@Asphel
http://www.mudlet.org/download/
Here is a possible way to set it up so you do not have to work around the prompt:
Give that a whirl!
You can make the (.*) part more specific once you know that much works.
P.S. if you enjoy MushClient stick with it
If you wanted to try this It would be under Game > Configure > Output and it should be the last check box on the right of that dialog window.
Might change how things are currently setup though for @Asphel.
I'm trying to build on @Taurnil's very helpful humour tracker, using lines from EVALUATE HUMOURS as an update to target humour levels, within a multi-line trigger.
Currently, I have:
As a multiline/AND Trigger, line delta 1, and
As the result (where melcount etc. are the variables for each individual humour level).
The trigger fires okay, but it doesn't appear as though (\w+) is being captured as matches[2] - I've tried adding
to the beginning of the response, and it's not giving any output.
This is the easy trigger, as well. My follow-up question is how I go about creating a trigger that will match:
Where each the last four lines will only appear if that humour has been tempered, but will always occur in that order. I haven't tried this one yet - I'm hoping I don't need to create four different triggers for it (each with a different humour line and line delta), because that seems inefficient, but that's the only way I can think of doing it currently.
ETA: I should probably specify the client: Mudlet. It might be obvious from the fact that I'm (failing at) using lua, but I'm not sure whether there's another client that also uses it.
ETA(again): I know that \w+ is a very lazy way to match his/her - I'm currently working on basics, though.
Results of disembowel testing | Knight limb counter | GMCP AB files
Then you can either change it to a table and do
or keep it as-is and do
EDIT: This won't clear a humour that reaches 0 and is no longer listed, so you'll need something for that. Maybe a separate trigger on the Looking over X line that runs first and clears them all?
If you wanted to capture that prompt, you could write:
^(?:\d+h, \d+m \w*-)?You pull a green leaf from the bush\.$
My bad with the parenthesis, just is something I pull from Mudlet. I Learned something new with that.
As I stated in my original post, they could get more specific once they know the first part works.
When they stated coding experience is rudimentary at best, I was going with the broad strokes and then you work at getting more specific, at least that is how I have always seen it to learn. To each their own though.
So \d+h matches "one or more (the +) numbers (the \d) and then the letter h". But let's say you wanted to make a trigger to see if that number was lower than 80% of your max health so you could sip health whenever that happened - you need some way to reference the number in your script - that's where the parentheses come in. So instead of \d+h you do (\d+)h which means "one or more numbers, and save that part, then the letter h". And then your client has some way to reference the "capture group" - in mudlet this is matches[2] (matches[1] is always the entire matching line) and in the HTML5 client this is args[1] - I don't know what it is in MushClient.
As for the rudimentary regex with the .* at the beginning, what I was trying to get across is that it actually won't work if you have enough of those triggers and/or you're on a slow computer. If the prompt can show up before any line, you would presumably be putting that in every trigger and with enough of them, you'd start seeing lag from your scripts. In most cases, you're fine to use something less-specific and stick a .* in, but a .* at the beginning of a regex is a special case that's particularly bad for performance thanks to the way regex engines work.
That's assuming it's in the script for the trigger itself. If you're using the automatically-call-a-function part of the trigger box it's a little different, and I suggest anyone doing so check out the (quite useful!) documentation here.
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.
Ohai gais. Okay I've got these two scripts. First one is for a small miniconsole to which I echo most things I need to pay attention to. I'm not too good at catching scrolling text anymore, but a box near my commandline is great for making me take notice of things. What it does is it actually pushes my display output a few pixels upwards to make space for a the miniconsole (AKA 'alerts') below. It also makes use of the sysWindowResizeEvent Event handler.
The second is the code for repositioning SVO's single command prompt to accomodate the 'alerts' box:
Ordinarily both codes work perfectly fine on their own. Both the 'alerts' box and repositioned single prompt are sitting where they should when I start mudlet. But for some weird reason, the display settings (as configured by setBorderBottom/Left) refuse to be processed unless I go to my scripts and save 'alerts'. That's all I need to do. It's not exactly a hassle or anything, I'm just wondering why it keeps doing that.
WindowWidth, WindowHeight = getMainWindowSize();
GMCP documentation: https://github.com/keneanung/GMCPAdditions
svof github site: https://github.com/svof/svof and documentation at https://svof.github.io/svof
I have a trigger for dstab to be used for affliction tracking: two venom lines and then the dstab line.
If it rebounds, then it shouldn't process the venoms. But if instead of rebounding if I get the prompt back it means that there was no rebounding and I should process the venoms
I've uploaded a few screenshots to display how I've set up the trigger, and the end result:
https://imgur.com/a/8Ur2X
This almost works perfectly except that it gets fired twice. Anyone know how to fix this?
If that makes no sense, I can post mine up tonight to show you. I added a little blue dot echo to the end of the trigger so I know it isn't staying open. Using this method, you can even add in checks to make sure you actually sent the attack, as an illusion fail safe.
Edit: if you use serverside alias, and include illusion, the illusion line will fire before the prompt, so you might want to add that into your prompt trigger as well. It looks like you are just leaving your trigger open too long, though. . I dunno, someone surely has a better method. I just needed dsl, rend, dstab, and single stabs to all work off one trigger.
as intended, but it will also be satisfied by just
In the second case, multimatches[1] and multimatches[2] should both be {"You rub some kalmia on a needle-pointed dirk.","kalmia"}, so I would expect it to run once and set your tracking variable to {"curare","kalmia"}, then a second time and set it to {"kalmia","kalmia"}, or maybe vice versa (not sure what order they'll be processed in). It looks from your prompt like they might actually be getting set to {"curare","curare"}, which I don't understand, but there might be something else weird going on.
In any case, if you add an extra pattern in between the two venom patterns, with type "line spacer", it will force the venom patterns to match on separate lines, which, if I'm correct, should solve the problem with it firing twice. You'll then want multimatches[3][2] for the second venom.
And thank you Austere too!
Sorry again, Kross.
You need to make a function that runs on the GMCP Room.Info event - this is pretty easy to do in Mudlet. Have a look at the Triggering on GMCP section here: http://www.mudlet.org/wp-content/uploads/2013/02/GMCPtutorial.pdf
Your event function will look something like this.
That will save your last room and your current room. If you want to do something when you change rooms, just put the function calls for whatever you want to do under currentRoom = gmcp.Room.Info.num, inside that if block.