Help with inventory miniwindow please

Posted by Tiredchris on Tue 30 Mar 2010 02:09 PM — 4 posts, 17,360 views.

#0
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!
#1
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.
Australia Forum Administrator #2
I would configure my pager length to disable paging. Having "[Hit Return to continue]" in the middle is totally going to throw it out.
#3
That worked like a charm. Thanks Nick!