Miniwindows for Awakened Worlds

Posted by Crashdivide on Wed 07 Jul 2010 06:55 PM — 34 posts, 115,201 views.

USA #0
What's up, folks?

I've recently started using Mushclient for the first time yesterday, and I came across the miniwindow thing and realized it's got alot of pretty useful uses. My problem is that I have no clue how to code or script.

I'd really like to see a miniwindow that shows what I'm carrying, my total Reputation and Notoriety and TKE, whether I'm weidling a weapon or have it holstered/sheathed, how much nuyen I have on a credstick, in the bank, how many clips of ammunition I have in various mag-straps and pockets, and how much weight in Kilos I'm carrying, versus my maximum weight allowance.

If any of you feel up to the project, let me know. I wish I had at least some kind of experience with scripting so I didn't feel like I was asking for a handout, but maybe someone out there would think it's a fun challenge.
Australia Forum Administrator #1
Quite a few plugins already exist, at least as examples of what to do.

http://www.gammon.com.au/forum/bbshowpost.php?bbtopic_id=108

There is a YouTube video showing how to make a plugin:

http://www.gammon.com.au/forum/?id=9617

This video shows how to use miniwindows to make an inventory window:

http://www.gammon.com.au/forum/?id=9965

The ideas there can be adapted for other things.
Amended on Tue 26 Nov 2013 03:46 AM by Nick Gammon
USA #2
I watched the tutorials, notably the inventory miniwindow (you give excellent and easy to follow tutorials, btw), and when all was said and done, I was able to create the miniwindow, but it was empty. I'm sure it had to do with the fact that on Awakened Worlds, when you type inventory, after You are carrying:, each inventory line starts at the border, there are no spaces. I tried changing a few things where you had 5 spaces indicated, but it didn't change anything. I'm not sure how you would tell the script that the inventory has ended.

When "i" is typed:

You are carrying:
A handheld Nav-Dat GPS system
a cellular phone
an invitation to Smith's Pub
a pocket secretary
an electronic kit
a set of low grade ultrasound goggles


There IS an empty space after the last line, obviously, Idunno if that helps. My miniwindow simply says "Inventory", with nothing else in it.
Australia Forum Administrator #3
Well in that script, where it says:


 -- see if end of inventory

  if not string.match (line, "^     ") then
    break
  end -- if


Instead of checking for not matching a line with spaces in it, match on an empty line, eg.


 -- see if end of inventory

  if line == "" then
    break
  end -- if

USA #4
ahh, I tried that, but left the ^ in. I'll try it.
USA #5
That did it, the inventory window works like a charm. I also attempted to use the drop|get|buy trigger, adding a couple other things like put, sell, give, gives you, but the trigger fires the alias, "inv", but the window doesn't update unless I manually type "inv" to fire the alias.
USA #6
Nevermind, I see the problem, I didn't add the fix you put in for when the prompt is on the same line as the "You are carrying:"
Australia Forum Administrator #7
Also make sure that the trigger does "inv" as "send to Execute" rather than "send to World". Otherwise it bypasses your inv alias.
USA #8
I got it working after using the fix you mentioned, but I can't seem to get a trigger that fires the alias when someone gives me something, such as:

Tinmai gives you a plastic credstick.

Or when I buy:

You now have a pint of Sapporo.

Or when I junk something:

You junk a pint of Sapporo. It vanishes into a recylcing bin!
Amended on Thu 08 Jul 2010 02:12 AM by Crashdivide
Australia Forum Administrator #9
Can you show us what you tried?

Template:copying
For advice on how to copy aliases, timers or triggers from within MUSHclient, and paste them into a forum message, please see Copying XML.


Something like:


* gives you *.


... should work.
USA #10
That worked amazingly well. What I was trying to do was use your trigger from the other thread, just changing the text, such as removing "^You" and replacing it with random crap. Is the "*" used for generally anything? Because all of the examples I gave in the last reply work now.
USA #11
And as for gagging the inventory in the output window, since we had to change the line under "--see if end of inventory" to

if line == "" then

What would I need to change that to to get this gag to work?
Australia Forum Administrator #12
Add the flag trigger_flag.OmitFromOutput as described in the other thread. That is to the wait.match part, so the change you made doesn't make any difference.

The latest versions of MUSHclient support that flag, so you should just be able to use it as described.


Crashdivide said:

Is the "*" used for generally anything?


