Posted by
| Nick Gammon
Australia (23,140 posts) Bio
Forum Administrator |
Message
| Well it would be more like this:
<triggers>
<trigger
group="wp_hide"
match="^(\d+)\) (.*)$"
name="poison_line"
omit_from_output="y"
regexp="y"
send_to="12"
sequence="100"
>
<send>
applied_poisons ["%2"] = true
</send>
</trigger>
<trigger
enabled="y"
group="wp_hide"
match="^.+ has the following poisons or magical effects on it:$"
omit_from_output="y"
regexp="y"
send_to="12"
sequence="100"
>
<send>
applied_poisons = {}
EnableTrigger ("poison_line", true)
EnableTrigger ("end_of_poisons", true)
</send>
</trigger>
<trigger
enabled="y"
group="wp_hide"
match="^Damage\: (.+) Precision\: (.+) Speed\: (.+)$"
omit_from_output="y"
regexp="y"
send_to="12"
sequence="100"
>
<send>
damage = "%1"
precision = "%2"
speed = "%3"
</send>
</trigger>
<trigger
enabled="y"
group="wp_hide"
match="^It is a (one|two)-handed weapon.$"
omit_from_output="y"
regexp="y"
send_to="12"
sequence="100"
>
<send>
weapon_type = "%1"
</send>
</trigger>
<trigger
group="wp_hide"
keep_evaluating="y"
match="*"
name="end_of_poisons"
send_to="12"
sequence="200"
>
<send>
EnableTrigger ("poison_line", false) -- disable poison line info
EnableTrigger ("end_of_poisons", false) -- disable self
for poison in pairs (applied_poisons) do
print ("You have applied", poison)
end -- for
print ("type=", weapon_type)
print ("damage= ", damage)
print ("precision= ", precision)
print ("speed= ", speed)</send>
</trigger>
</triggers>
As the stuff comes in, we remember it in the table applied_poisons (which we set to empty on the line "has the following poisons or magical effects on it").
Then the catch-all trigger fires when we run out of poison lines, and in my case just shows debugging information, eg.
You have applied saxitin
You have applied hadrudin
You have applied haemotox
type= one
damage= 33
precision= 235
speed= 211
Now what you would need to do is work out what you *want* applied, which you don't already have applied.
For example, with your table of all possible poisons:
poisons = {
"aleutian",
"anatine",
"anerod",
"botulinum",
"calcise",
"chansu",
"charybdon",
"contortrin",
"crotamine",
"dendroxin",
"dulak",
"escozul",
"hadrudin",
"haemotox",
"ibululu",
"inyoka",
"mactans",
"mantakaya",
"mellitin",
"morphite",
"niricol",
"pyrotoxin",
"saxitin",
"senso",
"tetrodin"
}
for i, name in ipairs (poisons) do
if not applied_poisons [name] then
print ("not applied:", name)
end -- if
end -- for
This shows:
not applied: aleutian
not applied: anatine
not applied: anerod
not applied: botulinum
not applied: calcise
not applied: chansu
not applied: charybdon
not applied: contortrin
not applied: crotamine
not applied: dendroxin
not applied: dulak
not applied: escozul
not applied: ibululu
not applied: inyoka
not applied: mactans
not applied: mantakaya
not applied: mellitin
not applied: morphite
not applied: niricol
not applied: pyrotoxin
not applied: senso
not applied: tetrodin
Now you probably can't apply all of those, so now the code needs to decide which ones to use (for example, put the list in order, and keep going until you have four poisons applied). |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|