I am working on a text based adventure game for a few friends and I to work through in batch. I'd like to make the option to have an entire section of variables echoed when wanted. Below is the entry code. The first section, Variables, is not an accessed section, but creates variables prior to the game starting. The second section, stats, provides these variables echoed.
@ECHO OFF
::Variables
set Name=Und
set Gender=Und
set Age=Und
set Gold=0
set Hunger=Satisfied
set Illness=None
set Wounds=None
set CHP=10
set MHP=10
set CMP=0
set MMP=0
goto Start
::Stats
:Stats
cls
echo Name: %Name%
echo Gender: %Gender%
echo Age: %Age%
echo Gold: 0
echo.
echo Health
echo Hunger: %Hunger%
echo Illness: %Illness%
echo Wounds: %Wounds%
echo.
echo Stats
echo HP: %CHP%/%MHP%
echo MP: %CMP%/%MMP%
My current solution to this issue is using
set /p "situation"= :
if "%situation%"=="1" goto nextpart
if "%situation%"=="2" goto nextpart
if "%situation%"=="3" goto nextpart
if "%situation%"=="Stats" goto Stats.
The issue with this method, however, is that once in stats, I have no way to jump to the previous section. It would require me making an exit gateway to every possible section I've created. So the question: Can I have a series of variables echoed without leaving the current section?
You can use Call:stats
in place of goto:stats
.
Like this it will comme back in the current section
Edit :
@echo off
set $var=1000
call:aff
echo done
exit/b
:aff
echo %$var%