Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ General ➜ Triggers that may or may not gag.

Triggers that may or may not gag.

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


Posted by Twisol   USA  (2,257 posts)  Bio
Date Thu 06 Aug 2009 05:20 AM (UTC)
Message
What would be the best way to handle this scenario? I have a set of triggers that gag and parse a certain stretch of text under certain conditions. Let's say it gags a map as you move. These triggers come in a specific order and have different groups.

Now what happens if you don't want to gag that when the user uses a command to get it? Obviously it needs to be displayed, not gagged, but you still want the parsing to be done.

My solution right now involves taking a table of trigger labels and iterating over them to set/unset the gagging options at need. It seems klutzy to me, and I was wondering if there was a better way.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #1 on Thu 06 Aug 2009 05:32 AM (UTC)
Message
I was going to suggest something similar. Say you type "map" and you want to see the map, but usually you gag it (or, inventory, or something).

One approach would be to have a "map" alias that turns off the "omit from output" flag on the appropriate trigger. Then, when the map has fully appeared (ie. the line that normally terminates the map output) it could turn omit from output back on, ready for next time.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #2 on Thu 06 Aug 2009 05:39 AM (UTC)
Message
Yeah, that's exactly what I'm doing, just for multiple triggers (since I have distinct start, middle, and end areas that all need conditional gagging). It just seems like there should be a better way. Thanks anyways!

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Fadedparadox   USA  (91 posts)  Bio
Date Reply #3 on Sat 08 Aug 2009 03:04 PM (UTC)
Message
You could use DeleteLines.
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #4 on Sat 08 Aug 2009 10:20 PM (UTC)

Amended on Sat 08 Aug 2009 10:21 PM (UTC) by Twisol

Message
I did look into that already, but this part of its documentation sort of throws it out the window for me:

`A line is counted as a physical line on the screen, it does not necessarily end in a newline character.`

That means it won't work as expected sometimes, depending on what wrap-width you might have set and what wrap-width the plugin-maker has. That's unacceptable for my purposes. =/

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #5 on Sun 09 Aug 2009 01:29 AM (UTC)
Message
You can do what the client does, and work backwards to find the previous line ending in a "real" line end, and then step forwards one line. This gives you the last "paragraph".

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #6 on Sun 09 Aug 2009 08:10 PM (UTC)
Message
Hmm. How expensive is it to do that? Wouldn't that make any line-flicker stand out more?

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #7 on Sun 09 Aug 2009 08:58 PM (UTC)

Amended on Mon 10 Aug 2009 11:32 PM (UTC) by Nick Gammon

Message
At present there is no line flicker if you omit a line that has just arrived, as redrawing the window is deferred to the main event loop as a low priority.

If you waited for a while and then tried to delete a batch of lines, yes there might be a flicker.

What might work for you instead is to do it a different way:


  • Omit your map or whatever it is from output as you go, in the usual way.

  • As each line arrives, in addition to your normal processing add the style runs into a Lua table. That is, on the first line (the start of the map), clear the table out, and then add that first line.

  • For subsequent lines, just do table.insert of the whole style run table.

  • Once the final line has arrived, check some flag you set in the alias to see whether you want to show the map.

  • If wanted, just run through the saved table, displaying each style run with a ColourTell / ColourNote.


That way, the map can be optionally shown, the extra work is minimal, and you don't need to toggle on or off the omit-from-output flags for lots of triggers.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #8 on Mon 10 Aug 2009 06:23 PM (UTC)
Message
Hmm, I like that. Thanks!

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
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.


25,085 views.

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

Go to topic:           Search the forum


[Go to top] top

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