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.
 Entire forum ➜ MUSHclient ➜ Miniwindows ➜ Help with inventory miniwindow please

Help with inventory miniwindow please

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


Posted by Tiredchris   (17 posts)  Bio
Date Tue 30 Mar 2010 02:09 PM (UTC)
Message
I'm trying to get the inventory miniwindow that was posted here to work, but I'm having problems as I don't know coding much. I'm sure that once I get help with this the knowledge will help with other miniwindows, anyways the mud output is giving me some trouble since it's different from the mud you use, what I need it to do is copy the whole list even after the prompt to continue (sometimes I have a big inventory).

Here's the mud inventory when I give the command.

<903/903hp 544/544m 427/854mv 179175/825xp> 
inventory
You are carrying (Carry: 81/127, Weight: 495/597):
      (Marble Quest) Cavcav's marble bag(not that kind of marble bag, perverts!)
      (Glowing) (Humming) An Ebony Paintbrush
      a hydra scale
      A mechanic's utility belt
      (Glowing) (Humming) an attack pod
      (Glowing) An ore burner
(  2) an egyptian mace
      (Glowing) (Humming) helm of Justice
(  2) Eyes of Seduction
      the Royal Armor of Tear
      (Humming) crimson dagger
      (Glowing) (Humming) Raven's Cry
      The Royal Cape of Tear
      thigh-high boots
      a bloody flail
      (Glowing) (Humming) a western wood mace
      (Glowing) (Humming) a red mace
      (Glowing) (Humming) a massive spear named "Bloodseeker"
      (Glowing) (Humming) Piercing Pin 
      ThunderStrike
      Funky Ring
      FaithKiller
[Hit Return to continue]


You are thirsty. Got Milk?
You are hungry. You need food badly.
[Hit Return to continue]
      a Bag of Holding
      Indian Blanket

<903/903hp 544/544m 430/854mv 179175/825xp>


Here's your script you posted. I did get the starting line redone to trigger the script, but the "if not" line for checking if it is still in the inventory list needs allot more work. I ended up using " if not string.match (line, "^..... ") then " to match the items in the inventory, and it also grabs the items that have more than one, but it doesn't go through the prompt to continue the inventory (being a longer list), grab through the prompt, and ignore messages like "you are hungry/thirsty" for the output window.


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 (Carry: */*, Weight: */*):", 10)

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 ("*")

  -- see if 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 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  "yellow")

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


How would I go about triggering it so it'll match everything in the list through the continue prompt, and ignore adding the prompt to continue and the "you are hungry/thirsty" messages in the output to the miniwindow? I do my best to try to figure it out myself before posting but I'm at a loss as to how to continue. Any help would be greatful!
Top

Posted by Tiredchris   (17 posts)  Bio
Date Reply #1 on Tue 30 Mar 2010 02:50 PM (UTC)
Message
Do you think I would need a trigger instead of an alias to grab between prompts? I guess then find a way to remove the extras thats not inventory, and send the variables to the miniwindow? I'm just wondering if that would be easier.
Top

Posted by Nick Gammon   Australia  (23,121 posts)  Bio   Forum Administrator
Date Reply #2 on Wed 31 Mar 2010 04:13 AM (UTC)
Message
I would configure my pager length to disable paging. Having "[Hit Return to continue]" in the middle is totally going to throw it out.

- Nick Gammon

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

Posted by Tiredchris   (17 posts)  Bio
Date Reply #3 on Mon 03 May 2010 11:24 PM (UTC)
Message
That worked like a charm. Thanks Nick!
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.


12,949 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.