03-29-2017, 05:56 AM
It's been a long time since I did this stuff but I agree with Saiyaka. Define the variable before the IF and it will work. Good luck with the game. I enclose the corrected code below.
@echo off
title Game
color 02
echo Once upon a time a girl walked into a cave.
echo Upon entering she found a portal. Its surface was a deep purple, spirals all over its surface
pause
echo.
:enter/run
echo --------------------------------------------------------------------------------
echo [e] to enter the portal
echo [r] to run away
echo.
set /p enter/run=
cls
if %enter/run%==e (
echo Your character takes a breath, closes her eyes, and steps forward.
echo.
echo Your characters body feels as if its being ripped apart.
echo.
echo Your character has lost consciousness.
pause
cls
goto jail
)
if %enter/run%==r (
echo Your character turns around and begins to run.
echo.
echo Your character feels a demon snatching at her feet.
echo.
echo Your character trips.
echo.
echo Your character has been dragged into the portal.
pause
cls
goto jail
)
if not %enter/run%==r (
echo ERROR
echo INVALID ASNWER
echo.
echo PLEASE TRY AGAIN
pause
cls
goto enter/run
)
:jail
cls
echo Your character wakes up bleary-eyed in a cell.
echo.
echo Your character peers around, trying to see in the semi-darkness.
pause
cls
:attack/go
echo Your character hears a small voice saying,
echo "Take this, use it to escape"
echo.
echo A small dagger drops into your character's lap.
echo.
echo Your character looks around for whoever has given you this weapon
pause
cls
echo A guard flings the door open and shouts,
echo "COME WITH ME"
pause
echo --------------------------------------------------------------------------------
echo [a] to attack the guard
echo [g] to go with the guard
echo.
set /p attack/go=
cls
set /a enemyHP = 25
if %attack/go%==a (
cls
color 0C
echo YOUR CHARACTER HAS ENTERED BATTLE!!!
echo.
echo YOUR WEAPON IS A DAGGER.
echo.
echo YOUR CHARACTER HAS 100HP
echo.
echo YOUR ENEMY HAS %enemyHP%HP
pause
)
if %attack/go%==g (
)
if not %attack/go%==a (
echo ERROR
echo INVALID ASNWER
echo.
echo PLEASE TRY AGAIN
pause
cls
goto attack/go
)
@echo off
title Game
color 02
echo Once upon a time a girl walked into a cave.
echo Upon entering she found a portal. Its surface was a deep purple, spirals all over its surface
pause
echo.
:enter/run
echo --------------------------------------------------------------------------------
echo [e] to enter the portal
echo [r] to run away
echo.
set /p enter/run=
cls
if %enter/run%==e (
echo Your character takes a breath, closes her eyes, and steps forward.
echo.
echo Your characters body feels as if its being ripped apart.
echo.
echo Your character has lost consciousness.
pause
cls
goto jail
)
if %enter/run%==r (
echo Your character turns around and begins to run.
echo.
echo Your character feels a demon snatching at her feet.
echo.
echo Your character trips.
echo.
echo Your character has been dragged into the portal.
pause
cls
goto jail
)
if not %enter/run%==r (
echo ERROR
echo INVALID ASNWER
echo.
echo PLEASE TRY AGAIN
pause
cls
goto enter/run
)
:jail
cls
echo Your character wakes up bleary-eyed in a cell.
echo.
echo Your character peers around, trying to see in the semi-darkness.
pause
cls
:attack/go
echo Your character hears a small voice saying,
echo "Take this, use it to escape"
echo.
echo A small dagger drops into your character's lap.
echo.
echo Your character looks around for whoever has given you this weapon
pause
cls
echo A guard flings the door open and shouts,
echo "COME WITH ME"
pause
echo --------------------------------------------------------------------------------
echo [a] to attack the guard
echo [g] to go with the guard
echo.
set /p attack/go=
cls
set /a enemyHP = 25
if %attack/go%==a (
cls
color 0C
echo YOUR CHARACTER HAS ENTERED BATTLE!!!
echo.
echo YOUR WEAPON IS A DAGGER.
echo.
echo YOUR CHARACTER HAS 100HP
echo.
echo YOUR ENEMY HAS %enemyHP%HP
pause
)
if %attack/go%==g (
)
if not %attack/go%==a (
echo ERROR
echo INVALID ASNWER
echo.
echo PLEASE TRY AGAIN
pause
cls
goto attack/go
)