Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Fragen
Newbie


Joined: 17 Oct 2008
Posts: 7
Location: WV

PostPosted: Sat Oct 18, 2008 12:29 am   

Enemies Script
 
Hi all, I'm using ZMud - I used to have a nice script to color the names of enemies (in Achaea) when I see them, and I see that there is a recent post about a similar issue, but this is a little different.

I've already figured out how to do the actual coloring of the names, what *I* need, is a way to automatically load the enemies list into my variables (ie - house enemies, city enemies)

Here is the problem.

My trigger line looks like this:

Enemies of the Sentinels of Nature:
enemy1, enemy2, enemy3, (and so on)

Now, I can get #additem to work just fine, as long as the string I want to capture is on the SAME LINE as the trigger line, but as you can see, this string falls on the SECOND line. How do I capture THAT and use #additem to put it into my variable? (@hems in this case)

Here is the code I wrote to add/delete my personal enemies:

Code:
#VAR enemy1

#VAR pems (stands for 'personal enemies' - duh)

#AL doenemy {#additem pems %selword;enemy %selword}

#AL undoenemy {enemy1=%item( @pems, 1);unenemy @enemy1;#delitem pems @enemy1;doenemy}

(I created 'speed menu' items for the commands - so I can just right click on a name)
#Menu {enemy} {#if {%numitems( @pems)>19} {undoenemy} {doenemy}}

#Menu {unenemy} {#delitem pems %selword;unenemy %selword}

#Trigger {{@pems}} {#cw orangered}


It's probably not the most 'elegant' code in the world, but it works and it's fast. So... there's my question, and 'contribution'. :)
Reply with quote
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: Sat Oct 18, 2008 3:43 am   
 
This isn't actually that hard, except for the variable length of the enemies line... I'm too tired to write it right now, and besides others here are better at this sort of trigger ;)
If I remember right though, this can't be done with normal zScript, you've gotta use a regex trigger. But I may be mistaken, like I said, I'll let someone else field this unless it isn't done when I check in at a time when I'm more lucid.
_________________
CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate
Reply with quote
Fragen
Newbie


Joined: 17 Oct 2008
Posts: 7
Location: WV

PostPosted: Sat Oct 18, 2008 2:37 pm   
 
Yeah, I'm sure it's a 'simple thing' I'm missing, but after struggling with it for DAYS now... (and scouring the internet without finding a solution that works), I figured I would just ask. lol ;) I tend to be pretty stubborn and like to figure things out for myself, but daggonit, there are so many 'variables' here (not in the coding sense) that I just can't seem to iron it out. Thanks for replying. Hopefully someone will help out.

And I hope it CAN be done with 'normal zScript'... I don't know the first thing about regex and I hate it when I don't understand my code!
Reply with quote
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: Sat Oct 18, 2008 9:22 pm   
 
Regex isn't hard, and only the pattern would need to be regex. I just don't have much experience with regex so I still have to look EVERYTHING up. ;)

Really this is right up Vij's alley, I'm surprised he hasn't jumped on it yet.
_________________
CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5187

PostPosted: Sat Oct 18, 2008 11:05 pm   
 
Hrm, I could swear I have written this script for someone else before.
Code:

#TRIGGER "HouseEnemy" {^Enemies of the Sentinels of Nature:$} {HEnemy=""}
#COND {} {#IF (%line) {HEnemy=%concat(@HEnemy,%line)} {#STATE HouseEnemy 3;#SET HouseEnemy 3 1}} {looplines|param=30}
#COND {} {#IF (%line) {HEnemy=%concat(@HEnemy,%line);#STATE HousEnemy 1} {#STATE HouseEnemy 3;#SET HouseEnemy 3 1}}
#COND {} {HEnemy=%subchar(@HEnemy,", ","|");Enemies=%dups(%concat(@PEms,"|",@CEnemy,"|",@HEnemy))} {manual}
Then you just duplicate it for the city list, and you end up with a single variable named Enemies that will have the full thing.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Fragen
Newbie


Joined: 17 Oct 2008
Posts: 7
Location: WV

