I'm trying to make a game using batch files. At the beginning of the game, the player can set the colors of the command prompt window. I want to save the color they choose (a 2-digit hex code) as a parameter or variable, and put it into another file which saves the color code. I tried to do this (see below) but it doesn't seem to work. Does anyone have any answers?
Here's my code (I'm somewhat new to coding, so I'm sorry if it doesn't look great):
Batch File 1:
set colorvalue=F0
set %6=%colorvalue%
pause
exit
Batch File 2:
echo The color should change once you continue.
pause
color %6
pause
echo Did it work?
pause
exit
Along with this, I tried using the contents of a .txt file as the color value.
Batch File 1:
@echo off
echo F0>value.txt
pause
exit
The above code should make value.txt (which is in the same location as the batch file) say F0, and this works.
Batch File 2:
echo off
color value.txt
pause
exit
I'm assuming I'm doing something wrong at "color value.txt." The output is simply the color help message.
COLOR [attr]
attr Specifies color attribute of console output
Color attributes are specified by TWO hex digits -- the first
corresponds to the background; the second the foreground. Each digit
can be any of the following values:
0 = Black 8 = Gray
1 = Blue 9 = Light Blue
2 = Green A = Light Green
3 = Aqua B = Light Aqua
4 = Red C = Light Red
5 = Purple D = Light Purple
6 = Yellow E = Light Yellow
7 = White F = Bright White
If no argument is given, this command restores the color to what it was
when CMD.EXE started. This value either comes from the current console
window, the /T command line switch or from the DefaultColor registry
value.
The COLOR command sets ERRORLEVEL to 1 if an attempt is made to execute
the COLOR command with a foreground and background color that are the
same.
Example: "COLOR fc" produces light red on bright white
I tried all of this, but the color doesn't change. I'm willing to try anything, any help is appreciated! :D
P.S. I've tried simply setting %6 to the hex code (F0 as an example) but that didn't work either.