Mudlet line counting

by Unknown

Back to Mechanic's Corner.

Unknown2010-03-17 00:57:21
Does anyone know if there's a way to make mudlet count lines that have passed since a trigger started, without using regex? I know I can get it to work with a ^ regex trigger, but regex is potentially slow, so if possible I'd like to find a way to do it that doesn't require regex.

Thank you content.gif
Unknown2010-03-17 01:35:23
QUOTE (Jello @ Mar 17 2010, 12:57 AM) <{POST_SNAPBACK}>
Does anyone know if there's a way to make mudlet count lines that have passed since a trigger started, without using regex? I know I can get it to work with a ^ regex trigger, but regex is potentially slow, so if possible I'd like to find a way to do it that doesn't require regex.

Thank you content.gif

In your trigger to start the count do this:
CODE
startline = getLineCount()
echo( "Line is: " .. startline )


Then create an alias you want to use when you want to know the number of lines that have passed (Or another particular trigger):
CODE
endline = getLineCount()
echo( "Lines since start is: " .. ((tonumber(endline) - tonumber(startline)) - 1))


I only tested quickly and don't really work much with Mudlet yet, but it seemed to work.
Unknown2010-03-17 01:35:28
Regex isn't slow, especially if you're just using one trigger to count some lines.

Not sure if Mudlet has functions for things like the total line count (MUSHclient does, and I'm sure Mudlet can, if it doesn't already), but you could look for that and just do a simple difference from start to stop.
Unknown2010-03-17 02:06:57
Thanks guys! Both things worth knowing.
Unknown2010-03-17 04:21:32
QUOTE (Jello @ Mar 16 2010, 08:57 PM) <{POST_SNAPBACK}>
Does anyone know if there's a way to make mudlet count lines that have passed since a trigger started, without using regex? I know I can get it to work with a ^ regex trigger, but regex is potentially slow, so if possible I'd like to find a way to do it that doesn't require regex.

Thank you content.gif



ok... there are several ways to go about this. If you want to simply make sure it's been a certain number of lines since a certain trigger fired before a different trigger fires (IE trigger A fires, trigger b won't fire unless it is the 6th line after trigger A fires) then a multiline AND trigger is what you want. In very pseudocode, this would look like the following:




The line delta here is also important, as that will determine the maximum number of lines it will continue to check for. So when trigger A fires, you need at least 6 newlines before tribber B fires. Without the line spicer, trigger A and trigger B could fire on the same line (assuming both conditions were met. A shoddy illusion to fall prey to indeed). The line delta of 6 says "If both aren't met within 6 lines, stop checking until trigger A matches again"

If instead you just want to count the lines, what was posted previously should work for you.
Unknown2010-03-17 07:22:54
Wow, so that's what line spacer does! Thank you. I had been staring at it earlier and tried to look it up but wasn't understanding what the manual said about deltas etc.