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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion Goto page Previous  1, 2, 3, 4, 5, 6  Next
chamenas Posted: Thu Apr 17, 2008 11:47 am
replacing lines of text before they show...
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Thu Apr 17, 2008 9:00 pm   
 
I thought expression in CMUD didn't use ==, they just used =

And what's with the 1,2,3,4?
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Thu Apr 17, 2008 9:14 pm   
 
They can use either way. = would be the same as the == I have there.

I showed you two different syntaxes.

The first syntax is a shortcut syntax. You place the variable to be tested first.
Then you place the value of the variable before each set of commands.

I'll do another example.
Code:
#var number 1
#switch (@number)
  1 {#show one}
  2 {#show two}
  3 {#show three}
  4 {#show four}
  {#show not 1 2 3 or 4}

In this case when the code was executed the value of @number is 1 so the output is "one"
Code:
#var number 3
#switch (@number=1) {#show one}
  (@number=2) {#show two}
  (@number=3) {#show three}
  (@number=4) {#show four}
  {#show not 1 2 3 or 4}

In this case the value of @number is 3 so the output is "three".
Code:
#var animal cat
#switch (@animal)
  "dog" {#show I like dogs.}
  "cat" {#show Cats are easier to take care of.}
  "elephant" {#show Try not to look at the white elephant.}
  "mouse" {#show Mice are said to like cheese.}
  {#show Not one of the animals I expected}


See how that could be helpful?
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Thu Apr 17, 2008 10:00 pm   
 
#switch (@damage)
"maims" {#sub {bladie blah?}}
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Fri Apr 18, 2008 3:57 am   
 
Uh why the heck are you doing all that with #SUBSTITUTE when all you need is #SAYADD to tack your little damage amounts or whatever onto the end of the line.
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Fri Apr 18, 2008 12:32 pm   
 
I want it to match the text from the MUD, #say would look separate from it.
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Fri Apr 18, 2008 1:03 pm   
 
Read the help on #sayadd, you can use it in a trigger so it's quite useful. But if you want to do other stuff to the line (you said you wanted to remove the damage text at some point?), you'll need to use #sub.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Fri Apr 18, 2008 3:16 pm   
 
I don't need to remove the damage text, just need to add the numbers. I need to capture the damage text, damage type and the critter I'm doing damage to.

Quote:

#SAYADD #SAYA
Added in v2.11
SAYADD

Syntax: #SAYADD text

Similar to the #SAY command, but adds the text to the end of the current line.


MY say command comes out orange in the mud, so this would put out the line with an orange number in parentheses. I'm hoping to make it look like it came from the mud (for aesthetics) and maybe even change the color for different values.
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Fri Apr 18, 2008 3:40 pm   
 
So change the colour. You can use %ansi or MXP to change it.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Fri Apr 18, 2008 5:21 pm   
 
And that will just change it for that instance?
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
JQuilici
Adept


Joined: 21 Sep 2005
Posts: 250
Location: Austin, TX

PostPosted: Fri Apr 18, 2008 6:02 pm   
 
If you close it properly, yes, it will only color the part you indicate.
Code:
#show Line
#sayadd { <color red>red text</color> normal text %ansi(bold,green)green text%ansi(reset) normal again}


If you don't close it...the default color will stay as you set it until it gets changed again or the line ends (if you use MXP colors), but it appears to reset immediately with ansi colors.
Code:
#show Line
#sayadd { <color fore=yellow back=#770000> some yellow-on-red}
#sayadd { Still yellow-on-red}
#show Back to normal
#show Line
#sayadd { %ansi(bold,green) green}
#sayadd { back to normal}
_________________
Come visit Mozart Mud...and tell an imm that Aerith sent you!
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Fri Apr 18, 2008 8:13 pm   
 
Right, #SAYADD is exactly what you want to use in this case. Just make sure and put a space before whatever you want to add to the end of the line.

In the value of your trigger you would just put your script to calculate the damage and then include:

Code:
#sayadd {<color red> $dmg Damage</color>}


You can put whatever you want of course, but that's what you posted earlier.

On your screen it would look like:

Your flaming bite *** DEVESTATES *** a sasquatch. 50 Damage
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Sat Apr 19, 2008 1:58 pm   
 
hmm... why are we using $dmg? and can I arrange "#regex {^(Your (?:shocking bite|punch|chop|whatever) (?:misses|maims|scratches|whatever) (a|the| ) .+[!\.])$} {#IF (%2="*** DEVESTATES ***") {#sub %concat(%1, " (50) dmg")} } " like...

#regex {^(Your
(?:shocking bite|punch|chop|whatever)
(?:misses|maims|scratches|whatever)
(a|the| ) .+[!\.])$}
{#IF (%2="*** DEVESTATES ***") {#sub %concat(%1, " (50) dmg")} }
Reply with quote
gamma_ray
Magician


Joined: 17 Apr 2005
Posts: 496

PostPosted: Sat Apr 19, 2008 2:29 pm   
 
$dmg would be the value calculated by you to represent how much damage you just did, so that instead of branching like this:

scratches -> #sayadd <color red> 1 Damage</color>
does something -> #sayadd <color red> 3 Damage</color>
something else -> #sayadd <color red> 7 Damage</color>
...

and so on, you can branch like this
scratches -> 1
does something -> 3
something else -> 7
...

which is much easier to read, and more important, change later on.

And really, you should avoid using sub, since we've got the lovely sayadd (so much love), because sub is really freaking slow and also sometimes a pain in the rear, and plus it requires you to jump through extra hoops, and really, just not good.
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Sat Apr 19, 2008 2:35 pm   
 
Well... here's what I have. IT's terribly messy and buggy Sad

Code:

#regex Damage Capture {^(Your (Acidic Bite|Beating|Bite|Blast|Charge|Chill|Chop|Claw|Cleave|Crush|Divine|Drain|Flame|Flaming Bite|Freezing Bite|Grep|Magic| |Peck|Pierce|Pound|Punch|Scratch|Shocking Bite|Shock|Slap|Slash|Slice|Slime|Smash|Stab|Sting|Suction|Thrust|Thwack|Whip|Wrath) (misses|maims|scratches|grazes|hits|injures|wounds|mauls|decimates|devestates|maims|MUTILATES|DISEMBOWELS|DISMEMBERS|MASSACRES|MANGLES|*** DEMOLISHES ***|*** DEVESTATES ***|=== OBLITERATES ===|>>> ANNIHILATES <<<|<<< ERADICATES >>>|GHASTLY|HORRID|DREADFUL|HIDEOUS|INDESSCRIBABLE|UNSPEAKABLE) (?:a|the| ) (.+)[!\.])$} {#IF (%2="*** DEVESTATES ***")
{ Damage_Value=%2
#switch (@Damage_Value)
 "misses" {#sayadd {%ansi(gray)\(%ansi(red)0%ansi(gray)\)Dmg%ansi(reset)}
 "scratches" {#sayadd {%ansi(gray)\(%ansi(red)2.5%ansi(gray)\)Dmg%ansi(reset)}       
 "grazes" {#sayadd {%ansi(gray)\(%ansi(red)6.5%ansi(gray)\)Dmg%ansi(reset)}       
 "hits" {#sayadd {%ansi(gray)\(%ansi(red)10.5%ansi(gray)\)Dmg%ansi(reset)}
 "injures" {#sayadd {%ansi(gray)\(%ansi(red)14.5%ansi(gray)\)Dmg%ansi(reset)}
 "wounds" {#sayadd {%ansi(gray)\(%ansi(red)18.5%ansi(gray)\)Dmg%ansi(reset)}
 "mauls" {#sayadd {%ansi(gray)\(%ansi(red)22.5%ansi(gray)\)Dmg%ansi(reset)}
 "decimates" {#sayadd {%ansi(gray)\(%ansi(red)26.5%ansi(gray)\)Dmg%ansi(reset)}
 "devastates" {#sayadd {%ansi(gray)\(%ansi(red)30.5%ansi(gray)\)Dmg%ansi(reset)}
 "maims" {#sayadd {%ansi(gray)\(%ansi(red)34.5%ansi(gray)\)Dmg%ansi(reset)}
 "MUTILATES" {#sayadd {%ansi(gray)\(%ansi(red)38.5%ansi(gray)\)Dmg%ansi(reset)}
 "DISEMBOWELS" {#sayadd {%ansi(gray)\(%ansi(red)42.5%ansi(gray)\)Dmg%ansi(reset)}
 "DISMEMBERS" {#sayadd {%ansi(gray)\(%ansi(red)46.5%ansi(gray)\)Dmg%ansi(reset)}
 "MASSACRES" {#sayadd {%ansi(gray)\(%ansi(red)50.5%ansi(gray)\)Dmg%ansi(reset)}
 "MANGLES" {#sayadd {%ansi(gray)\(%ansi(red)54.5%ansi(gray)\)Dmg%ansi(reset)}
 "*** DEMOLISHES ***" {#sayadd {%ansi(gray)\(%ansi(red)58.5%ansi(gray)\)Dmg%ansi(reset)}
 "*** DEVASTATES ***" {#sayadd {%ansi(gray)\(%ansi(red)68%ansi(gray)\)Dmg%ansi(reset)}
 "=== OBLITERATES ===" {#sayadd {%ansi(gray)\(%ansi(red)88%ansi(gray)\)Dmg%ansi(reset)}
 ">>> ANNIHILATES <<<" {#sayadd {%ansi(gray)\(%ansi(red)112%ansi(gray)\)Dmg%ansi(reset)}
 "<<< ERADICATES >>>" {#sayadd {%ansi(gray)\(%ansi(red)136%ansi(gray)\)Dmg%ansi(reset)}
 "GHASTLY" {#sayadd {%ansi(gray)\(%ansi(red)163%ansi(gray)\)Dmg%ansi(reset)}
 "HORRID" {#sayadd {%ansi(gray)\(%ansi(red)188%ansi(gray)\)Dmg%ansi(reset)}
 "DREADFUL" {#sayadd {%ansi(gray)\(%ansi(red)228%ansi(gray)\)Dmg%ansi(reset)}
 "HIDEOUS" {#sayadd {%ansi(gray)\(%ansi(red)238%ansi(gray)\)Dmg%ansi(reset)}
 "INDESSCRIBABLE" {#sayadd {%ansi(gray)\(%ansi(red)263%ansi(gray)\)Dmg%ansi(reset)}
 "UNSPEAKABLE" {#sayadd {%ansi(gray)\(%ansi(red)280%ansi(gray)\)Dmg%ansi(reset)}
} {General Triggers|Damage Calculator}
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Sat Apr 19, 2008 3:34 pm   
 
Hmm... I could clean it up if I did the conversion first and just did one #sayadd. I'll look into that after breakfast.
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Sat Apr 19, 2008 4:44 pm   
 
That's why I had the local variable of $dmg. It would certainly be more readable than what you have. However, why are you backreferencing 3 items when you only use one of them? Also your script will never work since you are missing a bracket and even then will only work when you get the Devestates line.
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Sat Apr 19, 2008 4:54 pm   
 
backreferencing what? I'm just trying to figure out why it's $ instead of @
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Sat Apr 19, 2008 5:05 pm   
 
How's this?

Code:

#regex Damage_Convert {^(Your (Acidic Bite|Beating|Bite|Blast|Charge|Chill|Chop|Claw|Cleave|Crush|Divine|Drain|Flame|Flaming Bite|Freezing Bite|Grep|Magic| |Peck|Pierce|Pound|Punch|Scratch|Shocking Bite|Shock|Slap|Slash|Slice|Slime|Smash|Stab|Sting|Suction|Thrust|Thwack|Whip|Wrath) (misses|maims|scratches|grazes|hits|injures|wounds|mauls|decimates|devestates|maims|MUTILATES|DISEMBOWELS|DISMEMBERS|MASSACRES|MANGLES|*** DEMOLISHES ***|*** DEVESTATES ***|=== OBLITERATES ===|>>> ANNIHILATES <<<|<<< ERADICATES >>>|GHASTLY|HORRID|DREADFUL|HIDEOUS|INDESSCRIBABLE|UNSPEAKABLE) (?:a|the| ) (.+)[!\.])$} {#IF (%2="*** DEVESTATES ***")
{ Dmg_Val=%2
  #switch(@Dmg_Val)
 "misses" {Dmg_Val=0}
 "scratches" {Dmg_Val=2.5}   
 "grazes" {Dmg_Val=6.5}   
 "hits" {Dmg_Val=10.5}
 "injures" {Dmg_Val=14.5}
 "wounds" {Dmg_Val=18.5}
 "mauls" {Dmg_Val=22.5}
 "decimates" {Dmg_Val=26.5}
 "devastates" {Dmg_Val=30.5}
 "maims" {Dmg_Val=34.5}
 "MUTILATES" {Dmg_Val=38.5}
 "DISEMBOWELS" {Dmg_Val=42.5}
 "DISMEMBERS" {Dmg_Val=46.5}
 "MASSACRES" {Dmg_Val=50.5}
 "MANGLES" {Dmg_Val=54.5}
 "*** DEMOLISHES ***" {Dmg_Val=58.5}
 "*** DEVASTATES ***" {Dmg_Val=68}
 "=== OBLITERATES ===" {Dmg_Val=88}
 ">>> ANNIHILATES <<<"{Dmg_Val= 112}
 "<<< ERADICATES >>>" {Dmg_Val=136}
 "GHASTLY" {Dmg_Val=163}
 "HORRID" {Dmg_Val=188}
 "DREADFUL" {Dmg_Val=228}
 "HIDEOUS" {Dmg_Val=238}
 "INDESSCRIBABLE" {Dmg_Val=263}
 "UNSPEAKABLE" {Dmg_Val=280}

 #sayadd {%ansi(gray)\(%ansi(red)@Dmg_Val%ansi(gray)\) dmg %ansi(reset)}
} {General Triggers|Damage Calculator}
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Sat Apr 19, 2008 5:14 pm   
 
Well okay lets look at your trigger.

Code:
^(Your (Acidic Bite|Beating|Bite|Blast|Charge|Chill|Chop|Claw|Cleave|Crush|Divine|Drain|Flame|Flaming Bite|Freezing Bite|Grep|Magic| |Peck|Pierce|Pound|Punch|Scratch|Shocking Bite|Shock|Slap|Slash|Slice|Slime|Smash|Stab|Sting|Suction|Thrust|Thwack|Whip|Wrath) (misses|maims|scratches|grazes|hits|injures|wounds|mauls|decimates|devestates|maims|MUTILATES|DISEMBOWELS|DISMEMBERS|MASSACRES|MANGLES|*** DEMOLISHES ***|*** DEVESTATES ***|=== OBLITERATES ===|>>> ANNIHILATES <<<|<<< ERADICATES >>>|GHASTLY|HORRID|DREADFUL|HIDEOUS|INDESSCRIBABLE|UNSPEAKABLE) (?:a|the| ) (.+)[!\.])$


First of all you are storing the value for the entire trigger because you have it surrounded by ( and ) parentheses. Then you are storing the value of the second word after Your by having it surrounded by parentheses. Then you are also storing the value of whatever is in-between (.+).

Read:

http://www.regular-expressions.info/brackets.html and especially this part "Remembering part of the regex match in a backreference, slows down the regex engine because it has more work to do."

The ONLY thing you need to backreference is the damage word which would be misses, maims, scratches, and so on.

Secondly, the $dmg is called a local variable, which is probably one of the greatest things about CMUD. I think gamma_ray explained it above. However, in your case you could use two local variables. One to store the type of damage and another to store the actual damage amount. Then at the end you would use one #sayadd line like so:

Code:
#sayadd {<color gray>~(</color><color red>$dmg</color><color gray>~) Dmg</color>}
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Sat Apr 19, 2008 5:28 pm   
 
Yes thats the right idea, but your script STILL will never work because of this:

Code:
#IF (%2="*** DEVESTATES ***")
{ Dmg_Val=%2
  #switch(@Dmg_Val)
 "misses" {Dmg_Val=0}


Your script will ONLY run if the line includes "***DEVESTATES***" which is not what you want at all.

Just declare two local variables. One to store the value of the TYPE and one to store the DAMAGE amount. You don't need to permanently store the amount, you only need it one time when that trigger fires and then discard it.

So it would look like this:

Code:

$dmgType=%1
$dmg=""
#switch ($dmgType)
  ("misses") {$dmg=0}
  ("maims") {$dmg=2.5}

...and so on
#sayadd { <color gray>~(</color><color red>$dmg</color><color gray>~) Dmg</color>}


By the way, if your default text color is silver you would only need to change the color of $dmg in your #sayadd like so:

Code:
#sayadd { ~(<color red>$dmg</color>~) Dmg}


Anyway, so with the following line received from the MUD:

Your slash maims a terrifying monster.

The output would be:

Your slash maims a terrifying monster. (2.5) Dmg


Last edited by oldguy2 on Sat Apr 19, 2008 5:40 pm; edited 1 time in total
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Sat Apr 19, 2008 5:36 pm   
 
I want to store the amount to be added to a total amount that survives past the instance of the trigger.

So what I have is this:
Code:

#regex Damage_Convert {^Your (Acidic Bite|Beating|Bite|Blast|Charge|Chill|Chop|Claw|Cleave|Crush|Divine|Drain|Flame|Flaming Bite|Freezing Bite|Grep|Magic| |Peck|Pierce|Pound|Punch|Scratch|Shocking Bite|Shock|Slap|Slash|Slice|Slime|Smash|Stab|Sting|Suction|Thrust|Thwack|Whip|Wrath) (misses|maims|scratches|grazes|hits|injures|wounds|mauls|decimates|devestates|maims|MUTILATES|DISEMBOWELS|DISMEMBERS|MASSACRES|MANGLES|*** DEMOLISHES ***|*** DEVESTATES ***|=== OBLITERATES ===|>>> ANNIHILATES <<<|<<< ERADICATES >>>|GHASTLY|HORRID|DREADFUL|HIDEOUS|INDESSCRIBABLE|UNSPEAKABLE) (?:a|the| ) (.+)[!\.]$}
{ Dmg_Val=%2
  #switch (@Dmg_Val)
 ("misses") {Dmg_Val=0}
 ("scratches") {Dmg_Val=2.5}   
 ("grazes") {Dmg_Val=6.5}   
 ("hits") {Dmg_Val=10.5}
 ("injures") {Dmg_Val=14.5}
 ("wounds") {Dmg_Val=18.5}
 ("mauls") {Dmg_Val=22.5}
 ("decimates") {Dmg_Val=26.5}
 ("devastates") {Dmg_Val=30.5}
 ("maims") {Dmg_Val=34.5}
 ("MUTILATES") {Dmg_Val=38.5}
 ("DISEMBOWELS") {Dmg_Val=42.5}
 ("DISMEMBERS") {Dmg_Val=46.5}
 ("MASSACRES") {Dmg_Val=50.5}
 ("MANGLES") {Dmg_Val=54.5}
 ("*** DEMOLISHES ***") {Dmg_Val=58.5}
 ("*** DEVASTATES ***") {Dmg_Val=68}
 ("=== OBLITERATES ===") {Dmg_Val=88}
 (">>> ANNIHILATES <<<") {Dmg_Val= 112}
 ("<<< ERADICATES >>>") {Dmg_Val=136}
 ("GHASTLY") {Dmg_Val=163}
 ("HORRID") {Dmg_Val=188}
 ("DREADFUL") {Dmg_Val=228}
 ("HIDEOUS") {Dmg_Val=238}
 ("INDESSCRIBABLE") {Dmg_Val=263}
 ("UNSPEAKABLE") {Dmg_Val=280}

 #sayadd {%ansi(gray)\(%ansi(red)@Dmg_Val%ansi(gray)\) dmg %ansi(reset)}
} {General Triggers|Damage Calculator}


I want to backreference three things because they're all important for the after damage report. What I did the damage with, amount of damage total, and what creature(s) I did the damage to. (the creatures and multiple damage types will make it very complicated which is why I'm not doing all of that yet)
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Sat Apr 19, 2008 5:46 pm   
 
I see. Well don't forget to assign those things to whatever variables or database you are going to use then in your script there. You don't have it yet.
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Sat Apr 19, 2008 6:12 pm   
 
I'm getting a load of syntax errors in the script at the moment. Confused
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Sat Apr 19, 2008 6:44 pm   
 
lol...do you see what you did?

You are storing the value of the type of damage into Dmg_Val and also trying to store the damage amount. This is why you need two variables.


Code:

dmgVal=%2
#switch (@dmgVal)
   ("misses") {dmg=0}
   ("scratches") {dmg=2.5}
   ("grazes") {dmg=6.5}
   ("hits") {dmg=10.5}
#sayadd { ~(<color red>@dmg</color>~) Dmg}

...and so on.


Make sure you get the spacing and indention right.
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Sat Apr 19, 2008 7:01 pm   
 
It's supposed to just replace it, but I can use two variables. However, the syntax is still an issue. I have no clue how to indent and space it properly, it should be. Confused
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Goto page Previous  1, 2, 3, 4, 5, 6  Next
Page 2 of 6

 
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