PostPosted: Sun Oct 19, 2008 1:04 am   
 
*clap* Yay! Thanks! =D

I wouldn't be a bit surprised if you had written it before... but I couldn't find it, so thanks very much! It looks like all I need to do is swap HEnemy with hems to fill my hems variable with the House enemies. I actually want to keep my enemy lists separate (I'm considering using different colors... though it would be messy because they do overlap somewhat, or possibly making a trigger to notify me as to what 'lists' they are in... ANYway).

Oh, you're not using #additem anywhere! Ah, that's why the %dups line is in there. So, this can't be done with #additem then? Or it's too messy to do that way? Because it *seems* like it would be easier, but then I couldn't get it to work, so maybe not, but I also just thought my problem was in finding a way to get the #additem to pick up that second line after the trigger. Now I'm gonna go look up all that #state and #set stuff to see what you're doing. lol Thanks again!
Reply with quote
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: Sun Oct 19, 2008 3:21 am   
 
Geeze, and he didn't even need regex. But I had forgotten about the %line, so I'd not have been able to do it like that. Thanks Vij

Fragen, here is an example of what you'd probably want to do for each enemy. It also illustrates why you need the combined Enemies variable.
Code:
#CLASS {EnemyShow}
#VAR ESTemp {}
#TRIGGER {{@Enemies}} {
  #IF (%ismember( %line, @hem)) {#var ESTemp %concat( @ESTemp, "%ansi(bold,red)~{H~} ")}
  #IF (%ismember( %line, @cem)) {#var ESTemp %concat( @ESTemp, "%ansi(bold,magenta)~{C~} ")}
  #IF (%ismember( %line, @pem)) {#var ESTemp %concat( @ESTemp, "%ansi(bold,blue)~{P~} ")}
  #SUB {%line @ESTemp}
  #VAR ESTemp {}
  }
#CLASS 0


Here is my test script:
Code:
#CLASS {TestEn}
#ALIAS TestScript {
  #LOOP (%numitems( @Enemies)) {
    %item( @Enemies, %i)
    #WAIT 3000
    }
  }
#VAR Enemies {Mardok the Elementalist|Lucifer the Wanderer|Hellion von Thun|St. Eldemore|Henry Couger}
#VAR hem {Mardok the Elementalist|Hellion von Thun|St. Eldemore}
#VAR cem {Lucifer the Wanderer|Mardok the Elementalist|Henry Couger|St. Eldemore}
#VAR pem {Mardok the Elementalist|Henry Couger|Hellion von Thun}
#CLASS 0


And this is my output:
Quote:
Mardok the Elementalist {H} {C} {P}
Lucifer the Wanderer {C}
Hellion von Thun {H} {P}
St. Eldemore {H} {C}
Henry Couger {C} {P}
_________________
CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5187

PostPosted: Sun Oct 19, 2008 5:08 am   
 
The script I wrote was just for capturing the house enemies, and putting that into a conjuctive list. I didn't use #ADDITEM because it is would be quite processor intensive. The mud itself is already ensuring uniqueness and all that is required is properly formatting the data as a list. I did that using a low level trick in the %subchar.

You should create addittional triggers for your city enemies and personal enemies. Each should use a seperate variable, but combine into the conjuctive list. Ralgith is correct that reason to have a single full list is so that one trigger can be used to mark all kinds of enemies. I made some changes to his code that will improve performance slightly while increasing compatibility with CMud, should you decide to upgrade. I also put the different enemy flags right before the name instead of after.
Code:
#CLASS {EnemyShow}
#VAR ESTemp {} {}
#TRIGGER {%q({@Enemies})%q} {
  #CW orange
  ESTemp=""
  #IF (%ismember( %1, @hem)) {ESTemp=%concat( @ESTemp, %ansi(bold,red),"{H}")}
  #IF (%ismember( %1, @cem)) {ESTemp=%concat( @ESTemp, %ansi(bold,magenta),"{C}")}
  #IF (%ismember( %1, @pem)) {ESTemp=%concat( @ESTemp, %ansi(bold,blue),"{P}")}
  #PSUB {@ESTemp} %word(%x1,1) -1
  }
