Thanks worstje, although I am still having trouble with the regexp. I'm posting the code from the alias so hopefully that will give people more of an idea. The window works if I use the capture (.*?), but as soon as I start trying to be more specific than that, it doesn't seem to work.
require "wait"
wait.make (function () -- coroutine starts here
local win = GetPluginID () .. ":affection" -- get a unique name
local font = "f"
-- request inventory
Send "aff"
local x = wait.regexp ("^(?:.*>)?(?J)You are affected by\:$", 10)
if not x then
ColourNote ("white", "blue", "No affection received within 10 seconds")
return
end -- if
aff = {}
-- loop until end of inventory
while true do
local line, wildcards = wait.regexp("^(.+)\s+\([^]]+\)")
affection = wildcards[1]
-- see if end of inventory
if string.match (line, "^$") then
break
end -- if
-- save inventory line
aff [affection] = 0
end -- while loop
require "tprint"
tprint (aff)
WindowFont (win, font, "Lucida Console", 10)
WindowCreate (win, 0 , 0, 150, GetInfo (212) * 20, 10, 0, ColourNameToRGB ("#003200")) -- create window
WindowRectOp (win, 5, 0, 0, 0, 0, 5, 15)
WindowText (win, font, "Affections", 5, 5, 0, 0, ColourNameToRGB "yellow")
-- draw each affection line
local font_height = WindowFontInfo (win, font, 1)
local y = font_height * 2 + 5
for k, v in pairs (aff) do
local x = 5
x = x + WindowText (win, font, k, x, y, 0, 0, ColourNameToRGB ("white"))
y = y + font_height
end -- for each affection
WindowShow (win, true)
end) -- end of coroutine
|