Name |
GetLineInfo
|
Type
| Method |
Summary
| Gets details about a specified line in the output window |
Prototype
| VARIANT GetLineInfo(long LineNumber, short InfoType);
|
Description
| Returns details about any line in the output buffer (window).
The line number can be from 1 (the first line) to the number of lines in the output window. You can use "world.GetLinesInBufferCount" to find how many lines are currently in the output window. This number is different from the sequential number of the line since the world opened. For example, if your buffer size is 5000 lines, and you have received 8000 lines, then the last line will be line around 5000 in the buffer but "actual line number" (selector 10 below) will return 8000.
Note that when the buffer fills up lines are discarded in batches of 100, so the last line will probably not be 5000, even if your buffer size is 5000 and you have been connected for a while. It is likely to be in the range 4900 to 4999.
Also, the last line may be blank (empty) as MUSHclient creates a new, empty, line as soon as a newline is received for the previous line from the MUD.
You can obtain one of 12 "types" of information about the line by specifying an "InfoType". The possible InfoTypes are:
1: text of line (string)
2: length of text (short)
3: true if newline, false if not (boolean)
4: true if world.note (boolean)
5: true if player input (boolean)
6: true if line logged (boolean)
7: true if bookmarked (boolean)
8: true if MXP horizontal rule (<hr>) (boolean)
9: date/time line arrived (date)
10: actual line number (not line number in buffer) (long)
11: count of style runs (long)
12: ticks - exact value from the high-performance timer (double)
13: elapsed time in seconds from when the world was started (opened) (high precision)
The text of the line is the actual text you see on the screen.
If "newline" is true then this line is the end of a paragraph (ie. had a newline at the end of it). You can reassemble paragraphs by concatenating lines as found, and then adding a newline (carriage-return, linefeed) whenever "newline" is true. MUSHclient automatically preserves the space at the end of each line, so it is unnecessary to add another of your own. If "indent paragraphs" option is set in MUSHclient the space will be at the start of the next line, rather than the end of the previous line.
If "world.note" is true this is a "note" line, not MUD output.
If "player input" is true, then this line is an echoed command, not MUD output.
The count of styles runs can be used in conjunction with GetStyleInfo to further break up individual lines into style runs (eg. colour changes, bold, underline, etc.).
The "ticks" value is obtained by querying the "high performance timer" provided by Windows. This gives a time interval to a high degree of precision, however it is not related to the time-of-day in any meaningful way. The intention here is that you can use it to find the precise time difference between various lines as they arrive from the MUD.
Note: Available in version 3.18 onwards.
|
VBscript example
| dim line, total_lines
total_lines = world.GetLinesInBufferCount
'
' Example showing the last 10 lines in the output buffer
' Shown is text of line, date/time received, count of style runs
'
for line = total_lines - 10 to total_lines
world.note "Line " & line & " = " & world.GetLineInfo (line, 1)
world.tell "Received " & world.GetLineInfo (line, 9)
world.note " - Style runs = " & world.GetLineInfo (line, 11)
next
|
Jscript example
| var line, total_lines;
total_lines = world.GetLinesInBufferCount ();
//
// Example showing the last 10 lines in the output buffer
// Shown is text of line, date/time received, count of style runs
//
for (line = total_lines - 10; line <= total_lines; line++)
{
world.note ("Line " + line + " = " + world.GetLineInfo (line, 1));
world.tell ("Received " + world.GetLineInfo (line, 9));
world.note (" - Style runs = " + world.GetLineInfo (line, 11));
}
|
PerlScript example
| my $line, $total_lines;
$total_lines = $world->GetLinesInBufferCount ();
#
# Example showing the last 10 lines in the output buffer
# Shown is text of line, date/time received, count of style runs
#
for ($line = $total_lines - 10; $line <= $total_lines; $line++)
{
$world->note ("Line " . $line . " = " . $world->GetLineInfo ($line, 1));
$world->tell ("Received " . $world->GetLineInfo ($line, 9));
$world->note (" - Style runs = " . $world->GetLineInfo ($line, 11));
}
|
Python example
| total_lines = world.GetLinesInBufferCount
#
# Example showing the last 10 lines in the output buffer
# Shown is text of line, date/time received, count of style runs
#
for line in range (total_lines - 10, total_lines):
world.note ("Line " + str(line) + " = " + world.GetLineInfo (line, 1))
world.tell ("Received " + str (world.GetLineInfo (line, 9)))
world.note (" - Style runs = " + str (world.GetLineInfo (line, 11)))
|
Lua example
| local line, total_lines
total_lines = GetLinesInBufferCount ()
--
-- Example showing the last 10 lines in the output buffer
-- Shown is text of line, date/time received, count of style runs
--
for line = total_lines - 10, total_lines do
Note ("Line ", line, " = ", GetLineInfo (line, 1))
Tell ("Received ", GetLineInfo (line, 9))
Note (" - Style runs = ", GetLineInfo (line, 11))
end
-- Lua extension - returns all information in a table:
for line = total_lines - 10, total_lines do
table.foreach (GetLineInfo (line), print)
end
|
Lua notes
| The InfoType is optional, and defaults to zero.
As an extension, if the InfoType is omitted or zero, then all types of information
for the nominated line are returned in a table, keyed by type:
text: text of line (string)
length: length of text (number)
newline: true if newline, false if not (boolean)
note: true if world.note (boolean)
user: true if player input (boolean)
log: true if line logged (boolean)
bookmark: true if bookmarked (boolean)
hr: true if MXP horizontal rule (<hr>) (boolean)
time: date/time line arrived (date - number)
timestr: date/time line arrived (date - string)
line: actual line number (not line number in buffer) (number)
styles: count of style runs (number)
ticks: exact value from the high-performance timer
(number)
elapsed: exact elapsed time (number) since world started (opened)
Thus, to print the text of line 5 you might do this:
print (GetLineInfo (5).text)
If the line does not exist, or the InfoType is invalid, Lua will return nil.
|
Returns
| The specified information about the line, as described above.
An EMPTY variant, if the line does not exist.
A NULL variant if the InfoType is not a valid type. |
Introduced in version
| 3.18 |
Enter a word or phrase in the box below to narrow the list down to those that match.
The function name, prototype, summary, and description are searched.
Leave blank to show all functions.
Many functions return a "code" which indicates the success or otherwise
of the function.
The "prototype" part of each function description lists exactly how the function is called (what arguments, if any, to pass to it).