Help With permSubstringTRigger.
Posted: Thu Oct 04, 2018 6:19 pm
I am trying to make a Trigger that gets names from a list of online players and makes a permanent trigger coloring each name. Not only do I want to color each name I also want the trigger to color each name based on their clan affiliation. I have got the trigger working but I am trying to improve it even further.
I am using exists statements to not make triggers of the same name multiple times.
Players can hide their clan. Obviously some players don't have a clan. I still want to color their names as well. The problem is if a player trigger is created with their clan hidden or if the player later becomes clanned the color highlighting will remain the same after they are clanned or reveal their clan.
The "Who list" in my game looks like this
Players
-------
Sati the Sentry [Civil Watch]
Chuker The Cartographer
Karrock of Shienar
Originator of Kandor
Ysidoriusz Duchovny, the Kandori Merchant (Idle)
Reyne Verenhald [Blue Ajah]
Jansen Algardis [Civil Watch]
Faerin of Kandor
Sarioc of Kandor
Lord Akiran the Captain of the Wall [Wall Guard]
Akiban of Arafel (Idle)
11 players displayed.
With clans always being surrounded by brackets [ ].
I also don't want to highlight every instance of each players name only certain situations as some player names can be part of other words or shortened versions of existing names.
So to deal with this I have created parent triggers with the situations I want the names to be highlighted which are the clans. The child triggers are the player names themselves. (see image trigger test)
This is an example of the code I use to define clan color and parent trigger name
Then I use this code to make the trigger
And this is the code I use to keep the trigger open and create triggers for unclanned players
So my question is how do I go about automatically getting rid of unclanned triggers when a player reveals their clan or is clanned while still keeping the clanned triggers for when a player hides thier clan.
I am using exists statements to not make triggers of the same name multiple times.
Players can hide their clan. Obviously some players don't have a clan. I still want to color their names as well. The problem is if a player trigger is created with their clan hidden or if the player later becomes clanned the color highlighting will remain the same after they are clanned or reveal their clan.
The "Who list" in my game looks like this
Players
-------
Sati the Sentry [Civil Watch]
Chuker The Cartographer
Karrock of Shienar
Originator of Kandor
Ysidoriusz Duchovny, the Kandori Merchant (Idle)
Reyne Verenhald [Blue Ajah]
Jansen Algardis [Civil Watch]
Faerin of Kandor
Sarioc of Kandor
Lord Akiran the Captain of the Wall [Wall Guard]
Akiban of Arafel (Idle)
11 players displayed.
With clans always being surrounded by brackets [ ].
I also don't want to highlight every instance of each players name only certain situations as some player names can be part of other words or shortened versions of existing names.
So to deal with this I have created parent triggers with the situations I want the names to be highlighted which are the clans. The child triggers are the player names themselves. (see image trigger test)
This is an example of the code I use to define clan color and parent trigger name
Code: Select all
if string.find(matches[2],"Lion Warden") then
parentname = ("Lion Warden")
fgclancolor = ("aaff7f")
bgclancolor = ("000000")
elseif string.find(matches[2],"Ghar'gheal") then
parentname = ("DS Players")
fgclancolor = ("aa0000")
bgclancolor = ("000000")
elseif string.find(matches[2],"Valon Guard") then
parentname = ("Valon Guard")
fgclancolor = ("00aa00")
bgclancolor = ("000000")
elseif string.find(matches[2],"Imperial Army") then
parentname = ("Seanchan")
fgclancolor = ("aa55ff")
bgclancolor = ("000000")
Code: Select all
local names = matches[2]
if exists(names.."","trigger") == 0 then
permSubstringTrigger (names .."",parentname.."",{names..""},
[[
selectCaptureGroup(1)
setHexBgColor"]]..bgclancolor..[["
setHexFgColor"]]..fgclancolor..[["
]])
cecho("<green> New Name!!")
end
enableTrigger(names.."")
parentname = nil
Code: Select all
local names = matches[2]
if string.find (line, " Players") or string.find (line, " -------") then
setTriggerStayOpen("Who (Name Triggers)", 1) else
if not string.find ("players displayed.") then
setTriggerStayOpen("Who (Name Triggers)", 1)
end
end
if not parentnames and
exists (names.."","trigger") == 0 then
permSubstringTrigger (names .."","Unclanned",{names..""},
[[
selectCaptureGroup(1)
setHexBgColor("000000")
setHexFgColor("aaaa7f")
]])
cecho("<green> New Name!!")
end
enableTrigger(names.."")