#CLASS 0
Your existing code with #ADDITEM is good for setting your personal enemies. Another reason to keep the full list around is that when you take action against someone they are likely to remember it. Even if you remove them from your personal enemies list you should probably keep thier name in some list to highlight the possibilty that they may be aggressive towards you.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Fragen
Newbie


Joined: 17 Oct 2008
Posts: 7
Location: WV

PostPosted: Sun Oct 19, 2008 3:58 pm   
 
Thanks, that looks very nice! My one question about the way you're using the color/key is how that's going to look when an enemy's name isn't in a 'list'... well I guess I can just try it and take a walk into Mhaldor and find out. ;) bahah
Reply with quote
Fragen
Newbie


Joined: 17 Oct 2008
Posts: 7
Location: WV

PostPosted: Sun Oct 19, 2008 4:23 pm   
 
Vijilante wrote:
Hrm, I could swear I have written this script for someone else before.


Embarassed

Well... I tried the script. The first time it ran, it did load my @hems variable with name1,name2,name3 which didn't work with my {@hems} color trigger.

I ran the trigger again, and the names were still loaded in @hems (still no coloring). Ran the trigger again and the names disappeared from @hems, and now will not load again. Confused

Correction: Ok, there was a double trigger in Zmud, causing the first to misfire. That's fixed now and the names are loading properly into @hems. BUT, the coloration isn't working, including the coloring script from here. It seems that my color script will only work with a string list name1|name2|name3 but this trigger loads @hems with name1,name2,name3

update again: If I load @Enemies with a single word 'name1', which is also in my @pems stringlist, and I remove the %q()%q from around your trigger line for colors, I get a colored {C} in my display, but the actual name is gagged. Not good! lol In fact, the entire line the name is in is gagged. Weird. Anyway, I'm still playing with it.
Reply with quote
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: Sat Oct 25, 2008 12:30 am   Vij, your trigger will not work to capture enemies with Achaea's Output Form
 
Here is the output form for City Enemies, and your trigger cannot capture this.

As you can see, sometimes the commas fall at the start of the next line. Also the trigger does not end in a blank line, so a failed #IF (%line) won't work.
Would #IF (%word(%line,1) != "Total:") work? Anyways, just hoping you can fix it ;)

