 |
Carpesimia Beginner
Joined: 06 Feb 2025 Posts: 22
|
Posted: Mon Apr 14, 2025 5:31 pm
unbold %ansi without reset |
Ok, so hopefully this is an easy one.
So, let's take this:
Quote: |
#say %ansi(gray) This is gray %ansi(bold,green) this is bold green, but %ansi(gray) this is no longer gray, but bold white. |
Is there a way to UNBOLD without needing to add a whole other ansi command? Something like the below?
Quote: |
#say %ansi(gray) This is gray %ansi(bold,green) this is bold green, but %ansi(unbold,gray) this is no longer gray, but bold white. |
I mean, I know that this works:
Quote: |
#say %ansi(gray) This is gray %ansi(bold,green) this is bold green, and %ansi(reset)%ansi(gray) this now gray again. |
But if I am really coloring something up, adding the whole additional %ansi(reset) each time i might go to an unbold color after a bold color is tedious. |
|
|
 |
shalimar GURU

Joined: 04 Aug 2002 Posts: 4757 Location: Pensacola, FL, USA
|
Posted: Mon Apr 14, 2025 8:19 pm |
Honestly, i think thats just a quirk of the ansi coloring system.
Have you tried migrating to MXP?
Code: |
#SAY <color gray>This is gray</color> <color green> This is some green with a splash of <color red>red</color> in it.</color> |
then you can use any hexadecimal color you want #RRGGBB |
|
_________________ Discord: Shalimarwildcat |
|
|
 |
Carpesimia Beginner
Joined: 06 Feb 2025 Posts: 22
|
Posted: Mon Apr 14, 2025 8:43 pm |
So, here's the thing. The above is simplified code, and i was trying to find a way to build a string, including ansi codes, and pass that to a #SAY, or to a #WINDOW, etc. The issue is that when pre-prepping the strings, just dropping the MXP codes or ansi codes into them, doesnt work because these need to pre-render and just adding them to a string to be passed to a display command just doesnt work.
After I wrote this post, I perfected a function I call colorize. With this function, I can make a string like this:
Quote: |
[gray]Hey! [yellow]username[gray] just stole your [green]backpack[gray]! You gonna let that stand?? |
And assign that to a string, using the right parms. then,
Quote: |
$str="[gray]Hey! [yellow]"%1"[gray] just stole your [green]"%2"[gray]! You gonna let that stand??"
$newstr = @colorize($str)
#WIN windowName $newstr |
And I have an easy way to colorize strings for any occasion.
Anyways, once again, thank you for your assist.
As far as my colorize function:
Quote: |
$newline = %-1
$green = %ansi(bold, green)
$cyan = %ansi(bold, cyan)
$blue = %ansi(bold, blue)
$red = %ansi(bold, red)
$magenta = %ansi(bold, magenta)
$brown = %ansi(reset)%ansi(brown)
$gray = %ansi(reset)%ansi(gray)
$yellow = %ansi(yellow)
$white = %ansi(white)
$lgreen = %ansi(reset)%ansi(green)
$lcyan = %ansi(reset)%ansi(cyan)
$lblue = %ansi(reset)%ansi(blue)
$lred = %ansi(reset)%ansi(red)
$lmagenta = %ansi(reset)%ansi(magenta)
$newline = %replace($newline,"[green]", $green)
$newline = %replace($newline,"[cyan]", $cyan)
$newline = %replace($newline,"[blue]", $blue)
$newline = %replace($newline,"[red]", $red)
$newline = %replace($newline,"[magenta]", $magenta)
$newline = %replace($newline,"[brown]", $brown)
$newline = %replace($newline,"[gray]", $gray)
$newline = %replace($newline,"[yellow]", $yellow)
$newline = %replace($newline,"[white]", $white)
$newline = %replace($newline,"[lgreen]", $lgreen)
$newline = %replace($newline,"[lcyan]", $lcyan)
$newline = %replace($newline,"[lblue]", $lblue)
$newline = %replace($newline,"[lred]", $lred)
$newline = %replace($newline,"[lmagenta]", $lmagenta)
#RETURN $newline
|
In the above function, I stick the actual escape codes generated by the %ascii into the string in place of the markers, which gives me a colorized string that works pretty much everywhere.
That's what I was trying to solve, and by adding the 'reset' into the color vars, it made the whole process easier for my needs. |
|
|
 |
chris123zugg Adept
Joined: 23 Aug 2013 Posts: 214
|
Posted: Tue Apr 15, 2025 12:16 am |
you can also use the hexidecimal codes for %ansi...
%ansi(41)HI THERE%ansi(reset) |
|
|
 |
|
|
|
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
|
|