|
chris-74269 Magician
Joined: 23 Nov 2004 Posts: 364
|
Posted: 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 |
|
|
|
charneus Wizard
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: 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 |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Fri Mar 06, 2009 12:15 pm |
Yes; you may want to put this up in the package library as well.
|
|
|
|
|
|
|
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
|
|