Code:
Enemies of the City of Eleusis:
Luthius, Portis, Rinoa, Goliath, Alex, Elric, Eschereheye, Pegasus, Arabi,
Kragg, Kusaro, Ravirrh, Xzar, Kaevan, Sarid, Jarrel, Mandrab, Kalypso, Locus,
Lothiac, Fahwe, Caelan, Morrigu, Element, Istavan, Niggurath, Darknight, Tad,
Santar, Namine, Erikarn, Rukimoro, Shanada, Flayre, Crythril, Meridius, Quasar,
Azaliea, Anh, Exirrel, Tarek, Ranzou, Dalamar, Xerimor, Xyas, Andelas, Silvaria
, Baldur, Avitar, Daje, Lonewolf, Jikun, Kalseru, Remeer, Prophecy, Coran,
Atlas, Glyrinn, Nerevarine, Silverwing, Tranquility, Getahun, Jaret, Katelynne,
Cooper, Kandor, Serthest, Xandu, Pokwundas, Mint, Eowyn, Proficy, Graven, Tali,
Lodi, Chronos, Sethroyce, Lukian, Galote, Tybalt, Karr, Firyious, Hamon, Chamea
, Tiamat, Wendigo, Ainly, Kaelin, Samadhi, Tristen, Lerad, Kaio, Xenomorph,
Arelas, Lulu, Akvavir, Brandi, Maddux, Cain, Jessamine, Kristal, Eiie, Mayhem,
Gaillardia, Ild, Taraza, Amal, Detritus, Kyvaer, Raesheon, Kelandra, Lideron,
Sgueg, Guga, Keram, Kyri, Gfhgiofe, Neko, Hathorne, Winter, Akihito, Seraphi,
Vesence, Caska, Ramoor, Teotwauki, Ithron, Acherontia, Rho, Astaroth, Zephyros,
Gormo, Tsao, Tarako, Khorus, Nicolai, Brew, Terra, Taran, Jaoura, Arcrisius,
Kinilan, Yig, Aragon, Appolonia, Xadhi, Rayin, Ranun, Shecks, Oya, Isis,
Musicia, Michlistus, Chasity, Raga, Rameus, Citrus, Zulah, Hoffryn, Khadgar,
Malchaia, Van, Des, Imyrr, Tordek, Silinrul, Tierat, Shye, Ulrike, Renee, Asche
, Chidori, Fyyar, Rythnin, Batista, Matisyahu, Semcath, Gaul, Byss, Orophin,
Azriya, Falgorn, Kateb, Dali, Drealok, Pepper, Onix, Dyzanru, Fenris, Razael,
Rezerin, Thrump, Vadimuses, Daloc, Glint, Kame, Kupo, Eredar, Gildenlow,
Nogusta, Artimous, Althena, Nich, Lilithia, Herose, Slok, Alzahn, Peirce, Jiano
, Rhaegar, Ladydeath, Ceres, Khyran, Salaric, Siple, Taloc, Saibel, Hyra,
Telemmaite, Chalos, Harmonia, Caelia, Murg, Theiwar, Igno, Bain, Tagg, Qzadzia,
Sergei, Chrono, Neraya, Sheng, Trance, Desian, Tsaketh, Syprius, Traas,
Epiphany, Rhadamanthys, Floralei, Tribal, Lomarion, Sabiru, Olias, Pol, Xeiru,
Lysander, Malachai, Exain, Pazalu, Flash, Andante, Turles, Galadryal, Grendor,
Marmilot, Deridius, Kristie, Rewyn, Destever, Marshall, Manu, Euronymous,
Herenicus, Hikage, Mazus, Varrock, Ennoire, Anke, Alollyra, Zamora, Midas,
Jaffar, Treon, Nadria, Saadya, Aedius, Lerik, Mystie, Tunh, Taraus, Antaios,
Xeros, Jharek, Veneficus, Profit, Pip, Ranky, Malaphus, Kyishi, Fanris, Korlax,
Xinner, Akarin, Valak, Katia, Cordova, Netal, Raekwon, Nightwalker, Zidayn,
Tascha, Cydus, Filgor, Elyse, Rakon, Hawkin, Bleak, Tenebrus, Shehpara, Revan,
Daeiros, Duane, Bood, Jarmen, Daeki, Rachis, Izzadorra, Fayte, Mirko, Saella,
Caramia, Lawia, Crair, Severen, Acar, Niahm, Lupercus, Benkai, Cedit, Lokliroln
, Rary, Sayri, Fen, Reiyna, Zlern, Dontarion, Istiria, Laverna, Shikairi,
Aridji, Heliux, Troknor, Nocroth, Gorlasintan, Lysea, Bryluen, Ankou, Kaos,
Kynes, Thalamir, Dethea, Cyrgon, Calamus, Sisoshy, Crux, Syralis, Ramoth, Icaru
, Zalai, Relish, Sehshomaryu, Wilendithas, Chakan, Gamoneterik, Musico,
Cambreed, Ethos, Khrom, Sobek, Balynne, Swishowski, Cypra, Nitrile, Morthif,
Nahaj, Nulaye, Iozmhrwa, Stern, Phanes, Savira, Tarathiel, Pernicios, Alamar,
Malifuus, Meilii, Xethros, Maximo, Kishiro, Jaryn, Xavyer, Shentaru, Ryne,
Annile, Braem, Trepiad, Miyamoto, Merador, Alexan, Zeiram, Jassore, Adahn,
Laiila, Pawzik, Tir, Ochimaru, Renaldo, Latch, Luxy, Konro, Aralec, Jaegerl,
Leiona, Eznia, Orlen, Kimeth, Brogan, Xorathus, Revolg, Stom, Genjyo, Zintha,
Versola, Nollie, Sykellus, Talgon, Berina, Telvantes, Helcore, Titonus, Sryn,
Huami, Amberly, Sasiya, Corinthian, Rakion, Gerlan, Wyatt, Korrok, Diedrick,
Arcadies, Kenshiro, Tryce, Achilos, Samoan, Rabid, Lukan, Soleil, Dartega,
Elecia, Lucifus, Vaan, Gwenith, Rolov, Xash, Donglar, Aesthe, Austere, Baikhel,
Foliana, Dawson, Shaden, Chani, Mannorath, Raist, Wulfen, Asunawa, Severn, Kamu
, Melazuril, Caius, Szethrusi, Daes, Maroc, Ezalia, Sion, Harper, Murdle,
Belwar, Aethon, Svatopluk, Indaba, Fieth, Adella, Zani, Berith, Alondorion,
Aromaros, Reuridru, Brock, Kevan, Omari, Imhotep
Total: 493
384h, 545m ex-
_________________
CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate
Reply with quote
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: Sat Oct 25, 2008 12:37 am   
 
