Need Help with Random Output Trigger Variable

Post Reply
Dayosh
Posts: 3
Joined: Mon Aug 25, 2014 9:17 pm

Need Help with Random Output Trigger Variable

Post by Dayosh »

Greetings! I'm quite new to Mudlet, and while I've had some experience with aliases and triggers in the past, I'm afraid I'm not very adept at coding or scripting.

Presently, I was trying to make a trigger which will look for certain server output phrases and will highlight them in a color (purple, for example) so that it will stand out from other white (or other, non-purple-colored) text (it's a fast-paced game with a lot of server output at times, and it can be easy to miss the messages I want to highlight).

So, for example:

Code: Select all

*You think you're *
*You're pretty sure you *
*You're positive you *
*You're fairly certain you *

The difficulty I'm having with these are the asterix symbols(the random output variable). I've used random input/output variables before ( *, $^, $%, etc.), that are usually server-side (built into the game, itself), but I need some symbol like this in Mudlet, which will essentially say "Whatever server output comes before or after doesn't matter, but if you find what's in-between the asterix (or whatever) symbols, highlight the line."

Is there a symbol for this built-in to Mudlet, or would I have to figure out a way to code my own? Any help would be greatly appreciated, and thank you very much in advance! :)

User avatar
Akaya
Posts: 414
Joined: Thu Apr 19, 2012 1:36 am

Re: Need Help with Random Output Trigger Variable

Post by Akaya »

^You think you're (.*)$
^You're pretty sure you (.*)$
^You're positive you (.*)$
^You're fairly certain you (.*)$


^: denotes the beginning of a line
$: denotes the end of a line
(.*): this is called a wildcard and is the 'random output trigger variable' you speak of.

To highlight these lines place this in your script (the big white box):
Code: [show] | [select all] lua
selectString(line,1)
fg("purple")
resetFormat()

User avatar
Belgarath
Posts: 232
Joined: Fri Jul 26, 2013 7:19 am
Discord: macjabeth#7149

Re: Need Help with Random Output Trigger Variable

Post by Belgarath »

You can select and highlight certain bits with easy functions:
Code: [show] | [select all] lua
-- highlights the entire line
selectCurrentLine() fg("purple") resetFormat()

-- highlights the capture group
selectCaptureGroup(2) fg("purple") resetFormat()
Hope that helps!

Dayosh
Posts: 3
Joined: Mon Aug 25, 2014 9:17 pm

Re: Need Help with Random Output Trigger Variable

Post by Dayosh »

Hey, folks! Thanks for the help! After trying to use the commands from Akaya's post, however, I am regrettably met with no success. I've included a screenshot of my trigger window, in hopes someone can point out something I'm missing.

Image

I should probably also take this opportunity to point out that I have very little (if any) experience with coding, and if I can keep things as GUI as possible, it would be awesome. Hope to hear back soon, and thanks so much again in advance to everyone for their help! :D

User avatar
Belgarath
Posts: 232
Joined: Fri Jul 26, 2013 7:19 am
Discord: macjabeth#7149

Re: Need Help with Random Output Trigger Variable

Post by Belgarath »

Heya,

All those trigger types are listed as "substring" - they must be changed to "perl regex" for it to match properly.

Dayosh
Posts: 3
Joined: Mon Aug 25, 2014 9:17 pm

Re: Need Help with Random Output Trigger Variable

Post by Dayosh »

Aye, that seems to have done the job nicely. Thank you both so much for your help! Really appreciate it! :D

User avatar
SlySven
Posts: 1023
Joined: Mon Mar 04, 2013 3:40 pm
Location: Deepest Wiltshire, UK
Discord: SlySven#2703

Re: Need Help with Random Output Trigger Variable

Post by SlySven »

For what it is worth the regexp ".*" is in two pieces: "." means match "ANY character" and "*" means "zero or more times"...

Post Reply