If I need to know the actual line# of a line sent from the Mud that causes a trigger to fire, will it ALWAYS be found if trigger processing uses GetLineInfo(GetLinesInBufferCount()).line?
Is there a better way to get this information while processing a trigger?
Oops. Just found GetLineCount(). Is this always the correct line# when processing a trigger fired by that line?
See the help for that.
Description
This returns the number of lines received by this world. However, see GetLinesInBufferCount for the number of lines currently in the output buffer, which might be different.
In other words, if you have the output buffer size at 1000 lines, then GetLineCount will be right for the first 1000 lines, then it will discard 100 lines, so after that line 1001 will actually be line 901 in the buffer.
So you really want GetLinesInBufferCount.
However, again, if this trigger (or another one which happened to fire previously) has added a Note to the output buffer, then the Note will be the last line, not the triggered line. Also, lines can wrap, so if you have a 2-line "line" (that is, a line which doesn't have a linefeed inside the wrapping column) then GetLinesInBufferCount would give the second line, not the first one.
But why do you need to get this in the first place? In most cases there is an easier way.
I am trying to adapt your (Nick's) Materia Magica mapper to Cities of M'Dhoria (CMD).
CMD doesn't provide a unique way to trigger on the name of a room, but it does provide and easily identifiable exit line AND the ability to retrieve the room name from the prompt.
So I'm doing the following on each prompt
- Store the last prompt line's actual Mud line number
- Store this prompt line's actual Mud line number
- get this line's Buffer line number
- get the room name from the prompt itself
- compute the difference in actual line numbers and subtract it from the buffer line number to get the approximate position in the buffer of the previous prompt. My assumption is that I will land on the original prompt line in the buffer or an earlier line if lines were not sent to output.
- walk forward through the buffer until I find the name line by matching with the name in the subsequent prompt.
- build a description string starting with the next buffer line and proceeding until I find the exit line.
- build the key as is done in the Materia Magica mapper plugin.
I only do this processing if an exit line was in fact encountered between the last and current prompt lines
So far it seems to capture the right information
Yes, very cunning.
Well this might help:
That returns lines that arrived from the MUD (not notes or player input). For your purposes that might be better. It is in fact what is used for multi-line matches.
So in that case you probably do want GetLineCount - as that is lines received from the MUD. If you use GetLineCount for the previous prompt, and GetLineCount on the current prompt, that should give you the number of lines received from the MUD itself between prompts. Then just use GetRecentLines (n) where n is that number, and you have a nice array of lines to examine for the room name and description.
That should be pretty reliable then.
As always, thanks for your help and prompt replies, Nick!
GetRecentLines looks good.
So far my mapper is doing fine creating rooms, etc. I haven't run across one that hashes to an existing key yet (fingers crossed)