Oh, and you have a typo in your script that I corrected before I complained it doesn't work ;)
HousEnemy instead of HouseEnemy in the second #COND
Also, on the first COND should the params be there?
_________________
CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate
Reply with quote
Rappy
Wanderer


Joined: 15 Jul 2005
Posts: 96

PostPosted: Sat Oct 25, 2008 4:39 am   
 
Code:
#TRIGGER {Enemies of the City of Eleusis: $} {
  #VARIABLE endline Total:
  #VARIABLE cem?! wasn't following variables =p ""
}
#COND {} {
  #IF (%line =~ "@EndLine") {#VAR @cem %replace(@cem,", ",|)
  } {
  #VARIABLE cem {%concat(@cem,%line)}
  }
} {looplines|notrig}


Something along those lines should process the entire list into a string list. Untested.

-Rappy
_________________
Windows 11 Pro,
cMUD 3.34
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5187

PostPosted: Sat Oct 25, 2008 12:28 pm   
 
For ralgith, corrected the typo you mentioned and adjusted the end condition.
Code:
#TRIGGER "HouseEnemy" {^Enemies of the Sentinels of Nature:$} {HEnemy=""}
#COND {} {#IF (!%begins(%line,"Total")) {HEnemy=%concat(@HEnemy,%line)} {#STATE HouseEnemy 3;#SET HouseEnemy 3 1}} {looplines|param=30}
#COND {} {#IF (!%begins(%line,"Total")) {HEnemy=%concat(@HEnemy,%line);#STATE HouseEnemy 1} {#STATE HouseEnemy 3;#SET HouseEnemy 3 1}}
#COND {} {HEnemy=%subchar(@HEnemy,", ","|");Enemies=%dups(%concat(@PEms,"|",@CEnemy,"|",@HEnemy))} {manual}
I am not sure what, if any problem, there would be from the commas being at the start of the line.

Yes the params needs to be there for state 1. The idea behind this particular state construct is that it when the counter runs out the next state will push it back to the looping state. I often use this stucture for things where a loosely fixed size range is applicable (ie room description <15 lines), and then have state 2 report an error and abort the finish processing.

Another reason to use this stucture is that the params number has some limit. I can't recall what that limit is, but this structure provides a limitless match while taking advantage of the conditional states. It tends to be just little faster then the classic enable/disable scenario.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: Sat Oct 25, 2008 3:00 pm   
 
Ok, thanks for explaining it. I've never seen it done that way, thus I was unsure how it should be corrected. I wasn't sure if the commas would interfere or not, thats why I mentioned it, but I guess if I had thought it through then I would have realized that with the concat method it doesn't matter. Thanks Vij, I'll test it and report back on it.
_________________
CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate
Reply with quote
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: Sat Oct 25, 2008 3:24 pm   
 
Ok, tested it and it reaches state 2 and then that state never fires.
So what I did to make that state fire is add a pattern
^*$
to it, so the receipt of a single line makes it fire.

Now however it reaches the final "manual" line, which does not fire. Even though it should with a proper #SET, which we have.

Of course, it still isn't working correctly because it doesn't fully populate the variable. It only populates the first 30 lines parsed by the looplines portion, plus one extra. Then skips to the final set state. I've included the partial cEnemy var here so you can compare it to my actual CityEnemies list I posted before.