If you are *not* using regular expressions, that matches any text (except newlines which you shouldn't have anyway in a single line trigger).

The stuff with ^ and $ in it is generally used in regular expressions, it is best not to confuse the two things.

This gives more details:

http://www.gammon.com.au/mushclient/funwithtriggers.htm
USA #13
Now getting:

[string "Alias: "]:21: ')' expected near 'trigger_flag'

USA #14
You have a ( without a matching ) somewhere near your use of trigger_flag, or you may be missing a comma in a function arguments list. Paste what you have?
Amended on Thu 08 Jul 2010 03:04 AM by Twisol
USA #15
Well, that was it, the damn commas. I was just pasting the line after the space.

It looks like it's working perfectly now, thanks guys for your patience, I know it's difficult when someone is making pretty basic mistakes.
USA #16
For me, it's actually pretty fun diagnosing this stuff. :D Glad you got it fixed!
USA #17
Now, one last question, to have a second miniwindow for the inventory inside a container, I'd like to have it just under the first. I'm not sure exactly what line the positioning of the window is, to change it. As it is, the second window just replaces the first, and vice versa. And, is there some kind of word-wrap function on the windows? Having items with long descriptions causes the window to cover up text.
USA #18
Or rather, would it be possible to send "inventory" and "look in pack" in the same window? With a break between them. So it would looks something like:

Inventory

a set of low grade ultrasound goggles
A handheld Nav-Dat GPS system
a cellular phone
an invitation to Smith's Pub
a pocket secretary
an electronic kit

A Blackwind(tm) R-55 M.O.R.P

a radio
a bandolier
a pair of Blackhawk(TM) 'Air-Tac' boots
a map of Seattle
A large fuzzy Skwerl with red Devil's lockes and facial tattoos
An earbud radio
a climbing harness
an Encyclopedia labeled "O"
a black feather
Australia Forum Administrator #19
Certainly, almost anything is possible. You could adapt the alias to first get the inventory, and then instead of displaying it, do the "look in pack", appending the lines received into the table of results. It would sort of be like the bulk of the alias, duplicated. Make sure you don't clear the "inv" table a second time. Then you would allow for a couple of blank lines, and you should be cooking with gas.
Australia Forum Administrator #20
Crashdivide said:

And, is there some kind of word-wrap function on the windows? Having items with long descriptions causes the window to cover up text.


It can be done:

Template:post=9996
Please see the forum thread: http://gammon.com.au/forum/?id=9996.
USA #21
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
USA #22
*whistles* Major props for being creative, truly, but you only use the wait.lua module within triggers/aliases to pause the script execution (as an alternative to DoAfter).
USA #23
Wouldn't I need to pause it after each sent command? Since they both look into inventories?
USA #24
Tried this, and at least I didn't get an error, but it only showed what's in the pack, and the headers, "Inventory" and "Blackwind(TM) M.O.R.P." were overlapping.





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

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))

end -- while loop

-- request inventory

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, "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 "#000000")
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

-- heading line

WindowText (win, font, "a Blackwind(tm) R-55 M.O.R.P", 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

WindowShow (win, true)


end) -- end of coroutine
Australia Forum Administrator #25
Half way down, change:


local inv = {}
local max_width = WindowTextWidth (win, font, "a Blackwind(tm) R-55 M.O.R.P")


to:



max_width = math.max (max_width, WindowTextWidth (win, font, "a Blackwind(tm) R-55 M.O.R.P"))



Since you cleared out inv (the table of what you have to display), then you will lose all the early stuff you put in it. So, "local inv = {}" has to go (the second one).

Further down, you have:


WindowText (win, font, "a Blackwind(tm) R-55 M.O.R.P", 5, 5, 0, 0, ColourNameToRGB "Red")


That is displaying at 5, 5 (the x and y location). That needs to be where the previous one finished, eg.


WindowText (win, font, "a Blackwind(tm) R-55 M.O.R.P", 5, y, 0, 0, ColourNameToRGB "Red")
y = y + font_height


That is, the y location (that is, down the page) is where the previous stuff left it.

Then omit this line the second time around:


local y = font_height * 2 + 5


That will put the y back at the top again.

It isn't magic - you just need to work out what each line is doing.
USA #26
That worked to put all the items in both inventories together, but it put them all in one list, as if they were in the same container/inventory, then put the Blackwind down at the bottom, so it looks like


Inventory

Item from inv
Item from inv
Item from inv
Item from inv
Item from pack
Item from pack
Item from Pack
Item from Pack
Blackwind R-55 M.O.R.P


And the window isn't big enough and cuts off in the middle of the last line.

What I would like is:

