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
chris-74269
Magician


Joined: 23 Nov 2004
Posts: 364

PostPosted: Fri Mar 06, 2009 5:49 am   

Function to remove ansi up to a certain string position
 
This will strip ansi in a string up to a given position, use it like @ansistrip(string,position) to receive a string up to position x with all ansi removed and all ansi retained after that position

Code:

<func name="ansistrip" id="266258">
  <value>$stripline=%left( $string, $position)
#while (((%regex( $stripline, "\e", $ansiposition)) <= $position) AND (%regex( $stripline, "\e") != 0))  {
  $ansiendposition=%regex( %right( $stripline, $ansiposition), "m|S")
  $position=$position+$ansiendposition+$ansiposition+1
  $stripline=%stripansi(%left($string,$position))
  }
#return %concat(%stripansi(%left($string,$position)),%right($string,$position))</value>
  <arglist>$string,$position</arglist>
</func>


If you want to echo the print back to your mud, you might want to add a %ansi(white) before the variable is echo'd so the print looks like your mud default's print instead of the cyan color cmud will default to
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Fri Mar 06, 2009 6:18 am   
 
Should probably note, chris-74269, that this is for CMUD, not zMUD, as this forum is for zMUD finished scripts. ;)

Charneus
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Fri Mar 06, 2009 12:15 pm   
 
Yes; you may want to put this up in the package library as well.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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