This is what I use.
CODE
<triggers>
<trigger
enabled="y"
group="enemies"
lines_to_match="2"
keep_evaluating="y"
match="^Enemies of (.*)\:\n(.+)\Z"
multi_line="y"
regexp="y"
send_to="12"
sequence="100"
>
<send>enemies = enemies or {}
local temporg = data.orgs.rev["%1"]
if temporg then
local tempvar = {
name = "e" .. temporg,
data = string.gsub ("%2", ", ", "|"),
}
SetVariable (tempvar.name, tempvar.data)
enemies[temporg] = utils.split (tempvar.data, "|")
end -- if</send>
</trigger>
</triggers>
With this in my script file:
CODE
data = {
orgs = {
city = "Ashtan",
house = "the Merchants",
order = "the Order of the Moon",
citylong = "the City of Ashtan",
houselong = "the Merchants of the Crown",
orderlong = "the Divine Order of Ourania, Goddess of the Moon",
rev = {
["the City of Ashtan"] = "city",
["the Merchants of the Crown"] = "house",
["the Divine Order of Ourania, Goddess of the Moon"] = "order",
},
},
}
It lists enemies in a MUSHclient table called enemies, with the key as the org type (city/house/order) and the value a numerically indexed table of names. It also creates a MUSHclient variable, vertical-bar delimited, for use in regex highlighting. I also use this script to check enemy partial names, or see what all orgs of mine a specific enemy is:
Aliases:
CODE
<aliases>
<alias
match="^ce (\w+)$"
enabled="y"
group="enemies"
regexp="y"
send_to="12"
ignore_case="y"
sequence="100"
>
<send>enemies.match (string.lower("%1"))</send>
</alias>
<alias
match="^cep (\w+)$"
enabled="y"
group="enemies"
regexp="y"
send_to="12"
ignore_case="y"
sequence="100"
>
<send>enemies.partialmatch (string.lower("%1"))</send>
</alias>
</aliases>
Script:
CODE
-- =============
-- enemy check
-- =============
enemies = {
city = utils.split (GetVariable("ecity") or "", "|"),
house = utils.split (GetVariable("ehouse") or "", "|"),
order = utils.split (GetVariable("eorder") or "", "|"),
match = function (name)
AnsiNote (ansicolor(7), "Searching for ",
ansicolor(15), name,
ansicolor(7), " in enemy database.")
local found = {
city = enemies.search (name, "city"),
house = enemies.search (name, "house"),
order = enemies.search (name, "order"),
}
if not (found.city or found.house or found.order) then
AnsiNote (ansicolor(15), name,
ansicolor(7), " not found.")
end -- if
prompt.draw ()
end, -- func
search = function (name, org)
local found = false
for k, v in ipairs (enemies[org]) do
if string.lower (name) == string.lower (v) then
found = true
AnsiNote (ansicolor(15), v,
ansicolor(9), " is an enemy of " .. data.orgs[org] .. ".")
end -- if
end -- for
return found
end, -- func
partialmatch = function (name)
AnsiNote (ansicolor(7), "Searching for names matching ",
ansicolor(15), name,
ansicolor(7), " in enemy database.")
local found = {
city = enemies.partialsearch (name, "city"),
house = enemies.partialsearch (name, "house"),
order = enemies.partialsearch (name, "order"),
}
found.total = found.city + found.house + found.order
AnsiNote (ansicolor(15), found.total,
ansicolor(7), " names matching ",
ansicolor(15), name,
ansicolor(7), " found. ")
prompt.draw ()
end, -- func
partialsearch = function (name, org)
local found = 0
for k, v in ipairs (enemies[org]) do
if string.match(string.lower(v), name) then
found = found + 1
AnsiNote (ansicolor(15), v,
ansicolor(9), " is an enemy of " .. data.orgs[org] .. ".")
end -- if
end -- for
return found
end, -- func
}
Note: it uses prompt.draw to draw a prompt, and ansicolor to get the color. You can find both in most of my plugins.