[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Highlighting a sentence within a multiple sentence output?

Highlighting a sentence within a multiple sentence output?

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Navazr   (15 posts)  [Biography] bio
Date Sat 05 Oct 2013 10:13 PM (UTC)
Message
Sorry if this has been covered somewhere. I checked through getting started and the highlighting stuff I could find, but couldn't resolve this.

So here is my question:

Is there a way to highlight a single sentence within a multiple sentence output?

Here is an example.

When I examine my utility belt in the MUD I'm playing I get this output from the game:

The belt is made of sturdy, rough-cut Kristanistian cattle leather. It boasts many pockets and flaps in which to place your possessions. Using the belt, though, is fairly complex, and requires at least a modicum of scholarly ability. It holds twenty
silver ores. It holds twenty iron ores. It holds twenty copper blocks. It holds two ropes. It holds no wax. It holds twenty tins. It holds no iron pole. It holds no twine. It belongs to you. You spot a small snow-flake shaped rune. A tiny oval-shaped
rune catches your eye. An anchor-shaped rune is emblazoned thereon.

I would like to highlight each of the different item sentences (For example, "It holds * iron ores.") a different color to make quickly checking belt contents easier.

Is there a way to do this? I've played around with it, but my somewhat rudimentary trigger knowledge hasn't allowed me to figure out a way to do it.

Thanks in advance for any assistance!
[Go to top] top

Posted by Chyort   USA  (58 posts)  [Biography] bio
Date Reply #1 on Sat 05 Oct 2013 11:02 PM (UTC)

Amended on Sat 05 Oct 2013 11:06 PM (UTC) by Chyort

Message

<triggers>
  <trigger
   custom_colour="7"
   enabled="y"
   keep_evaluating="y"
   match="It holds (.*?) ropes\."
   regexp="y"
   sequence="100"
  >
  </trigger>
</triggers>


If i understand what your after, just copy the chunks you want. Convert to regular expression. Then delete the ^ and $ off the start/end. and set the color/style box to what ever you want. Oh and check "keep evaluating" so multiple triggers can match on the same line.
[Go to top] top

Posted by Navazr   (15 posts)  [Biography] bio
Date Reply #2 on Sat 05 Oct 2013 11:52 PM (UTC)
Message
Sorry, but I guess I'm more of a MUSHclient noob than I thought I was.

I've been doing all my trigger work and stuff through the configuration/triggers UI (accessed via the triggers button on the toolbar).

How exactly would I use what you replied with?
[Go to top] top

Posted by Navazr   (15 posts)  [Biography] bio
Date Reply #3 on Sun 06 Oct 2013 01:04 AM (UTC)
Message
Nevermind! I got it!

I just wasn't using the "convert to regular expression" thing.

Thanks so much for your help!
[Go to top] top

Posted by Navazr   (15 posts)  [Biography] bio
Date Reply #4 on Sun 06 Oct 2013 01:20 AM (UTC)
Message
Okay Got another question if anyone is up for it.

I got a few of them working by just copy/pasting into the trigger field and then converting to regular expression. The first two worked fine (I skipped the very first one, silver, because it gets wrapped to a second line by the MUD, so I'm not sure if it'll be easily highlighted) but when I set up a third highlight trigger on the same line, the color from that 3rd highlight bleeds all the way back to the first triggered sentence on that line.

So this is the line of output that I'm working on now:

silver ores. It holds twenty iron ores. It holds twenty copper blocks. It holds two ropes. It holds no wax. It holds twenty tins. It holds no iron pole. It holds no

I set up a highlight trigger for the IRON and COPPER sentences. Each of them is a different color and they both work great.

However, using the same method to set up a highlight for ROPES or any of the other items on that line causes the chosen color for this 3rd highlight to "bleed" (Dunno if that's the right term) all the way back to the IRON sentence.

What gives?

As always, any help would be appreciated!
[Go to top] top

Posted by Chyort   USA  (58 posts)  [Biography] bio
Date Reply #5 on Sun 06 Oct 2013 02:11 AM (UTC)
Message
To use what i posted, just select everything in the code box, (triggers to /triggers) and then click the paste button in mushclient triggers.

And to see what the problem is, you need to post your triggers here. (click the copy button, and then just ctrl+v here) and wrap them with the code /code tags for easier reading...

Without seeing what your doing, and being able to test it myself it is hard to say.
[Go to top] top

Posted by Navazr   (15 posts)  [Biography] bio
Date Reply #6 on Sun 06 Oct 2013 02:27 AM (UTC)

Amended on Sun 06 Oct 2013 02:52 AM (UTC) by Navazr

Message
Not sure how to apply the code tags, sorry about that.

Iron and copper by themselves work fine, once I add the rope one in though it colors all 3 saddlebrown. Again, this is the line of output from the MUD i'm working with:


silver ores. It holds twenty iron ores. It holds twenty copper blocks. It holds two ropes. It holds no wax. It holds twenty tins. It holds n

Here's a screenshot of two outputs. First is with just the iron and copper trigger, third is with those two and the rope one as well.

http://s21.postimg.org/t35mfq5af/MUSHhelp1.jpg


<triggers>
  <trigger
   custom_colour="17"
   enabled="y"
   keep_evaluating="y"
   match="It holds (.*?) copper blocks\."
   regexp="y"
   sequence="100"
   other_text_colour="goldenrod"
  >
  </trigger>
  <trigger
   custom_colour="17"
   enabled="y"
   keep_evaluating="y"
   match="It holds (.*?) iron ores\."
   regexp="y"
   sequence="100"
   other_text_colour="dimgray"
  >
  </trigger>
  <trigger
   custom_colour="17"
   enabled="y"
   keep_evaluating="y"
   match="It holds (.*?) ropes\."
   regexp="y"
   sequence="100"
   other_text_colour="saddlebrown"
  >
  </trigger>
</triggers>
[Go to top] top

Posted by Chyort   USA  (58 posts)  [Biography] bio
Date Reply #7 on Sun 06 Oct 2013 02:45 AM (UTC)

Amended on Sun 06 Oct 2013 02:56 AM (UTC) by Chyort

Message
code tags are just [code] and [/code]. you put code above the text, and /code after and the forums makes it stand out a bit. Oh and you have to click the little "forums codes:" box below your message. There is a description of them under the little check box. just hit the forum codes link and it will give you a better description

Anyways!... i don't see the problem just looking at the triggers.

I changed 5 separate words on a single line on my mud just to test if there was some bug and it worked fine for me.

From the way you described it, i was assuming there was a variable at the start/end of one of your triggers. but looking at them, that isnt the problem.


Edit
After looking at the link you provided i see the problem.

The trigger is catching the first "It holds" and because your using the generic variable (.*?) it continues scanning the line until it sees "ropes".. and it is counting everything in between as one variable.

To solve this you need to mess around with your regular expression match and make it more restrictive. Instead of (.*?) which means everything.. try ([A-Za-z]+) basically any single word composed of everything from A-Z and a-z.

regular expressions can get very complicated, but they can also be amazingly powerful... You might want to search the forums here for a description of how they work. The convert to regular expression button is a nice starting point a lot of times, but every once in a while you need to get a lot more specific with defining what variable you are looking for.

[Go to top] top

Posted by Navazr   (15 posts)  [Biography] bio
Date Reply #8 on Sun 06 Oct 2013 03:01 AM (UTC)
Message
Awesome! That worked out perfect. Thanks a ton!

If you're still around, one more question:

The sentence with the silver ore is automatically separated into two lines by the MUD. It always ends at the quantity number, and starts the next line with "silver ore(s).".

I don't suppose there's any way to treat that as a single sentence for highlighting like the others is there?

Seems doubtful, but worth a shot I guess.
[Go to top] top

Posted by Chyort   USA  (58 posts)  [Biography] bio
Date Reply #9 on Sun 06 Oct 2013 03:12 AM (UTC)

Amended on Sun 06 Oct 2013 03:15 AM (UTC) by Chyort

Message
There are ways to accomplish anything. But that is getting a bit more complicated :P

My gut reaction was to say use "multi-line, match:" But that disables changing color and styles.

Hmm...

You might be able to accomplish it with 2 separate triggers if it always ends/starts at the same point... Use the a-z thing for the variable. and leave the $ in at the end, and start the next trigger with a ^.

So like... your first trigger match would be something like this

it holds ([A-Za-z]+)$

($ being end of line, and im typing this by hand quick and dirty so you might have to mess with the proper formatting :P)
and then another trigger that matches this.

^ silver (ore|ores)\.

(^ being the start of a line)

Oh and the (ore|ores) thing is another regular expression trick... it tells it to look for (this|Or that) so to speak, and nothing else.


Yet another edit... lol
the problem with doing it this way is you might get false positives. If those pop up, you can get around it by enabling triggers/disabling triggers using script commands most likly (trigger one, enables trigger 2. Then trigger 2 disables itself after it fires) But that is getting a lot more complicated and out of the realm of "General" trigger questions. heh :P
[Go to top] top

Posted by Navazr   (15 posts)  [Biography] bio
Date Reply #10 on Sun 06 Oct 2013 03:34 AM (UTC)
Message
Holy hell you're some kind of MUSHclient wizard or something!

Totally worked, and I'm pretty sure there aren't any other instances where a line will end or begin with either of those, so it'll be fine.

Gonna help to make checking my belts quite a bit easier than staring at a giant wall of same colored text!

http://s23.postimg.org/6j0h2fi7t/Successsss.jpg

Still gotta mess with the colors and stuff, but I've accomplished everything I wanted with your help! Really appreciate it man.
[Go to top] top

Posted by Chyort   USA  (58 posts)  [Biography] bio
Date Reply #11 on Sun 06 Oct 2013 03:51 AM (UTC)
Message
rofl

this is triggers 101 :P nick could show up, do some "Simple" Lua style runs or something and have us both scratching our heads in 2 seconds flat.

I have gotten my share of help on these forums over the years, and while i still have massive problems with real scripting, i have picked up a decent amount of info on how to make a bunch of simple stuff combine to do some interesting(for me) things... Heh.

But i enjoy helping out with the simple stuff, when i have time/notice it. Things that i can actually answer, and help pay it forward, so to speak.
[Go to top] top

Posted by Nick Gammon   Australia  (22,982 posts)  [Biography] bio   Forum Administrator
Date Reply #12 on Sun 06 Oct 2013 09:26 PM (UTC)
Message
If it's working for you, I'm happy. :)

You can detect colours in style runs if you have to, I think there is a module that helps with that.

http://www.gammon.com.au/modules

Look for "getstyle.lua".

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


30,037 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]