我正在批量制作一个选择你自己的冒险游戏,我想在其中包含统计数据来跟踪你在游戏中的表现。我想显示统计信息,但每次我有cls
命令时都必须这样做,而且因为我会经常收到那个命令,所以我做了一个块调用:Stats
,这样我就可以在每次需要时调用它。它工作正常,但显示统计信息后的叙述似乎不再有效。我想保留:colorEcho
块,这样玩家就可以区分对话、叙述和输入选择的命令。有想法该怎么解决这个吗?
:Start
::Game goes here.
cls
Echo Please enter your player name.
set /p PlayerName="Player name: "
cls
call :Stats
call :colorEcho 7 "You lay on the cold, hard ground, sleeping away. It's been 1 month since the Virus spread..."
Echo.
call :colorEcho 7 "The sun rises over the horizon, warming up your dirt-caked body."
Echo .
pause
exit
:Stats
call :colorEcho A "Current Health = "
call :colorEcho C " %Health%"
Echo.
call :colorEcho A "Hunger = "
call :colorEcho C " %Food%"
Echo.
call :colorEcho A "Thirst = "
call :colorEcho C " %Water%"
Echo.
call :colorEcho A "Infection = "
call :colorEcho C " %Infection%"
Echo.
call :colorEcho A "Stamina = "
call :colorEcho C " %Stamina%"
Echo.
Echo.
pause
:colorEcho
echo off
<nul set /p ".=%DEL%" > "%~2"
findstr /v /a:%1 /R "^$" "%~2" nul
del "%~2" > nul 2>&1i
旁注:我已经定义了所有变量。这是我确定的。
应该发生什么:
实际发生的情况: