I think I'm getting stuck in a infinite loop or something, as MUSHclient keeps crashing on me when I get into a certain mode.. It happens whenever I try to cure an affliction (the curePrompt-function below). All seems to be running as it should, but MC still crashes.. Tried to include some failsafes, to make the cure only being sent once. Here's the functions involved in the crash, somewhat stripped to keep the thread sane.
function curePrompt (name, line, wildcards)
curing = 0
attacked = 0
if (canEat () > 0 and haha ~= 1) then
if aff['paralysis'] ~= nil then
haha = 1
cureHerb ("maidenhair", "emh")
elseif aff['clumsiness'] ~= nil then
haha = 1
cureHerb ("kelp", "eke")
end
else
debugNote ("Cannot eat!")
end
end
function cureHerb (name, line, wildcards)
if line == "eww" then doHerb = "wormwood"
elseif line == "emh" then doHerb = "maidenhair"
end
Send ("outr " .. doHerb)
Send ("eat " .. doHerb)
end
function cureBLostHerb (name, line, wildcards)
if doHerb == wildcards['herb'] then
bHerb = 0
--doHerb = "none"
curing = 1
--EnableTimer("cureBLostHerb", true)
debugNote ("Lost herb balance")
else
debugNote ("Illusion catched, doHerb was " .. doHerb .. "!")
end
end
function cureBGotHerb (name, line, wildcards)
--EnableTimer("cureBLostHerb", false)
if bHerb > 0 then
debugNote ("Illusion catched, allready had herb balance!")
else
debugNote ("Got herb balance")
end
end
function affAdd (name, toxin)
if toxin ~= nil then
if attacked ~= nil then
aff[name] = "yes"
debugNote ("Added affliction: " .. name .. " (was attacked)")
else
debugNote ("Illusion catched, was not attacked")
end
else
aff[name] = "yes"
debugNote ("Added affliction: " .. name)
end
end
function affDel (name)
if curing ~= nil then
aff[name] = nil
debugNote ("Removed affliction: " .. name)
else
debugNote ("Illusion catched, no cured detected")
end
end
function cureAttacked (weapon)
-- Check for rebound and shield
attacked = 1;
debugNote ("Attack noted, toxins possible")
end
function canEat ()
if bHerb == 1 then
if doHerb == "none" then
if aff['anorexia'] ~= 2 then
return 1
end
end
end
return 0
end
And here's the triggers that calls those functions:
<triggers>
<trigger
enabled="y"
group="cxCuring"
keep_evaluating="y"
match="^H\:\d+ M\:\d+ E\:\d+ W\:\d+ \<eb\>"
regexp="y"
script="curePrompt"
sequence="100"
>
</trigger>
<trigger
enabled="y"
group="cxCuring"
keep_evaluating="y"
match="^You quickly eat (an?|some)( piece of)? (?P<herb>\w+)( (root|flower|seed|leaf|stem|berry))?\.$"
regexp="y"
script="cureBLostHerb"
sequence="100"
>
</trigger>
<trigger
enabled="y"
group="cxCuring"
keep_evaluating="y"
match="^You may eat another herb or plant\.$"
regexp="y"
script="cureBGotHerb"
sequence="100"
>
</trigger>
<trigger
enabled="y"
group="cxCuring"
keep_evaluating="y"
match="^You concentrate on purging your body of foreign toxins\.$"
regexp="y"
script="cureBLostPurge"
sequence="100"
>
</trigger>
<trigger
enabled="y"
group="cxCuring"
keep_evaluating="y"
match="^You have regained the ability to purge your body\.$"
regexp="y"
script="cureBGotPurge"
sequence="100"
>
</trigger>
<trigger
enabled="y"
group="cxCuring"
keep_evaluating="y"
match="^Terror takes hold\, as a numb sensation overcomes your body\.$"
regexp="y"
send_to="12"
sequence="100"
>
<send>affAdd("paralysis", true)</send>
</trigger>
<trigger
enabled="y"
group="cxCuring"
keep_evaluating="y"
match="^You stumble and it becomes very difficult to concentrate on your coordination\.$"
regexp="y"
send_to="12"
sequence="100"
>
<send>affAdd("clumsiness", true)</send>
</trigger>
<trigger
enabled="y"
group="cxCuring"
keep_evaluating="y"
match="^Your paralysis fades and you can move once more\.$"
regexp="y"
send_to="12"
sequence="100"
>
<send>affDel("paralysis")</send>
</trigger>
<trigger
enabled="y"
group="cxCuring"
keep_evaluating="y"
match="^You feel coordinated once more\.$"
regexp="y"
send_to="12"
sequence="100"
>
<send>affDel("clumsiness")</send>
</trigger>
<trigger
enabled="y"
group="cxCuring"
keep_evaluating="y"
match="^(\w+) pricks you twice in rapid succession with (his|her) dirk\.$"
regexp="y"
send_to="12"
sequence="100"
>
<send>cureAttacked(true)</send>
</trigger>
<trigger
enabled="y"
group="cxCuring"
keep_evaluating="y"
match="^With a lightning-quick motion\, (\w+) slashes you with .+\.$"
regexp="y"
send_to="12"
sequence="100"
>
<send>cureAttacked(true)</send>
</trigger>
</triggers>
What happens is that when I'm afflicted by clumsiness, for example, I send out the "outr wormwood;eat wormwood" and "(DEBUG) Cannot eat!" is outputted. I cannot see what's causing MC to crash! Someone else? |