|  | 
	
	
		| charneus Wizard
 
  
 Joined: 19 Jun 2005
 Posts: 1876
 Location: California
 
 | 
			
			  |  Posted: Sun Jan 13, 2008 7:27 am 
 String lists and special characters...
 
 |  
				| In Aardwolf, there are several damage messages that contain special characters. One such damage message is: 
 
 
 
	  | Code: |  
	  | <*><-:-><*> SLAUGHTERS <*><-:-><*> |  
 In zMUD, I put them all into a variable (I use it to #sub the line the damage is on), and use #TRIGGER {Your {@damagetypes} blah blah blah} to sub it out.
 
 However, in CMUD, it only matches the damages without special characters in them. How can I go about triggering off the damages like so?
 
 Charneus
 |  | 
	
	  |  | 
	
		|  | 
	
		| charneus Wizard
 
  
 Joined: 19 Jun 2005
 Posts: 1876
 Location: California
 
 | 
			
			  |  Posted: Sun Jan 13, 2008 7:29 am 
 |  
				| EDIT: I thought I had figured it out, but when it came to: 
 
 
 
	  | Code: |  
	  | <-==-><-==-> SHATTERS <-==-><-==-> |  
 it didn't detect it properly, even though I have " " around it in the list. Any suggestions?
 
 Charneus
 |  | 
	
	  |  | 
	
		|  | 
	
		| Larkin Wizard
 
  
 Joined: 25 Mar 2003
 Posts: 1113
 Location: USA
 
 | 
			
			  |  Posted: Sun Jan 13, 2008 3:28 pm 
 |  
				| Have you tried using ~ to escape the special characters in your strings? The string list is substituted into the pattern, and the pattern is looking for ~ on those characters, but it's not there. 
 |  | 
	
	  |  | 
	
		|  | 
	
		| charneus Wizard
 
  
 Joined: 19 Jun 2005
 Posts: 1876
 Location: California
 
 | 
			
			  |  Posted: Sun Jan 13, 2008 7:13 pm 
 |  
				| Well, I went ahead and escaped all the characters, and ran a test. The results are as follows: 
 
 
 
	  | Code: |  
	  | #var damagetypes {misses|tickles|bruises|scratches|grazes|nicks|scars|hits|injures|wounds|mauls|maims|mangles|mars|LACERATES|DECIMATES|DEVASTATES|ERADICATES|OBLITERATES|EXTIRPATES|INCINERATES|MUTILATES|DISEMBOWELS|MASSACRES|DISMEMBERS|~- BLASTS ~-|~-~= DEMOLISHES ~=~-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~-~:~-~>~<~-~:~-~*~-~:~-~>~<~-~*~-~> SUPERNOVAS ~<~-~*~-~>~<~-~:~-~*~-~:~-~>~<~-~:~-~>|pimpslaps|does UNSPEAKABLE things to|does UNIMAGINABLE things to|does UNTHINKABLE things to|RENDS} |  All special characters are escaped.
 
 
 
 
	  | Code: |  
	  | #var damagetest {misses|tickles|bruises|scratches|grazes|nicks|scars|hits|injures|wounds|mauls|maims|mangles|mars|LACERATES|DECIMATES|DEVASTATES|ERADICATES|OBLITERATES|EXTIRPATES|INCINERATES|MUTILATES|DISEMBOWELS|MASSACRES|DISMEMBERS|- BLASTS -|-= DEMOLISHES =-|** SHREDS **|**** DESTROYS ****|***** PULVERIZES *****|-=- VAPORIZES -=-|<-==-> ATOMIZES <-==->|<-:-> ASPHYXIATES <-:->|<-*-> RAVAGES <-*->|<>*<> FISSURES <>*<>|<*><*> LIQUIDATES <*><*>|<*><*><*> EVAPORATES <*><*><*>|<-=-> SUNDERS <-=->|<=-=><=-=> TEARS INTO <=-=><=-=>|<->*<=> WASTES <=>*<->|<-+-><-*-> CREMATES <-*-><-+->|<*><*><*><*> ANNIHILATES <*><*><*><*>|<--*--><--*--> IMPLODES <--*--><--*-->|<-><-=-><-> EXTERMINATES <-><-=-><->|<-==-><-==-> SHATTERS <-==-><-==->|<*><-:-><*> SLAUGHTERS <*><-:-><*>|<-*-><-><-*-> RUPTURES <-*-><-><-*->|<-*-><*><-*-> NUKES <-*-><*><-*->|-<[=-+-=]<:::<>:::> GLACIATES <:::<>:::>[=-+-=]>-|<-=-><-:-*-:-><*--*> METEORITES <*--*><-:-*-:-><-=->|<-:-><-:-*-:-><-*-> SUPERNOVAS <-*-><-:-*-:-><-:->|pimpslaps|does UNSPEAKABLE things to|does UNIMAGINABLE things to|does UNTHINKABLE things to|RENDS} |  No escapes needed, it's going to show directly to the MUD.
 
 
 
	  | Code: |  
	  | #TRIGGER {^Your * {@damagetypes} (*) {.|!} ~[(%d)~]} {#SUB {You hit %1 for %2 points of damage!}} |  My SUB.
 
 
 
	  | Code: |  
	  | #FORALL @damagetest {#SHOW Your mind force %i a dog! [123] ~/~/ Damage type %i} |  The FORALL I used.
 
 
 
	  | Code: |  
	  | You hit a dog for 123 points of damage! // Damage phrase misses You hit a dog for 123 points of damage! // Damage phrase tickles
 You hit a dog for 123 points of damage! // Damage phrase bruises
 You hit a dog for 123 points of damage! // Damage phrase scratches
 You hit a dog for 123 points of damage! // Damage phrase grazes
 You hit a dog for 123 points of damage! // Damage phrase nicks
 You hit a dog for 123 points of damage! // Damage phrase scars
 You hit a dog for 123 points of damage! // Damage phrase hits
 You hit a dog for 123 points of damage! // Damage phrase injures
 You hit a dog for 123 points of damage! // Damage phrase wounds
 You hit a dog for 123 points of damage! // Damage phrase mauls
 You hit a dog for 123 points of damage! // Damage phrase maims
 You hit a dog for 123 points of damage! // Damage phrase mangles
 You hit a dog for 123 points of damage! // Damage phrase mars
 You hit a dog for 123 points of damage! // Damage phrase LACERATES
 You hit a dog for 123 points of damage! // Damage phrase DECIMATES
 You hit a dog for 123 points of damage! // Damage phrase DEVASTATES
 You hit a dog for 123 points of damage! // Damage phrase ERADICATES
 You hit a dog for 123 points of damage! // Damage phrase OBLITERATES
 You hit a dog for 123 points of damage! // Damage phrase EXTIRPATES
 You hit a dog for 123 points of damage! // Damage phrase INCINERATES
 You hit a dog for 123 points of damage! // Damage phrase MUTILATES
 You hit a dog for 123 points of damage! // Damage phrase DISEMBOWELS
 You hit a dog for 123 points of damage! // Damage phrase MASSACRES
 You hit a dog for 123 points of damage! // Damage phrase DISMEMBERS
 Your mind force - BLASTS - a dog! [123] // Damage phrase - BLASTS -
 Your mind force -= DEMOLISHES =- a dog! [123] // Damage phrase -= DEMOLISHES =-
 You hit a dog for 123 points of damage! // Damage phrase ** SHREDS **
 You hit a dog for 123 points of damage! // Damage phrase **** DESTROYS ****
 You hit a dog for 123 points of damage! // Damage phrase ***** PULVERIZES *****
 Your mind force -=- VAPORIZES -=- a dog! [123] // Damage phrase -=- VAPORIZES -=-
 Your mind force <-==-> ATOMIZES <-==-> a dog! [123] // Damage phrase <-==-> ATOMIZES <-==->
 You hit a dog for 123 points of damage! // Damage phrase <-:-> ASPHYXIATES <-:->
 You hit a dog for 123 points of damage! // Damage phrase <-*-> RAVAGES <-*->
 You hit a dog for 123 points of damage! // Damage phrase <>*<> FISSURES <>*<>
 You hit a dog for 123 points of damage! // Damage phrase <*><*> LIQUIDATES <*><*>
 You hit a dog for 123 points of damage! // Damage phrase <*><*><*> EVAPORATES <*><*><*>
 Your mind force <-=-> SUNDERS <-=-> a dog! [123] // Damage phrase <-=-> SUNDERS <-=->
 Your mind force <=-=><=-=> TEARS INTO <=-=><=-=> a dog! [123] // Damage phrase <=-=><=-=> TEARS INTO <=-=><=-=>
 Your mind force <->*<=> WASTES <=>*<-> a dog! [123] // Damage phrase <->*<=> WASTES <=>*<->
 You hit a dog for 123 points of damage! // Damage phrase <-+-><-*-> CREMATES <-*-><-+->
 You hit a dog for 123 points of damage! // Damage phrase <*><*><*><*> ANNIHILATES <*><*><*><*>
 You hit a dog for 123 points of damage! // Damage phrase <--*--><--*--> IMPLODES <--*--><--*-->
 Your mind force <-><-=-><-> EXTERMINATES <-><-=-><-> a dog! [123] // Damage phrase <-><-=-><-> EXTERMINATES <-><-=-><->
 Your mind force <-==-><-==-> SHATTERS <-==-><-==-> a dog! [123] // Damage phrase <-==-><-==-> SHATTERS <-==-><-==->
 Your mind force <*><-:-><*> SLAUGHTERS <*><-:-><*> a dog! [123] // Damage phrase <*><-:-><*> SLAUGHTERS <*><-:-><*>
 You hit a dog for 123 points of damage! // Damage phrase <-*-><-><-*-> RUPTURES <-*-><-><-*->
 You hit a dog for 123 points of damage! // Damage phrase <-*-><*><-*-> NUKES <-*-><*><-*->
 Your mind force -<[=-+-=]<:::<>:::> GLACIATES <:::<>:::>[=-+-=]>- a dog! [123] // Damage phrase -<[=-+-=]<:::<>:::> GLACIATES <:::<>:::>[=-+-=]>-
 Your mind force <-=-><-:-*-:-><*--*> METEORITES <*--*><-:-*-:-><-=-> a dog! [123] // Damage phrase <-=-><-:-*-:-><*--*> METEORITES <*--*><-:-*-:-><-=->
 Your mind force <-:-><-:-*-:-><-*-> SUPERNOVAS <-*-><-:-*-:-><-:-> a dog! [123] // Damage phrase <-:-><-:-*-:-><-*-> SUPERNOVAS <-*-><-:-*-:-><-:->
 You hit a dog for 123 points of damage! // Damage phrase pimpslaps
 You hit a dog for 123 points of damage! // Damage phrase does UNSPEAKABLE things to
 You hit a dog for 123 points of damage! // Damage phrase does UNIMAGINABLE things to
 You hit a dog for 123 points of damage! // Damage phrase does UNTHINKABLE things to
 You hit a dog for 123 points of damage! // Damage phrase RENDS
 |  The end results. As you can see, it works most of the list. However, you can see there are some that do NOT work at all, even escaped. Besides, shouldn't variables be literal in a record list anyway? The only time they should be expanded is if you tell it to be expanded, I thought.
 
 Charneus
 |  | 
	
	  |  | 
	
		|  | 
	
		| Guinn Wizard
 
 
 Joined: 03 Mar 2001
 Posts: 1127
 Location: London
 
 | 
			
			  |  Posted: Sun Jan 13, 2008 11:14 pm 
 |  
				| Could you do something like 
 #IF (%quote(%1) = %quote(@record.item)) {do whatever}
 
 So rather than escaping everything in the variable you're using %quote to escape it
 |  | 
	
	  | 
		    
			  | _________________ CMUD Pro, Windows Vista x64
 Core2 Q6600, 4GB RAM, GeForce 8800GT
 Because you need it for text... ;)
 |   |  | 
	
		|  | 
	
		| charneus Wizard
 
  
 Joined: 19 Jun 2005
 Posts: 1876
 Location: California
 
 | 
			
			  |  Posted: Sun Jan 13, 2008 11:29 pm 
 |  
				| The problem is the main trigger isn't capturing it, no matter what, so putting the #IF statement in the trigger isn't going to help. 
 Charneus
 |  | 
	
	  |  | 
	
		|  | 
	
		| MrCheviot Novice
 
 
 Joined: 02 Dec 2007
 Posts: 42
 
 
 | 
			
			  |  Posted: Mon Jan 14, 2008 5:27 am 
 |  
				| I've always had better luck capturing odd/complex strings with #REGEX vs. #TRIGGER. Not sure if it's just me or a limitation of the conversion process... 
 I worked on this a bit with Charneus, and although he may not end up adopting my solution, it was basically to use a #REGEX with \W+? to capture all of the 'non-word' symbols that can appear in certain damage messages.
 
 Two triggers, which don't exactly fit his #SUB above, but offer enough flexibility for #psub/#sub/output function/etc.
 
 
 
 
	  | Code: |  
	  | ^Your .*(\s\W+?) (.*) (\W+?\s)(.*)[\.!] \[(\d+)\]$ ^(?:\[(\d+)\] |)Your (.*)\s(@dam_verbs) (.*)[\.!] \[(\d+)\]$
 
 dam_verbs = "misses|cleaves|bashes|smotes|etc"
 |  
 
 When triggers cause headaches (or always really), I recommend ditching #TRIGGER for #REGEX. Doing subtle things are just easier, IMO.
 
 
 -MrC
 |  | 
	
	  |  | 
	
		|  | 
	
		| Guinn Wizard
 
 
 Joined: 03 Mar 2001
 Posts: 1127
 Location: London
 
 | 
			
			  |  Posted: Mon Jan 14, 2008 10:54 am 
 |  
				| y'know, I think this is a bug... 
 It's = inside {} that's causing the problems with the match
 
 #TR {one @test one} {#say one}
 #TR {two {@test} one} {#say two}
 
 test = "hellogoodbye"
 #SAY one @test one
 #SAY two @test one
 
 test = "hello=goodbye"
 #SAY one @test one
 #SAY two @test one
 
 First 3 fire, 4th doesn't
 |  | 
	
	  | 
		    
			  | _________________ CMUD Pro, Windows Vista x64
 Core2 Q6600, 4GB RAM, GeForce 8800GT
 Because you need it for text... ;)
 |   |  | 
	
		|  | 
	
		| Fang Xianfu GURU
 
  
 Joined: 26 Jan 2004
 Posts: 5155
 Location: United Kingdom
 
 | 
			
			  |  Posted: Mon Jan 14, 2008 12:02 pm 
 |  
				| Your example will be because "hello=goodbye" looks like a data record variable, Guinn, and you'll notice that a fifth test, #say two hello one fires, since {@datarecordvariable} in a trigger becomes the regex (?:key1|key2|key3). 
 It's possible, I suppose, that there's a bug here relating to how triggers detect what's a data record variable and what isn't (since Charneus' example isn't).
 |  | 
	
	  |  | 
	
		|  | 
	
		| Guinn Wizard
 
 
 Joined: 03 Mar 2001
 Posts: 1127
 Location: London
 
 | 
			
			  |  Posted: Mon Jan 14, 2008 3:02 pm 
 |  
				| Is there a method of allowing an = in a variable value without potentially causing this problem? If you put ~= in the variable value it still doesn't work, so maybe the escape character should work inside a variable value as well as inside a trigger pattern?
 |  | 
	
	  | 
		    
			  | _________________ CMUD Pro, Windows Vista x64
 Core2 Q6600, 4GB RAM, GeForce 8800GT
 Because you need it for text... ;)
 |   |  | 
	
		|  | 
	
		| Fang Xianfu GURU
 
  
 Joined: 26 Jan 2004
 Posts: 5155
 Location: United Kingdom
 
 | 
			
			  |  Posted: Mon Jan 14, 2008 3:30 pm 
 |  
				| There isn't that I'm aware of, and that's why I say there might be a weakness in the way triggers separate keys from values in what they suppose is a data record variable. 
 |  | 
	
	  |  | 
	
		|  | 
	
		| Posideon Beginner
 
 
 Joined: 06 Feb 2005
 Posts: 26
 
 
 | 
			
			  |  Posted: Tue Jan 15, 2008 9:58 am 
 |  
				| Try this... Check verbatim as a trigger parameter... then you don't need " " or the ~ or anything you just copy and paste and it should capture...
 
 Hope this helps.
 Posideon
 |  | 
	
	  |  | 
	
		|  | 
	
		| alluran Adept
 
 
 Joined: 14 Sep 2005
 Posts: 223
 Location: Sydney, Australia
 
 | 
			
			  |  Posted: Tue Jan 15, 2008 12:16 pm 
 |  
				| Verbatim won't work, cos he still wants to use {} to indicate its one option out of the possible list. I know i've always had fun when it came to capturing things like this. Another fun one is to capture clan logos, or Auras (logos can contain virtually any characters, auras are surrounded by ( and )), and even more fun is importing them again 
 |  | 
	
	  | 
		    
			  | _________________ The Drake Forestseer
 |   |  | 
	
		|  | 
	
		| Zugg MASTER
 
  
 Joined: 25 Sep 2000
 Posts: 23379
 Location: Colorado, USA
 
 | 
			
			  |  Posted: Tue Jan 15, 2008 6:17 pm 
 |  
				| I think it's the code in the Trigger routine (the one that converts a zMUD trigger into the proper regex and expands the variables) that is causing this.  The "=" is causing CMUD to think that you are expanding a database variable instead of a string list.  Can someone post a simplified example or test script that will illustrate the bug quickly.  This would really help when I get back to bug fixing towards the end of the month. 
 |  | 
	
	  |  | 
	
		|  | 
	
		| charneus Wizard
 
  
 Joined: 19 Jun 2005
 Posts: 1876
 Location: California
 
 | 
			
			  |  Posted: Tue Jan 15, 2008 6:34 pm 
 |  
				| Don't know if this helps, but here's my output from testing a couple of things: 
 
 
 
	  | Code: |  
	  | #VAR testvars {>>=<<Test1>>=<<|>><<Test2>><<|-=-Test3-=-|---Test4---|**=**Test5**=**|*****Test6*****} #SHOW Now showing ~@testvars using ~#FORALL:;#FORALL @testvars {#SHOW %i};#SHOW
 #SHOW Now showing ~@testvars using ~#LOOPDB:;#LOOPDB @testvars {#SHOW %key is a key. %val is the value.};#SHOW
 #SHOW Now showing ~@testvars using ~#SHOW;#SHOW @testvars
 |  
 
 
	  | Code: |  
	  | Now showing @testvars using #FORALL: >>=<<Test1>>=<<
 >><<Test2>><<
 -=-Test3-=-
 ---Test4---
 **=**Test5**=**
 *****Test6*****
 
 Now showing @testvars using #LOOPDB:
 >> is a key. <<Test1>>=<< is the value.
 >><<Test2>><< is a key.  is the value.
 ---Test4--- is a key.  is the value.
 - is a key. -Test3-=- is the value.
 ** is a key. **Test5**=** is the value.
 *****Test6***** is a key.  is the value.
 
 Now showing @testvars using #SHOW:
 >>=<<Test1>>=<<|>><<Test2>><<|-=-Test3-=-|---Test4---|**=**Test5**=**|*****Test6*****
 |  
 Also, on the following trigger:
 
 
 
	  | Code: |  
	  | #TRIGGER {Blah blah blah ({@testvars}) blah blah blah} {#SHOW %i fires correctly.} |  
 returns:
 
 
 
	  | Code: |  
	  | Blah blah blah >>=<<Test1>>=<< blah blah blah Blah blah blah >><<Test2>><< blah blah blah
 >><<Test2>><< fires correctly.
 Blah blah blah -=-Test3-=- blah blah blah
 Blah blah blah ---Test4--- blah blah blah
 ---Test4--- fires correctly.
 Blah blah blah **=**Test5**=** blah blah blah
 Blah blah blah *****Test6***** blah blah blah
 *****Test6***** fires correctly.
 |  
 Hope that aids a bit. :P
 
 Charneus
 |  | 
	
	  |  | 
	
		|  | 
	
		| Guinn Wizard
 
 
 Joined: 03 Mar 2001
 Posts: 1127
 Location: London
 
 | 
			
			  |  Posted: Tue Jan 15, 2008 9:21 pm 
 |  
				| You can remove all but the = to simplify it further. 
 #VAR test {}
 #ADDITEM test "Test1"
 #ADDITEM test "Test2=asdf"
 #ADDITEM test "Test3"
 
 #TR {blah ({@test}) blah} {#SHOW %1 fires correctly.}
 
 #FORALL @test {#SAY blah %i blah}
 |  | 
	
	  | 
		    
			  | _________________ CMUD Pro, Windows Vista x64
 Core2 Q6600, 4GB RAM, GeForce 8800GT
 Because you need it for text... ;)
 |   |  | 
	
		|  | 
	
		|  | 
	
		|  |