... it matches on the ginseng entry, but not on the goldenseal entry ...
The real problem here is that the trigger processing optimizes certain things. In particular, "repeat on same line" is intended for colouring multiple words. If you set a "change colour", like this you will see it:
You can see from that, that it does indeed match twice when expected.
However, and this is what is catching your script, it then calls the script once, per line. Thus the script is called for the first match only.
The good news is that there is a fairly simple way around this.
To do this you will need a script file (not just "send to script"), which I am guessing you have from the way you call do_stuff ().
Next you need to change your trigger slightly to call a script function by name, rather than the way you did, like this:
match="\[ *(\d+)\] (ginseng root|valerian|goldenseal root|myrrh gum)"
I also gave it a name, for reasons that will become apparent (the name "herb_trigger").
Now inside the script file we need to reprocess that line, using the PCRE regexp handler, built into the Lua script. This is an exact copy of the one that MUSHclient uses, and thus we can pass to it the same regular expression from the trigger.
To allow for future enhancement, I pull the regexp directly from the trigger itself.
Here is the script:
function herb_trigger_script (name, line, wildcards)
-- function to handle individual matches
local function one_herb (m, t)
print ("count", t )
print ("herb", t )
end -- one_herb
local re = rex.new (GetTriggerInfo (name, 1)) -- get the match text, make into a regexp
re:gmatch (line, one_herb) -- match repeatedly, call function
end -- herb_trigger_script
What this does is use re:gmatch to re-match on the trigger line, calling the function one_herb for each match. Then you can do whatever you want with the match. The function one_herb is passed a table of substrings (t), out of which I extract the count and herb name.
You could optimize this slightly by moving the call to rex.new out of the function, and simply pass the name of the trigger to it, to save compiling the regular expression every time, but it might not make much difference.
My output was:
[ 11] bayberry bark [ 7] bellwort flower [ 10] black cohosh
[ 80] bloodroot leaf [ 8] blueberry [ 39] echinacea
[ 15] ginseng root [ 16] goldenseal root [ 8] hawthorn berry
herb ginseng root
herb goldenseal root
[ 14] irid moss [ 18] kelp [ 14] kola nut
[ 200] kuzu root [ 498] lady's slipper [ 10] leather
[ 30] lobelia seed [ 16] myrrh gum [ 3] piece of stag's
herb myrrh gum
[ 101] prickly ash bark [ 11] prickly pear [ 11] sileris
[ 11] skullcap [ 10] slippery elm [ 237] valerian
[ 54] venom sac [ 2] yellow ink
Some triggers can get unbelievably complex due to this and until recently there was no way to "get" the wildcards over a certain number, so you have to compromise.
My solution above shows how you can achieve this without too much complexity.