Here comes my first, useful post!
I went ahead and wrote up a script that starts with a table of 15 strings, which represent the output from your MUD, and then it writes the first 10 of those lines to a white Miniwindow.
There are two invisible hotspots which are each 10 pixels x 100 pixels and on the far right side of the Miniwindow situated on top of each other. If you click the top one it'll scroll your text up (provided you're not on the first line) and down (provided you're not out of lines).
What you'll want to work on to suit your needs is changing out the table with MUD's output. I have no idea how many lines you can fit in that table without having any memory/speed issues, so you might want to use Twisol's suggestion and keep it around 100 lines or whatever.
Also! This works off of MouseUp, which means you have to remove your finger from the mouse. You can only get one scroll per click as a consequence. You can easily change:
function MouseUp(flags, hotspot_id)
scrollbar(hotspot_id)
end
to not have anything in it, and move
to
the function MouseDown(). If you do that, you'll want to cancel the scrollbar stuff on CancelMouseDown or it'll keep going no matter where your mouse was after the click.
Here's what is between the script tags in the XML plugin:
text = {
"1: This is a line of text",
"2: This is a line of text",
"3: This is a line of text",
"4: This is a line of text",
"5: This is a line of text",
"6: This is a line of text",
"7: This is a line of text",
"8: This is a line of text",
"9: This is a line of text",
"10: This is a line of text",
"11: This is a line of text",
"12: This is a line of text",
"13: This is a line of text",
"14: This is a line of text",
"15: This is a line of text"
}
lineStart = 1
lineEnd = 10
SBWin = "ScrollbarWindow"..GetPluginID()
function OnPluginInstall()
init()
end
function init()
WindowCreate(SBWin, 2, 2, 200, 200, 4, 2, ColourNameToRGB("white"))
WindowAddHotspot(SBWin, "upHotspot", 190, 0, 0, 100, "MouseOver", "CancelMouseOver", "MouseDown", "CancelMouseDown", "MouseUp", "Scroll up?", 1, 0)
WindowAddHotspot(SBWin, "downHotspot", 190, 100, 0, 0, "MouseOver", "CancelMouseOver", "MouseDown", "CancelMouseDown", "MouseUp", "Scroll down?", 1, 0)
WindowFont(SBWin, "font"..SBWin, "Trebuchet MS", 12, true, false, false, false)
WindowShow(SBWin, true)
writeLines()
end
function writeLines()
spacing = 0
for count = lineStart, lineEnd do
WindowText(SBWin, "font"..SBWin, text[count], 5, spacing * 15, 0, 0, ColourNameToRGB("black"), false)
spacing = spacing + 1
end
end
function refresh()
WindowRectOp(SBWin, 2, 0, 0, 0, 0, ColourNameToRGB("white"), ColourNameToRGB("white"))
WindowShow(SBWin, true)
writeLines()
end
function scrollbar(calledBy)
if calledBy == "upHotspot" then
if (lineStart > 1) then
lineStart = lineStart - 1
lineEnd = lineEnd - 1
end
elseif calledBy == "downHotspot" then
if (lineEnd < #text) then
lineStart = lineStart + 1
lineEnd = lineEnd + 1
end
end
refresh()
end
function MouseOver(flags, hotspot_id)
end
function CancelMouseOver(flags, hotspot_id)
end
function MouseDown(flags, hotspot_id)
end
function CancelMouseDown(flags, hotspot_id)
end
function MouseUp(flags, hotspot_id)
scrollbar(hotspot_id)
end
|