This is untested, so use at your own risk. I would suggest, as a learning exercise, if it does have problems, you try to work through them using the tools Mudlet gives you, such as the error window and the debug output. If you have any further questions, I'll get back to you as time permits.
Trigger Pattern (regex):
Code: Select all
^.*(.)HP:(\d+)/(\d+) MA:(\d+)/(\d+) MV:(\d+)/(\d+) Gold:(\d+) W/A:(\d+) (\w+)\)>$
Script:
-- This is a trigger on your prompt. We collect all of the
-- useful data from the prompt. Currently, this data is just used
-- locally, but it would make more sense to store this in some
-- global table so it can be used outside of this trigger.
-- As an architectural practice, generally speaking, you want
-- to separate your data input (this trigger) from your logic
-- (the healing bit); however, for this simple, specific case,
-- this works.
local in_combat = matches[2] == "!"
-- Collect our stats, and turn them into numbers for
-- comparison later on.
local health_current = tonumber(matches[3])
local health_max = tonumber(matches[4])
local mana_current = tonumber(matches[5])
local mana_max = tonumber(matches[6])
local move_current = tonumber(matches[7])
local move_max = tonumber(matches[8])
local gold = tonumber(matches[9])
-- No idea what "W/A" means. You may want to rename this.
local wa = tonumber(matches[10])
local is_standing = matches[11] == "Standing"
-- Spam protection.
if not healing_trigger then
if (health_current / health_max) <= .75 then
-- This creates a temporary trigger so we know when the heal
-- was successful. This is to prevent spamming, since you
-- could potentially match the prompt conditions multiple
-- times just from the act of casting.
healing_trigger = tempExactMatchTrigger( "HEALING LINE",
function ()
killTrigger(healing_trigger)
end)
-- This is where we tell the MUD to cast heal.
send("cast heal self")
end if
end if
Try pasting that into a new trigger, open up your errors and/or debug output, and see what you get. It may be helpful to turn on highlighting to make sure everything is matching properly.
At the very least, this should be a good place to start.