Not really that hard. Use a regular expression like:
^(master dagger|appraisal|smooth talk) \d+ \d+
Then just add new things into the () section as needed. This would hilight any one of the matching names and the two values after them.
You could also create a few aliases to add, remove and list them that call these subs (the trigger edit field gets crowded with more than a handful of match possibilities. lol):
sub Addskill(aname, output, wilds)
dim tcolor = 1 'Change this to the custom color you use.
dim Temp
Temp = GetTriggerInfo("SkillHlt", 1) 'Get match text.
dim p1, p2, T1, T2, T3
p1 = instr(Temp, "(")
p2 = instr(Temp, ")")
T1 = left(Temp, p1) 'Get the first bit.
T2 = mid(Temp, p1 + 1, p2 - p1 - 1) 'Get our list of skills.
T3 = right(Temp, len(Temp) - p2 + 1) 'Get the last bit.
dim fnd
fnd = 0
if T2 = "" then 'No skills, so just add it.
T2 = wilds(1)
else
dim Skills, count
Skills = split(T2,"|") 'Split into an array then check if already in list.
for count = 0 to ubound(Skills) 'Loop through all the skills we have in the list.
if Skills(count) = wilds(1) then
fnd = 1
end if
next
if fnd = 0 then
T2 = T2 + "|" + wilds(1)
else
world.colournote "red", "black", "That skill is already being tested for."
world.note " "
end if
end if
if fnd = 0 then
world.addtrigger "SkillHlt", T1 & T2 & T3, "", 1065, tcolor, 0, "", "", 0, 100
world.note wilds(1) & " added to hilight list."
world.note " "
end if
end sub
sub Remskill(aname, output, wilds)
dim tcolor = 1 'Change this to the custom color you use.
dim Temp
Temp = GetTriggerInfo("SkillHlt", 1)
dim p1, p2, T1, T2, T3
p1 = instr(Temp, "(")
p2 = instr(Temp, ")")
T1 = left(Temp, p1)
T2 = mid(Temp, p1 + 1, p2 - p1 - 1)
T3 = right(Temp, len(Temp) - p2 + 1)
if T2 > "" then
dim Skills, count, fnd
Skills = split(T2,"|")
fnd = 0
for count = 0 to ubound(Skills)
if Skills(count) <> wilds(1) then
if count > 0 then
T2 = T2 + "|" + Skills(count)
else
T2 = Skills(count)
end if
else
fnd = 1
end if
next
if fnd = 1 then
world.addtrigger "SkillHlt", T1 & T2 & T3, "", 1065, tcolor, 0, "", "", 0, 100
world.note wilds(1) & " successfully removed."
world.note " "
else
world.colournote "red", "black", wilds(1) & " not found in list."
world.note " "
end if
else
world.colournote "red", "black", "There are no skills to remove."
world.note " "
end if
end sub
sub ListHlt (aname, output, wilds)
Temp = GetTriggerInfo("SkillHlt", 1)
dim p1, p2, T1, T2, T3
p1 = instr(Temp, "(")
p2 = instr(Temp, ")")
T2 = mid(Temp, p1 + 1, p2 - p1 - 1)
if T2 = "" then
world.note "Nothing to list."
else
dim count, Skills
Skills = split(T2, "|")
for count = 0 to ubound(Skills)
world.tell Skills(count) & space(20 - len(Skills)
if (count + 1)/3 = int((count + 1)/3) then 'This gives us 3 skills per line when displayed.
world.note " "
end if
next
world.note " "
end sub
I haven't testing this, so there could be bugs in them. ;) They need to have the trigger added 'before' they will work, since they rely on T1 and T3 being taken from the trigger text. If you replaced those lines with T1 = "^(" and T3 = ") \d+ \d+" in the first sub then it 'may' in theory be able to create the trigger even if not already present, but I am not entirely certain.
In any case, you can match more than one possibility in a single trigger, having aliases to manage it is just a bit easier. ;) |