|
Chris_3413 Novice
Joined: 22 Mar 2004 Posts: 46 Location: Australia
|
Posted: Mon Jan 11, 2010 2:02 pm
String lists and triggers |
What I would like to know is, is it at all possible to somehow create a trigger (using zScript if possible) that uses a string list variable as part of a pattern or can be compared to a string list.
Specifically what I am attempting to do is store a list of the names of enemies in a string list(that bit is easy) and then use a trigger to highlight those names when I check whos online with a QW command.
The Mud in question is MKO but this would apply to any IRE mud or one with similar output.
an example of the output is as follows:
Kinuma, Saiellah, Skyanne, Jessamin, Wyrthe, Drakith, Shadryn, Aurelen, Camenae,
Iaocal, Raki, Alexander, Zjorn, Mara, Vaerom, Meradin, Merou, Aeonex, Luthian,
Larraleigh, Audriana, Akaryu, Markir, Khyvar, Zengor, Grin, Aelryl, Mikkel,
Eldin, Elvearae, Drue, Tyrad, Beligan, Arashi, Lilah, Gryndal, Mos, Omny,
Aranion, Aulle.
Currently i'm using a separate trigger for every enemy name but this is rather cumbersome to update as time goes on |
|
_________________ What do you mean, Fatal Error! |
|
|
|
Dumas Enchanter
Joined: 11 Feb 2003 Posts: 511 Location: USA
|
Posted: Mon Jan 11, 2010 3:00 pm |
I'm working on converting something Larkin did before to work with MKO. The problem is that, for example, they have a triggerable phrase that leads off the enemy list. MKO doesn't.
|
|
|
|
gamma_ray Magician
Joined: 17 Apr 2005 Posts: 496
|
Posted: Mon Jan 11, 2010 3:22 pm |
Simple version:
Code: |
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
<trigger priority="1230" case="true" regex="true" copy="yes">
<pattern>\b(@enemies)\b</pattern>
<value>#cw red</value>
</trigger>
</cmud>
|
Where @enemies is a stringlist of your enemies. Note that these need to be full names, proper case (if you add "Al" as an enemy, it won't highlight "Allison"). If this gets too slow for you in normal use (for example if you have too many enemies), try:
Code: |
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
<class name="highlighting" enabled="false" copy="yes">
<trigger priority="1230" case="true" regex="true" copy="yes">
<pattern>\b(@enemies)\b</pattern>
<value>#cw red</value>
</trigger>
<trigger priority="1260" copy="yes">
<pattern>.</pattern>
<value>#t- highlighting</value>
</trigger>
</class>
<trigger type="Command Input" priority="1250" copy="yes">
<pattern>bw</pattern>
<value>#t+ highlighting</value>
</trigger>
</cmud> |
This will only highlight in bw, it's pretty simple to change it to add bwho, qw, who, etc.
And as I'm guessing you've already found, the easiest way to add enemies to the list is to keep track of them while you add them. |
|
Last edited by gamma_ray on Wed Jan 13, 2010 10:56 am; edited 1 time in total |
|
|
|
Dumas Enchanter
Joined: 11 Feb 2003 Posts: 511 Location: USA
|
Posted: Mon Jan 11, 2010 3:34 pm |
Bleh, I was speaking more of pulling city enemies for highlighting. If you meant personal enemies then adding to your string list is, as you said, easy.
So, to expound on this, this is what you get in MKO for city enemies.
Code: |
Beird, Xadre, Malapardis, Nehemiah, Bakaris, Anarion, Evanna, Dinensul, Mithryn,
Tonni, Mithonduir, Silvenae, Keijima, Valthnar, Nhudri, Lemuria, Gerabalde,
Traea, Devlin, Drongon, Rollan, Tanssko, Raki, Temig, Muza, Uleth, Aeonex,
Shikomiru, Bakstabba, Joao, Deorai, Edrik, Uuazxkuu, Albaster, Eidh, Naran,
Gareth, Amadan, Vaxmo, Tora, Volshek, Messora, Amanita, Luxi, Lilin, Grendel,
Khyvar, Radakail, Ashurmannus, Sethysia, Mara, Garnuk.
There are 52 enemies of Krondor.
52 are permanent enemies, while 0 are temporarily banished. |
Right now using a simple ^(*)$ trigger that does the following (will be making changes to get the thing to disable)
Code: |
#if (%regex(%1, "\d")) {#STATE ce_capture 0;#var CityEnemies {%subregex(@CityEnemies, "[^\w]+", "|")}} {#var CityEnemies {%concat( @CityEnemies, "%1")};#state ce_capture 1} |
Here is the crux so far. It is capturing the prompt before I enter the alias to clear the list and send the command (but not adding any of it to the list), the first line of names isn't added, and the line with "There are 52 enemies of Krondor" is being added to the list (despite containing a number) |
|
|
|
Dumas Enchanter
Joined: 11 Feb 2003 Posts: 511 Location: USA
|
Posted: Mon Jan 11, 2010 3:50 pm |
hmm, it was the "%1" that was killing the first line for some reason. Also took out it keeping the line with the the number of enemies.
|
|
|
|
gamma_ray Magician
Joined: 17 Apr 2005 Posts: 496
|
Posted: Mon Jan 11, 2010 7:38 pm |
Well he does say
Quote: |
store a list of the names of enemies in a string list(that bit is easy) |
Code: |
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
<trigger type="Command Input" priority="1310" regex="true" copy="yes">
<pattern>^cityenemies$</pattern>
<value>city_enemies = %null</value>
<trigger type="Within Lines" param="5" case="true" regex="true">
<pattern>^(?:[A-Z][a-z]+, )+(?:[A-Z][a-z]+)(?:,|.) ?$</pattern>
<value>#t+ parse_city_enemies</value>
</trigger>
</trigger>
<trigger type="Within Lines" param="5" case="true" regex="true" copy="yes">
<pattern>^(?:[A-Z][a-z]+, )+(?:[A-Z][a-z]+)(?:,|.) ?$</pattern>
<value>#t+ parse_city_enemies</value>
</trigger>
<class name="parse_city_enemies" enabled="false" copy="yes">
<trigger priority="1370" case="true" repeat="true" regex="true" copy="yes">
<pattern>\b(\w+)\b</pattern>
<value>#additem city_enemies %1</value>
</trigger>
<trigger priority="1390" copy="yes">
<pattern>.</pattern>
<value>#t- parse_city_enemies</value>
</trigger>
</class>
</cmud>
|
|
|
|
|
Chris_3413 Novice
Joined: 22 Mar 2004 Posts: 46 Location: Australia
|
Posted: Mon Jan 11, 2010 11:51 pm |
Thanks everyone for the responses, I probably should have been clearer and said ive already got the stringlist sorted out and just needed some way to trigger off its contents.
gamma_ray's first response seems to have hit the nail on the head for what i was trying to do .. I use his second suggestion as this is more or less for city enemies which will no doubt be quite numerous eventually and it seems to be working fine. |
|
_________________ What do you mean, Fatal Error! |
|
|
|
gamma_ray Magician
Joined: 17 Apr 2005 Posts: 496
|
Posted: Tue Jan 12, 2010 12:17 am |
Her's. :) Glad I could help.
|
|
|
|
Dumas Enchanter
Joined: 11 Feb 2003 Posts: 511 Location: USA
|
Posted: Wed Jan 13, 2010 4:11 am |
heh, I decided to work some more to mark city members in my list. The problem is, the above highlight trigger doesn't match on whole words only. So, for example, Bakaris is a city enemy. Bak is a citizen. I get "Bak" in one color and "aris" in the other. Any way to make the highlight only if it matches the whole name in the trigger and nothing but the name?
|
|
|
|
nexela Wizard
Joined: 15 Jan 2002 Posts: 1644 Location: USA
|
Posted: Wed Jan 13, 2010 9:06 am |
The trigger for highlighting city enemies needs to surrounded by %b (or \b if using regex)
#TRIGGER {%b{@City_Enemies}%b} {#CW Red}
or some such |
|
|
|
gamma_ray Magician
Joined: 17 Apr 2005 Posts: 496
|
Posted: Wed Jan 13, 2010 10:56 am |
I did use \b, what I forgot to use were the parentheses, so it was only associating \b with the beginning of the first name and end of the last name... Bleh. I fixed the patterns in the original post.
|
|
|
|
fumi Beginner
Joined: 27 May 2015 Posts: 10
|
Posted: Fri Oct 02, 2015 10:43 am |
Sorry for jumping in, or if this should be a new thread. I am at the point of being able to trigger off of a %b{@monsters}%b, but now I would like to extract the exact item in the list that triggered. For example if item 5 triggered, then I would like to use item 5's contents to say "kill @monster(item5)" or what not. Is this possible, and if so, could someone shed some light please? Many thanks!
|
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4690 Location: Pensacola, FL, USA
|
Posted: Fri Oct 02, 2015 5:59 pm |
Better to start a new thread usually, but this is a quick one, wrap it in parenthesis
#TR {%b({@monsters})%b} {kill %1) |
|
_________________ Discord: Shalimarwildcat |
|
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|