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 ➜ [HELP] Inventory Miniwindow

[HELP] Inventory Miniwindow

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


Posted by Roundcircle   USA  (2 posts)  Bio
Date Fri 04 Jun 2010 09:01 PM (UTC)
Message
My inventory miniwindow won't popup I think it has something to do with "You are carrying:". It sends inventory to Aardwolf and Aardwolf shows me what is in my inventory, but the inventory miniwindow doesn't popup and after 10 seconds it says "Inventory Timeout".


require "wait"

wait.make(function () -- coroutine start

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

local x = wait.match ("You are carrying:", 10)
if not x then
  ColourNote ("white", "blue", "Inventory Timeout")
  return
end -- if

local inv = {}
local max_width = WindowTextWidth (win, font, "Inventory")

-- inventory loop

while true do
  local line, wildcards, styles = wait.match ("*")

  --check end of inventory

  if not string.match (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 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 "yellow")

-- draw inventory lines

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

WindowShow (win, true)

end) -- coroutine end


Thanks for your help
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #1 on Fri 04 Jun 2010 09:44 PM (UTC)
Message
I just pasted what you had into an alias and it worked. Do you actually see "You are carrying:" appear on the screen, like this? ...


You are carrying:
     Gueldar's crafted leather cap (1)
     Gueldar's crafted leather jerkin (1)
     Gueldar's crafted leather belt (1)
     Gueldar's crafted leather bracer (1)


If so, it should work. But if you see this, it won't:


{inventory}
     Gueldar's crafted leather cap (1)
     Gueldar's crafted leather jerkin (1)
     Gueldar's crafted leather belt (1)
     Gueldar's crafted leather bracer (1)
{/inventory}


If you see the latter, type "tag inv off" to go back to the original display, or change the alias to look for "{inventory}" instead of "You are carrying:".

- Nick Gammon

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

Posted by Roundcircle   USA  (2 posts)  Bio
Date Reply #2 on Sat 05 Jun 2010 05:17 PM (UTC)

Amended on Sat 05 Jun 2010 05:19 PM (UTC) by Roundcircle

Message
I did a little change and now it's working. I changed this

--wait for inventory

local x = wait.match ("You are carrying:", 10)
if not x then
  ColourNote ("white", "blue", "Inventory Timeout")
  return
end -- if


to this


--wait for inventory

local x = wait.match ("You are carrying:", 10)

if not x then
  ColourNote ("white", "blue", "Inventory Timeout")
  return
end -- if


I don't think it likes me.
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.


9,489 views.

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.