Alright, since I'm still unclear on what alot of these lines of code do, I tried putting things in places that looked like they'd work, and I ended up with:
[string "Alias: "]:129: unexpected symbol near ')'
My script might make your head hurt, because I'm sure you'll wonder why the hell this is there, and that is here...
require "wait"
wait.make (function () -- coroutine starts here
local win = GetPluginID () .. ":inventory"
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 inventory
Send "inventory"
-- wait for inventory to start
local x = wait.match ("*You are carrying:", 10, trigger_flag.OmitFromOutput)
if not x then
ColourNote ("white", "blue", "No inventory received within 10 seconds")
return
end -- if
Send "look in pack"
-- wait for inventory to start
local x = wait.match ("*a Blackwind(tm) R-55 M.O.R.P (used): ", 10, trigger_flag.OmitFromOutput)
if not x then
ColourNote ("white", "blue", "No inventory received within 10 seconds")
return
end -- if
local inv = {}
local max_width = WindowTextWidth (win, font, "Inventory")
-- loop until end of inventory
while true do
local line, wildcards, styles = wait.match ("*", 0, trigger_flag.OmitFromOutput)
-- see if end of inventory
if line == "" then
break
end -- if
-- save inventory line
table.insert (inv, styles)
-- work out max width
max_width = math.max (max_width, WindowTextWidth (win, font, line))
local inv = {}
local max_width = WindowTextWidth (win, font, "a Blackwind(tm) R-55 M.O.R.P")
-- loop until end of inventory
while true do
local line, wildcards, styles = wait.match ("*", 0, trigger_flag.OmitFromOutput)
-- see if end of inventory
if line == "" then
break
end -- if
-- save inventory 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, "Inventory", 5, 5, 0, 0, ColourNameToRGB "red")
-- draw each inventory 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 inventory item
WindowText (win, font, "a Blackwind(tm) R-55 M.O.R.P", 5, 5, 0, 0, ColourNameToRGB "Black")
-- draw each inventory 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 inventory item
WindowShow (win, true)
end) -- end of coroutine
|