My edited trigger for CityEnemies
Code:
#CLASS {Enemies|City}
#VAR cEnemy {Luthius, Portis, Rinoa, Goliath, Alex, Elric, Eschereheye, Pegasus, Arabi, Kragg, Kusaro, Ravirrh, Xzar, Kaevan, Sarid, Jarrel, Mandrab, Kalypso, Locus, Lothiac, Fahwe, Caelan, Morrigu, Element, Istavan, Niggurath, Darknight, Tad, Santar, Namine, Erikarn, Rukimoro, Shanada, Flayre, Crythril, Meridius, Quasar,Azaliea, Anh, Exirrel, Tarek, Ranzou, Dalamar, Xerimor, Xyas, Andelas, Silvaria, Baldur, Avitar, Daje, Lonewolf, Jikun, Kalseru, Remeer, Prophecy, Coran, Atlas, Glyrinn, Nerevarine, Silverwing, Tranquility, Getahun, Jaret, Katelynne,Cooper, Kandor, Serthest, Xandu, Pokwundas, Mint, Eowyn, Proficy, Graven, Tali,Lodi, Chronos, Sethroyce, Lukian, Galote, Tybalt, Karr, Firyious, Hamon, Chamea, Tiamat, Wendigo, Ainly, Kaelin, Samadhi, Tristen, Lerad, Kaio, Xenomorph, Arelas, Lulu, Akvavir, Brandi, Maddux, Cain, Jessamine, Kristal, Eiie, Mayhem, Gaillardia, Ild, Taraza, Amal, Detritus, Kyvaer, Raesheon, Kelandra, Lideron, Sgueg, Guga, Keram, Kyri, Gfhgiofe, Neko, Hathorne, Winter, Akihito, Seraphi, Vesence, Caska, Ramoor, Teotwauki, Ithron, Acherontia, Rho, Astaroth, Zephyros,Gormo, Tsao, Tarako, Khorus, Nicolai, Brew, Terra, Taran, Jaoura, Arcrisius, Kinilan, Yig, Aragon, Appolonia, Xadhi, Rayin, Ranun, Shecks, Oya, Isis, Musicia, Michlistus, Chasity, Raga, Rameus, Citrus, Zulah, Hoffryn, Khadgar, Malchaia, Van, Des, Imyrr, Tordek, Silinrul, Tierat, Shye, Ulrike, Renee, Asche, Chidori, Fyyar, Rythnin, Batista, Matisyahu, Semcath, Gaul, Byss, Orophin, Azriya, Falgorn, Kateb, Dali, Drealok, Pepper, Onix, Dyzanru, Fenris, Razael, Rezerin, Thrump, Vadimuses, Daloc, Glint, Kame, Kupo, Eredar, Gildenlow, Nogusta, Artimous, Althena, Nich, Lilithia, Herose, Slok, Alzahn, Peirce, Jiano, Rhaegar, Ladydeath, Ceres, Khyran, Salaric, Siple, Taloc, Saibel, Hyra, Telemmaite, Chalos, Harmonia, Caelia, Murg, Theiwar, Igno, Bain, Tagg, Qzadzia,Sergei, Chrono, Neraya, Sheng, Trance, Desian, Tsaketh, Syprius, Traas, Epiphany, Rhadamanthys, Floralei, Tribal, Lomarion, Sabiru, Olias, Pol, Xeiru, Lysander, Malachai, Exain, Pazalu, Flash, Andante, Turles, Galadryal, Grendor, Marmilot, Deridius, Kristie, Rewyn, Destever, Marshall, Manu, Euronymous, Herenicus, Hikage, Mazus, Varrock, Ennoire, Anke, Alollyra, Zamora, Midas, Jaffar, Treon, Nadria, Saadya, Aedius, Lerik, Mystie, Tunh, Taraus, Antaios, Xeros, Jharek, Veneficus, Profit, Pip, Ranky, Malaphus, Kyishi, Fanris, Korlax,}
#TRIGGER "CityEnemy" {^Enemies of the City of @City~:$} {cEnemy=""}
#COND {} {
  #IF (!%begins( %line, "Total")) {cEnemy=%concat( @cEnemy, %line)} {
    #STATE CityEnemy 3
    #SET CityEnemy 3 1
    }
  } {looplines|param=30}
