[Home] [Downloads] [Search] [Help/forum]

Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Miniwindows
. . -> [Subject]  Inventory Capture Problem with detecting my Prompt

Inventory Capture Problem with detecting my Prompt

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

Posted by Carsinix   (8 posts)  [Biography] bio
Date Thu 31 Jul 2014 08:06 PM (UTC)
So I have been following Nick Gammons guide on making an inventory capture to a miniwindow and I can not get it to detect my prompt to end the capture

Here is what my inventory list displays as
[You are carrying 4 of 41 items]
[You have a total weight of 633/1260]
a Transporter device
a juicy apple
a bottle of cod liver oil
a Dark Void

4742H 98310M 45075V (100) Can Now RemortTNL Level: 50 [Inside] [Day]->

And here is my code

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 * of * items] " , 10)

if not x then
	ColourNote ("white", "blue", "No Inventory")
	end -- if
	local inv = {}
	local max_width = WindowTextWidth (win, font, "Inventory")
	-- loop untinl end of inventory

while true do
	local line, wildcards, styles = wait.match ("*")
	-- see if end of inventory
	if string.match (line, "(\d+)H (\d+)M (\d+)V \(\d+\) .+ [\w+]\-\>") then
	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

require "tprint"

tprint (inv)

end) -- end of coroutine

If I change it so it ends at (a Dark Void) it works correctly.

so im not sure what im doing wrong here. Is it possible to have it end at the blank line before my prompt?

I checked my regexp converstion of my prompt at regexr.com and it detects the prompt. Ive even tried adding ^ to the start. any help would be much appreciated.

Also i dont even get a fail message when I have my prompt in there.
[Go to top] top

Posted by Carsinix   (8 posts)  [Biography] bio
Date Reply #1 on Thu 31 Jul 2014 10:03 PM (UTC)
Well I figured a work around, but i would still like to know why it wont trigger off the prompt. I can run a trigger and my trigger fires, but this alias isint working with it.

My work around is just changing

 if string.match (line, "(\d+)H (\d+)M (\d+)V \(\d+\) .+ [\w+]\-\>") then
	end -- if


if not string.match (line, "[A-Za-z0-9]") then
end -- if
[Go to top] top

Posted by Shadowfyr   USA  (1,786 posts)  [Biography] bio
Date Reply #2 on Thu 31 Jul 2014 10:05 PM (UTC)
Uh. Been a while, but.. at the end of your prompt you have:


But your regex says '[\w+]\-\>', which translates to "any letter or _ followed by ->", right? So, it will never match on your [Day] or [Inside] parts. Or, that would be my guess at least. You would need to either remove the [\w+], in which case it would just not care, I think, if the other stuff is in there, or, either "[\[\w+\]][\[\w+\]]\-\>", for exactly two such bracketed things, or, to be more clever "[\[\w+\]]{0,2}\-\>", which would, unless I am way too rusty, give you "between 0 and 2" bracketed items (on the chance the prompt might, in some cases, be missing them.
[Go to top] top

Posted by Nick Gammon   Australia  (23,003 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Fri 01 Aug 2014 03:14 AM (UTC)

if string.match (line, "(\d+)H (\d+)M (\d+)V \(\d+\) .+ [\w+]\-\>") then

But this is a PCRE-style regular expression, not a Lua one.

Lua regular expressions use somewhat different syntax, as described here:


In particular, to match digits you use %d not \d. Similarly for \w.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] 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.


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

Go to topic:           Search the forum

[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]