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

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Triggers that may or may not gag.

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Triggers that may or may not gag.

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page


Posted by Twisol   USA  (2,229 posts)  [Biography] bio
Date Thu 06 Aug 2009 05:20 AM (UTC)  quote  ]
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
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Thu 06 Aug 2009 05:32 AM (UTC)  quote  ]
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
[Go to top] top

Posted by Twisol   USA  (2,229 posts)  [Biography] bio
Date Reply #2 on Thu 06 Aug 2009 05:39 AM (UTC)  quote  ]
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
[Go to top] top

Posted by Fadedparadox   USA  (91 posts)  [Biography] bio
Date Reply #3 on Sat 08 Aug 2009 03:04 PM (UTC)  quote  ]
Message
You could use DeleteLines.
[Go to top] top

Posted by Twisol   USA  (2,229 posts)  [Biography] bio
Date Reply #4 on Sat 08 Aug 2009 10:20 PM (UTC)  quote  ]

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
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Sun 09 Aug 2009 01:29 AM (UTC)  quote  ]
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
[Go to top] top

Posted by Twisol   USA  (2,229 posts)  [Biography] bio
Date Reply #6 on Sun 09 Aug 2009 08:10 PM (UTC)  quote  ]
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
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Reply #7 on Sun 09 Aug 2009 08:58 PM (UTC)  quote  ]

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
[Go to top] top

Posted by Twisol   USA  (2,229 posts)  [Biography] bio
Date Reply #8 on Mon 10 Aug 2009 06:23 PM (UTC)  quote  ]
Message
Hmm, I like that. Thanks!

'Soludra' on Achaea

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


2,639 views.

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

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

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]