Quote:
I want to do is get the herb i am currently pick see what month its hibernation is ...
The easiest way of doing that is to rejig your table a bit. You had a table of tables, but to look up the month corresponding to a herb, this is simpler:
herbs = {
arnica = 'Klangiary',
calamus = 'Dioni',
chervil = 'Roarkian',
colewort = 'Kiani',
coltsfoot = 'Juliary',
faeleaf = 'Juliary',
flax = 'Estar',
galingale = 'Shanthin',
horehound = 'Vestia',
juniper = 'Dioni',
kafe = 'Urlachmar',
kombu = 'Dioni',
marjoram = 'Shanthin',
merbloom = 'Estar',
mistletoe = 'Avechary',
myrtle = 'Estar',
pennyroyal = 'Klangiary',
reishi = 'Tzarin',
rosehips = 'Shanthin',
sage = 'Dioni',
sargassum = 'Tzarin',
sparkleberry = 'Dvarsh',
weed = 'Estar',
wormwood = 'Vestia',
yarrow = 'Roarkian',
}
print (herbs.yarrow) -- Roarkian
See how in this case I simply put the herb name in, and get its month? In your case you might say:
foundherb = wildcs [2]
hibernate_month herbs [foundherb]
if month == hibernate_month then
Note("Hibernating")
else
-- blah blah
What might help you is the TraceOut function which is new to MUSHclient from version 3.68 onwards. This lets you put debugging stuff into your script, which only appears if you turn on Game -> Trace.
I have modified your existing script (I know it isn't working, but to show you the idea) to add some traces:
function do_pick (name, output, wildcs)
TraceOut "in do_pick"
table.foreach (wildcs,
function (k, v) TraceOut ("wildcard ", k, " = ", v) end )
TraceOut ("month = ", month)
TraceOut ("herb = ", herb)
for _, v in ipairs (herbs) do
if month == v.month then
Note("Hibernating")
else
if wildcs[2] == herb then
TraceOut ("we have ", wildcs[4], " of ", wildcs[2])
if tonumber (wildcs[4]) > 10 then
Send("pick ", herb)
else
Note("No more for you to pick.")
Send("inr all ", herb)
DoAfter(4, EnableTriggerGroup ("Herbs", false))
end
end
end
end
end
Now if we go to the Game menu and turn Trace on, and then find a herb, we see this:
TRACE: Matched trigger "^(.*) \((.*?)\) (.*?) left\.$"
TRACE: Executing trigger script "do_pick"
TRACE: in do_pick
TRACE: wildcard 1 = A sprig of chervil
TRACE: wildcard 2 = chervil
TRACE: wildcard 3 = 11
TRACE: wildcard 0 = A sprig of chervil (chervil) 11 left.
TRACE: month = nil
TRACE: herb = nil
However as soon as we turn Trace off, the spammy output goes away. So it is useful to have your debugging code there, until everything is working.
Here I am displaying the wildcard contents, and the values of 'month' and 'herb' so I can see what is going on. |