Knew I forgot something. Its not exactly a plugin yet, I've tried converting the Inventory Miniwindow Plugin into an alias to capture all of it just to see if I could get it to work without making more then one miniwindow:
require "wait"
wait.make (function () -- coroutine starts here
local win = GetPluginID () .. ":who"
local font = "f"
if not WindowInfo (win, 1) then
WindowCreate (win, 0, 0, 0, 0, 6, 0, 0)
WindowFont (win, font, "Lucida Console", 9)
end -- if
-- request who list
Send "who"
-- wait for who list to start
local x = wait.match ("..Found!", 10)
if not x then
ColourNote ("white", "blue", "No who list received within 10 seconds")
return
end -- if
local inv = {}
local max_width = WindowTextWidth (win, font, "Who")
-- loop until end of who list
while true do
local line, wildcards, styles = wait.match ("*")
-- see if end of who list
if string.match (line, "^Logging off..") then
break
end -- if
-- save who list line
table.insert (inv, styles)
-- work out max width
max_width = math.max (max_width, WindowTextWidth (win, font, line))
end -- while loop
local font_height = WindowFontInfo (win, font, 1)
local window_width = max_width + 10
local window_height = font_height * (#inv + 2) + 10
-- make window correct size
WindowCreate (win, 0, 0, window_width, window_height, 6, 0, ColourNameToRGB "#373737")
WindowRectOp (win, 5, 0, 0, 0, 0, 5, 15 + 0x1000)
-- heading line
WindowText (win, font, "Who List", 5, 5, 0, 0, ColourNameToRGB "yellow")
-- draw each who list line
local y = font_height * 2 + 5
for i, styles in ipairs (inv) do
local x = 5
for _, style in ipairs (styles) do
x = x + WindowText (win, font, style.text, x, y, 0, 0, style.textcolour)
end -- for
y = y + font_height
end -- for each who list item
WindowShow (win, true)
end) -- end of coroutine
10 seconds later I get "No Inventory received within 10 seconds"
I didn't edit much as you can see most of the functions still use inv. Once I get it working I'll end up changing them to whoImm or whoplayer. |