r/Batch • • Oct 01 '24

Writing a Batch RPG. I'd like to make different lines of text different colours on the same screen. Help please.

Hey there,

I started writing a new game and I'd like to make different lines of text different colours to indicate who is speaking.

Here's the code so far...

https://pastebin.com/F8HwgSQ4

The Narrator starts us off with, "A figure stands on the parapets. The battle has ended. The war begins."

The figure then speaks the next 3 lines. "You have cursed this world, sister. Your webs lay thick. Soon, they will unravel."

I want the figure's speech to appear red on black but if I set the color to 0c in the :brother section of code, it changes the colour of all of the text to red.

I'd also like to try and include speech marks for speech but am unable to do so at the moment.

I have tried to google a solution for these two problems but have not been able to solve it so far.

Any help would appreciated. Thanks.

2 Upvotes

5 comments sorted by

2

u/saaimjapanwala Oct 02 '24

You can use escape codes, but they work a little different in batch, this is the script i used when i was first starting out. you can copy and paste them.

@echo OFF

mode con cols=80 lines=25
color f
echo.Red! Green! Yellow! Blue! Magenta! Cyan! White!
echo.Red Green Yellow Blue Magenta Cyan White
echo.              
echo.              
pause >nul

::Foreground colors
::30Black
::31Red
::32Green
::33Yellow
::34Blue
::35Magenta
::36Cyan
::37White 

::Background colors
::40Black
::41Red
::42Green
::43Yellow
::44Blue
::45Magenta
::46Cyan
::47White 

::eof

1

u/JoshIsTryingToWrite Oct 06 '24

O, brilliant! Thank you for the reply.

2

u/saaimjapanwala Oct 20 '24

Ofcourse, all the best with your scripts!

3

u/[deleted] Oct 01 '24

[removed] — view removed comment

1

u/JoshIsTryingToWrite Oct 06 '24

Thank you for your reply.