#COND {^*$} {
  #IF (!%begins( %line, "Total")) {
    cEnemy=%concat( @cEnemy, %line)
    #STATE CityEnemy 1
    } {
    #STATE CityEnemy 3
    #SET CityEnemy 3 1
    }
  }
#COND {} {
  cEnemy=%subchar( @cEnemy, ", ", "|")
  Enemies=%dups( %concat( @pEnemy, "|", @cEnemy, "|", @hEnemy))
  } {manual}
#CLASS 0
_________________
CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Sat Oct 25, 2008 5:51 pm   
 
Ten thousand times easier way to do this:

CONFIG SCREENWIDTH 0

#trig {Enemies of the City of %w:} {CityEnemies=""}
#cond {(*)} {#forall %subchar(%1,", ","|") {#additem CityEnemies %i}}

Job done. Tested this with my city enemies just now and it works like a charm.

If you want your wrapping to look how it did before, set the wrap column to 80 and the indent to 0.

Also makes stuff like accounting for long names and channel capping easier :)
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Fragen
Newbie


Joined: 17 Oct 2008
Posts: 7
Location: WV

PostPosted: Mon Oct 27, 2008 2:50 am   
 
doesn't work.... but thanks for trying :)

Rappy wrote:
Code:
#TRIGGER {Enemies of the City of Eleusis: $} {
  #VARIABLE endline Total:
  #VARIABLE cem?! wasn't following variables =p ""
}
#COND {} {
  #IF (%line =~ "@EndLine") {#VAR @cem %replace(@cem,", ",|)
  } {
  #VARIABLE cem {%concat(@cem,%line)}
  }
} {looplines|notrig}


Something along those lines should process the entire list into a string list. Untested.

-Rappy
Reply with quote
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: Mon Oct 27, 2008 4:18 am   
 
Fang, Fragen and I are having problems with your trigger. It is only catching a single name... and it is a name that doesn't even appear on our screens let alone on the list. I'm looking into it more, but I don't understand why it should be doing so. And sometimes it throws an AV with it. That might be because of Vista though, I do get the occasional random AV that can't be blamed anywhere else.
_________________
CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Mon Oct 27, 2008 10:18 am   
 
Well, that's weird, because I logged into Achaea and tested it myself in the game and it's working absolutely fine. Check the value of %1 and see if it's capturing properly.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: Mon Oct 27, 2008 2:50 pm   
 
It was capturing it fine, but when it got subchar'ed it went all loopy.
I'm going to delete the entire thing and recreate it again, maybe I've got a typo in there somewhere or something.

Thanks again.
_________________
CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Mon Oct 27, 2008 2:52 pm   
 
You could try using %replace to the same effect in that case.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5187

PostPosted: Tue Oct 28, 2008 2:17 am   
 
#forall %subchar(%1,", ","|") {#additem CityEnemies %i}
simpler again
CityEnemies=%subchar("%1",", ","|")

There is no reason to keep people that are no longer enemies in this list, so we can just replace the entire list. Also this is zMud, where a %nn value containing things such as a comma can cause all kinds of confusion. Yes, it needs the quotes around it.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Fragen
Newbie


Joined: 17 Oct 2008
Posts: 7
Location: WV

PostPosted: Tue Oct 28, 2008 2:42 am   
 
Well Vij, that last modification to Fang's script seems to do the trick! =D Thanks fellas! All of ya. Beautiful!
Reply with quote
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: Tue Oct 28, 2008 11:01 pm   
 
Ah, it was the quotes I was missing. I didn't know they were needed inside of %subchar too

Otherwise I had already made that other change to the script. I just couldn't get it to capture properly. Which I now know is because of the commans.

Thanks again Vij and Fang
_________________
CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
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

© 2009 Zugg Software. Hosted by Wolfpaw.net