Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Miniwindows ➜ Miniwindows for Awakened Worlds

Miniwindows for Awakened Worlds

It is now over 60 days since the last post. This thread is closed.     Refresh page


Pages: 1  2 3  

Posted by Crashdivide   USA  (22 posts)  Bio
Date Reply #15 on Thu 08 Jul 2010 03:11 AM (UTC)
Message
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.

AwakenedWorlds.net Port:4000
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #16 on Thu 08 Jul 2010 03:14 AM (UTC)
Message
For me, it's actually pretty fun diagnosing this stuff. :D Glad you got it fixed!

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Crashdivide   USA  (22 posts)  Bio
Date Reply #17 on Thu 08 Jul 2010 03:22 AM (UTC)
Message
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.

AwakenedWorlds.net Port:4000
Top

Posted by Crashdivide   USA  (22 posts)  Bio
Date Reply #18 on Thu 08 Jul 2010 04:47 AM (UTC)
Message
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

AwakenedWorlds.net Port:4000
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #19 on Thu 08 Jul 2010 04:57 AM (UTC)
Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #20 on Thu 08 Jul 2010 05:10 AM (UTC)
Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Crashdivide   USA  (22 posts)  Bio
Date Reply #21 on Thu 08 Jul 2010 05:29 AM (UTC)
Message
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

AwakenedWorlds.net Port:4000
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #22 on Thu 08 Jul 2010 05:32 AM (UTC)
Message
*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).

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Crashdivide   USA  (22 posts)  Bio
Date Reply #23 on Thu 08 Jul 2010 05:55 AM (UTC)
Message
Wouldn't I need to pause it after each sent command? Since they both look into inventories?

AwakenedWorlds.net Port:4000
Top

Posted by Crashdivide   USA  (22 posts)  Bio
Date Reply #24 on Thu 08 Jul 2010 06:05 AM (UTC)
Message
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

AwakenedWorlds.net Port:4000
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #25 on Thu 08 Jul 2010 06:35 AM (UTC)
Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Crashdivide   USA  (22 posts)  Bio
Date Reply #26 on Thu 08 Jul 2010 06:50 AM (UTC)
Message
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

AwakenedWorlds.net Port:4000
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #27 on Thu 08 Jul 2010 06:57 AM (UTC)
Message
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


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Crashdivide   USA  (22 posts)  Bio
Date Reply #28 on Thu 08 Jul 2010 06:57 AM (UTC)
Message
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

AwakenedWorlds.net Port:4000
Top

Posted by Crashdivide   USA  (22 posts)  Bio
Date Reply #29 on Thu 08 Jul 2010 07:27 AM (UTC)
Message
How do I define #pack?

AwakenedWorlds.net Port:4000
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


80,720 views.

This is page 2, subject is 3 pages long:  [Previous page]  1  2 3  [Next page]

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.