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.
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.
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.
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.
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.
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?
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.
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
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.
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
*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).
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
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).
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.
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.
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?
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.
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.
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