this is the alias:
require "wait"
wait.make (function () -- coroutine starts here
local win = GetPluginID () .. "Equipment"
local font = "f"
if not WindowInfo (win, 1) then
WindowCreate (win, 0, 0, 0, 0, 8, 0, 0)
WindowFont (win, font, "Lucida Console", 9)
end -- if
-- request equipment
Send "eq"
-- wait for equipment to start
local x = wait.match ("You are using:", 10)
if not x then
ColourNote ("white", "blue", "No equipment recieved within 10 seconds")
return
end -- if
local equipment = {}
local max_width = WindowTextWidth (win, font, "You are using:")
-- loop until end of equipment
while true do
local line, wildcards, styles = wait.match ("*")
-- see if end of equipment
if not string.match (line, "^%[ [%a%d]%]: ") then
break
end -- if
-- save equipment line
table.insert (equipment, 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 * (#equipment + 2) + 10
-- make window correct size
WindowCreate (win, 0, 0, window_width, window_height, 8, 0, ColourNameToRGB "#373737")
WindowRectOp (win, 5, 0, 0, 0, 0, 5, 15 + 0x1000)
-- heading line
WindowText (win, font, "Equipment", 5, 5, 0, 0, ColourNameToRGB "yellow")
-- draw each equipment line
local y = font_height * 2 + 5
for i, styles in pairs (equipment) 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 equipment item
WindowShow (win, true)
end) -- end of coroutine
|