Ada said: A trigger either matches or not matches. The compile error you're getting means it -is- matching in both cases but the associated script is not in working order. Can you paste the triggers and the text they're supposed to match here please?
To answer your second question first, 'health' or 'hea' is a game command.
>help health
The "health" command will let you see how many hit points you have left and
what your maximum hit point amount is. If you are of a magical class, it will
show your spell points and your spell point maximum. You will also be told how
many minutes you have left to eat food before you begin to starve to death.
And, if you are diseased, it will let you know that too. Type: health or hea.
The normal output for 'hea' looks like this:
You have 95/96 hitpoints and 38/38 spellpoints.
You are middle-aged.
You will need to eat within 11 minutes.
I use that first line as a trigger to do a simple math calculation so that I will automatically drink a flask (which restores full health) when my health drops below a certain point.
Whenever a mob hits me, it sets off a trigger that automatically does this: Send ("health")
For example ... >The imp hits you for 15 hps!
That automatically triggers Send ("health")
Then I have this trigger:
^You have (.*?)\/(.*?) hitpoints(.*?)$|^>You have (.*?)\/(.*?) hitpoints(.*?)$
As you can see, that is simply evaluating what comes from the "health" command (which again, is a game command.)
This is the point where it dies if I use this as the trigger instead:
^(\>)?You have (.*?)\/(.*?) hitpoints(.*?)$
And Nick's idea of using this as the trigger:
^\>?You have (.*?)\/(.*?) hitpoints(.*?)$
...solves it as well. So for some reason, it doesn't like those parenthesis. I don't understand regular expressions well enough to know why that's the case.
So ... for the curiously minded, moving on with the flow...
The code in that trigger is:
if (%1 < (%2 * .3)) then
EnableTrigger("FlaskEmergency", true)
Send ("drink flask")
elseif (%1 < (%2 * .5)) then
ColourNote ("black", "red", "Health is %1")
elseif (%1 < (%2 * .6)) then
ColourNote ("black", "orange", "Health is %1")
elseif (%1 < (%2 * .7)) then
ColourNote ("white", "green", "Health is %1")
else
ColourNote ("white", "blue", "Health is %1")
end
EDIT: I think I just figured it out. Something Nick said. He said "You don't need to make it a capture...."
So I think (and correct me if I'm wrong), but I think by having the trigger start with parenthesis, it's making my %1 and %2 variables screw up. In other words, %1 would need to become %2, and %2 would need to become %3. Is that right?
The code for the FlaskEmergency trigger is:
EnableTrigger("FlaskEmergency", false)
Execute ("countflasks")
EnableTrigger("FlaskEmergencyCount", true)
The countflasks alias does this:
EnableTrigger("InvStart", true)
Send ("inventory")
...that part is all worked out... You know what the InvStart/InvFull does because you wrote it.
So the FlaskEmergencyCount is looking for "pieces." as its trigger text.
And the whole point of this trigger is so our character can teleport to safety if he is out of flasks.
The code for the FlaskEmergencyCount is:
EnableTrigger("FlaskEmergencyCount", false)
if (flaskcount == 0) then
giveup = true
Send ("rub key")
EnableTrigger("TeleportSafetyCheck", true)
elseif (flaskcount == 1) then
ColourNote ("white", "red", "==========================")
ColourNote ("white", "red", "WARNING: 1 Flask Remaining")
ColourNote ("white", "red", "==========================")
end
Whew ... I think I covered everything.
The bottom line here is that one Regular Expression ... for reasons that I don't even begin to understand, one expression works, and the other completely bombs ... with compile errors. |