Inventory

Item from inv
Item from inv
Item from inv

Blackwind R-55 M.O.R.P

Item from pack
Item from pack
Item from pack
Australia Forum Administrator #27
OK, yes it would do that. :)

Well you probably need two tables, eg. inv and pack.

The first loop fills up inv, and the second one fills up pack.

The number of lines to allocate to make the window will be the size of inv (ie. #inv) plus the size of pack (ie. #pack) plus about 4 or 5 for the headings.

Then you need to:

  • Display the inventory heading
  • Drop y down a line (to leave a blank)
  • Loop, displaying all the inv lines
  • Drop y down a line (to leave a blank)
  • Display the pack heading
  • Drop y down another line
  • Loop to display the pack lines

USA #28
I moved:

WindowText (win, font, "a Blackwind(tm) R-55 M.O.R.P", 5, y, 0, 0, ColourNameToRGB "Red")
y = y + font_height

-- draw each inventory line


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



down past the output of the inventory, so it looks like it works, but the miniwindow isn't stretching to show it all
USA #29
How do I define #pack?
USA #30
Nevermind, I seem to have figured it all out. To create spaces in the window, is that just extra lines in the code? Or is there a tag to create link breaks?
USA #31
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

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))

end -- while loop

-- request inventory

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 pack = {}
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 (pack, 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 + #pack + 2) + 10

-- make window correct size

WindowCreate (win, 0, 0, window_width, window_height, 6, 0, ColourNameToRGB "#000000")
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

-- heading line

WindowText (win, font, "a Blackwind(tm) R-55 M.O.R.P", 5, y, 0, 0, ColourNameToRGB "Red")

y = y + font_height


-- draw each inventory line

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



This makes the window:

Inventory

Item
Item
Item
Item
Blackwind
Item
Item
Item


Just need to figure out how to space, since it seems that the Inventory group and the Blackwind group are identical, yet there's only a space after inventory.
USA #32
I decided, instead, to go with the two windows, and this is what I used:


require "wait"

wait.make (function ()  -- coroutine starts here


local win = GetPluginID () .. ":inventory"
local font = "f"

if not WindowInfo ("1", 1) then
  WindowCreate ("1", 0, 0, 0, 0, 6, 0, 0)
  WindowFont ("1", 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

local inv = {}
local max_width = WindowTextWidth ("1", 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 ("1", font, line))

end -- while loop


local font_height = WindowFontInfo ("1", font, 1)

local window_width = max_width + 10
local window_height = font_height * (#inv + 2) + 10

-- make window correct size

WindowCreate ("1", 0, 0, window_width, window_height, 6, 0, ColourNameToRGB "#000000")
WindowRectOp ("1", 5, 0, 0, 0, 0, 5, 15 + 0x1000)

-- heading line

WindowText ("1", 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 ("1", font, style.text, x, y, 0, 0, style.textcolour)
  end -- for
  y = y + font_height

end -- for each inventory item


if not WindowInfo ("2", 1) then
  WindowCreate ("2", 0, 0, 0, 0, 7, 0, 0)
  WindowFont ("2", font, "Lucida Console", 9)
end -- if


-- request inventory

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 pack = {}
local max_width = WindowTextWidth ("2", 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 (pack, styles)
  -- work out max width
  max_width = math.max (max_width, WindowTextWidth ("2", font, line))

end -- while loop

local font_height = WindowFontInfo ("2", font, 1)

local window_width = max_width + 10
local window_height = font_height * (#pack + 2) + 10

-- make window correct size

WindowCreate ("2", 0, 0, window_width, window_height, 7, 0, ColourNameToRGB "#000000")
WindowRectOp ("2", 5, 0, 0, 0, 0, 5, 15 + 0x1000)

-- heading line

WindowText ("2", font, "a Blackwind(tm) R-55 M.O.R.P", 5, 5, 0, 0, ColourNameToRGB  "Red")

-- draw each inventory line

local y = font_height * 2 + 5

for i, styles in ipairs (pack) do

  local x = 5
  for _, style in ipairs (styles) do
    x = x + WindowText ("2", font, style.text, x, y, 0, 0, style.textcolour)
  end -- for
  y = y + font_height

end -- for each inventory item

WindowShow "1"
WindowShow "2"


end)   -- end of coroutine



This works great, but I want to get the second window, which is in the 7 position, right under the first window, in the 6 position. But if I set them both to 6, they overlap.
USA #33
Everything seems to be working great now, I even added a few more windows, but, I have one question.

I have a window for the inventory, the pack, and spells I'm sustaining. But if there's nothing in the pack, or I'm not carrying anything, or not sustaining spells, none of the windows work until I put something in inv/pack/sustain a spell. Is there a way to fix that?


I'm using:


require "wait"

wait.make (function ()  -- coroutine starts here


local win = GetPluginID () .. ":inventory"
local font = "f"

if not WindowInfo ("1", 1) then
  WindowCreate ("1", 0, 0, 0, 0, 6, 0, 0)
  WindowFont ("1", 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

local inv = {}
local max_width = WindowTextWidth ("1", 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 ("1", font, line))

end -- while loop


local font_height = WindowFontInfo ("1", font, 1)

local window_width = max_width + 10
local window_height = font_height * (#inv + 2) + 10

-- make window correct size

WindowCreate ("1", 0, 0, window_width, window_height, 6, 0, ColourNameToRGB "#000000")
WindowRectOp ("1", 5, 0, 0, 0, 0, 5, 15 + 0x1000)

-- heading line

WindowText ("1", 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 ("1", font, style.text, x, y, 0, 0, style.textcolour)
  end -- for
  y = y + font_height

end -- for each inventory item


if not WindowInfo ("2", 1) then
  WindowCreate ("2", 0, 0, 0, 0, 7, 0, 0)
  WindowFont ("2", font, "Lucida Console", 9)
end -- if


-- request inventory

Send "look in pack"


-- wait for inventory to start

local x = wait.match ("*a Blackhawk(TM) X-3 R.A.P.T.O.R. pack (used): ", 10, trigger_flag.OmitFromOutput)

if not x then
  ColourNote ("white", "blue", "No inventory received within 10 seconds")
  return
end -- if

local pack = {}
local max_width = WindowTextWidth ("2", font, "a Blackhawk(TM) X-3 R.A.P.T.O.R.")

-- 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 (pack, styles)
  -- work out max width
  max_width = math.max (max_width, WindowTextWidth ("2", font, line))

end -- while loop

local font_height = WindowFontInfo ("2", font, 1)

local window_width = max_width + 10
local window_height = font_height * (#pack + 2) + 10

-- make window correct size

WindowCreate ("2", 0, 0, window_width, window_height, 7, 0, ColourNameToRGB "#000000")
WindowRectOp ("2", 5, 0, 0, 0, 0, 5, 15 + 0x1000)

-- heading line

WindowText ("2", font, "a Blackhawk(TM) X-3 R.A.P.T.O.R. pack", 5, 5, 0, 0, ColourNameToRGB  "Red")

-- draw each inventory line

local y = font_height * 2 + 5

for i, styles in ipairs (pack) do

  local x = 5
  for _, style in ipairs (styles) do
    x = x + WindowText ("2", font, style.text, x, y, 0, 0, style.textcolour)
  end -- for
  y = y + font_height

end -- for each inventory item

if not WindowInfo ("3", 1) then
  WindowCreate ("3", 0, 0, 0, 0, 7, 0, 0)
  WindowFont ("3", font, "Lucida Console", 9)
end -- if

-- request inventory

Send "status"


-- wait for inventory to start

local x = wait.match ("*You are sustaining:", 10, trigger_flag.OmitFromOutput)

if not x then
  ColourNote ("white", "blue", "No inventory received within 10 seconds")
  return
end -- if

local sus = {}
local max_width = WindowTextWidth ("3", font, "Sustained Spells")

-- 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 (sus, styles)
  -- work out max width
  max_width = math.max (max_width, WindowTextWidth ("3", font, line))

end -- while loop


local font_height = WindowFontInfo ("3", font, 1)

local window_width = max_width + 10
local window_height = font_height * (#sus + 2) + 10

-- make window correct size

WindowCreate ("3", 0, 0, window_width, window_height, 7, 0, ColourNameToRGB "#000000")
WindowRectOp ("3", 5, 0, 0, 0, 0, 5, 15 + 0x1000)

-- heading line

WindowText ("3", font, "Sustained Spells", 5, 5, 0, 0, ColourNameToRGB  "red")

-- draw each inventory line

local y = font_height * 2 + 5

for i, styles in ipairs (sus) do

  local x = 5
  for _, style in ipairs (styles) do
    x = x + WindowText ("3", font, style.text, x, y, 0, 0, style.textcolour)
  end -- for
  y = y + font_height

end -- for each inventory item

WindowShow "1"
WindowShow "2"
WindowShow "3"

end)   -- end of coroutine