Help With permSubstringTRigger.

Post Reply
OGslinkyT
Posts: 15
Joined: Thu Sep 06, 2018 5:26 am

Help With permSubstringTRigger.

Post by OGslinkyT »

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

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")
Then I use this code to make the trigger

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
And this is the code I use to keep the trigger open and create triggers for unclanned players

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.."")
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.
Attachments
Trigger Test.png

User avatar
Vadi
Posts: 5035
Joined: Sat Mar 14, 2009 3:13 pm

Re: Help With permSubstringTRigger.

Post by Vadi »

Use temp triggers, then you can delete them as necessary.

OGslinkyT
Posts: 15
Joined: Thu Sep 06, 2018 5:26 am

Re: Help With permSubstringTRigger.

Post by OGslinkyT »

I am really having a struggle with temp triggers.

for some reason I can't get them to work at all
there must be something wrong with my syntax it's probably something simple.

I feel like I am formatting like the examples on the wiki but I never can get the triggers to fire after creation.
temptrigger.png
temptrigger.png (10.7 KiB) Viewed 6374 times

Jor'Mox
Posts: 1142
Joined: Wed Apr 03, 2013 2:19 am

Re: Help With permSubstringTRigger.

Post by Jor'Mox »

You have two different problems in that example. The first is just that your patterns are wrong. You have +. instead of .+, which will make the difference between worthless and working. The second problem is that while contained within normal quotes, you need to escape the backslashes you use, or they are interpreted before they become part of the pattern. So in this instance, you either need to wrap your pattern in double square brackets, or you need to use \\. to match the period in the line.

OGslinkyT
Posts: 15
Joined: Thu Sep 06, 2018 5:26 am

Re: Help With permSubstringTRigger.

Post by OGslinkyT »

That was it.
This stuff makes me feel so dumb sometimes.

Thank you for the quick reply.

The next question is how to deal with parent child relationships with temp triggers.

in the example above I have 17 different situations in which I want the highlight trigger to fire.
With the permanent triggers I simply made a parent with the 17 different matches and a child with the sub-string that I wanted highlighted upon matching.

This prevents false matches such as mobs leaving rooms and gives me control on specific colors for each sub-string match.

even with the tempComplexRegexTrigger option I don't see a way to create a parent child relationship. I am sure there is another way to achieve this but I have been unable to think of it.

Jor'Mox
Posts: 1142
Joined: Wed Apr 03, 2013 2:19 am

Re: Help With permSubstringTRigger.

Post by Jor'Mox »

There is no way to have temp triggers work as parents or children, so you can stop looking now. That said, you can use complex temp triggers with multiple patterns to work in a similar way. The concept of an "AND" trigger means that all patterns have to match for it to work, and if the line delta value for the trigger is 0, all patterns have to match in one line. So in that way, you can have your specific substrings you care about but that need to have their input restricted, and then restricting patterns themselves as part of the same trigger. An alternative strategy if you have a large number of substrings that all need to be filtered through the same restricting pattern, is to make a trigger with just the restricting pattern, and then check for the substrings in code within that trigger (i.e. it calls a function that loops through your substrings to see if any of them match, and does whatever needs to be done if that happens).

OGslinkyT
Posts: 15
Joined: Thu Sep 06, 2018 5:26 am

Re: Help With permSubstringTRigger.

Post by OGslinkyT »

Also I am running into a problem with tempComplexRegexTrigger

it names the trigger the regex code rather than using the name field
temptrigger.png
temptrigger.png (4.72 KiB) Viewed 6366 times
once again what am I doing wrong

Jor'Mox
Posts: 1142
Joined: Wed Apr 03, 2013 2:19 am

Re: Help With permSubstringTRigger.

Post by Jor'Mox »

I'll be honest, I don't really use complex triggers, because they weren't around when I was learning to make things happen. So, it is quite possible either that they are completely messed up, or just that the pattern and name argument positions are switched for some reason. Either way, I would recommend making a bug report.

User avatar
SlySven
Posts: 1019
Joined: Mon Mar 04, 2013 3:40 pm
Location: Deepest Wiltshire, UK
Discord: SlySven#2703

Re: Help With permSubstringTRigger.

Post by SlySven »

Are you playing on WoTMUD - by any chance? ;)

Jomin al'Bara, Tower Accepted [White Tower]

Post Reply