Solved something wrong with my batch game.

April 17, 2020 at 12:35:24
Specs: Windows 10
in the b label, (in the start of game developer mode you can go straight into label b) when you write option, game exits, i cheked if if had double = and it had, i tried something with food label, but i cant find problem. please help.

@echo off
title Jungle aventure.
set day = 1
set food = 0
set hunger = 10
echo Welcome!
pause
cls
echo This is jungle aventure!
pause
:a
cls
echo Select option
echo 1 = start game
echo 2 = info
echo 3 = exit
echo 4 = developer test
echo My option is:
set /p o1=
if %o1% == 1 goto game
if %o1% == 2 goto info
if %o1% == 3 goto exit
if %o1% == 4 (
set name = test
goto b
)
else goto invaild
:invalid
cls
echo Invalid input!
pause
goto a
:exit
exit
:info
cls
echo made by koi
echo warning, game dont save progres
echo if you see any bugs, report to mail franczyslaw09@gmail.com
pause
goto a
:game
cls
echo Pick your name:
set /p name=
cls
echo A long time ago, there was a litle vilage.
pause
cls
echo Vilagers, in this vilage where fine, except for of one.
pause
cls
echo He was powerfull in soul, but weak in hand, not like others, he excepted this.
pause
cls
echo His name was %name%.
pause
cls
echo One time. Hes was thinking: "Why im acccepting this?".
pause
cls
echo And he stand up. And said: "Im not gonna accept this!".
pause
cls
echo He walked to place where his father sword was placed, he grab it and scream: "im not gonna accept this!".
pause
cls
echo He returned to village. One man talked to him "%name%! You are so weak that i can kill you with my finger!".
pause
cls
echo %name% get to hand his father sword, and killed that man.
pause
cls
echo every one was shocked.
pause
cls
echo his soul was so strong, so his sword start shine and every one in 5 meter radius got blinded.
pause
cls
echo for that thing, he was exiled to jungle.
pause
cls
echo JUNGLE ADVENTURE
pause
:b
cls
echo You are in jungle, its day %day% of your adventure, what you do?
echo 1 = find food
echo 2 = get materials
echo 3 = explore
set /p o2 =
if %o2% == 1 goto food
if %o2% == 2 goto materials
if %o2% == 3 goto explore
else goto inv2
:food
cls
echo You walked through jungle, you see some carrots in ground, you grab them, and return.
set /a food = %food% + 1
pause
cls
set /a rfood = %random% %% 2 + 1
if %rfood% == 2 (
set /a hunger = %hunger% - 1
echo You lost 1 hunger! you have %hunger% hunger!
echo Do you want to eat food?
echo 1 = yes
echo 2 = no
set /p o3 =
if %o3% == 1 goto eat1
if %o3% == 2 goto b
)
else (
echo You dont lost any hunger! You are lucky!
pause
)
echo You have %food% food.
goto b
:eat1
echo You eated 1 food! Now you have %food% food, and %hunger% hunger.
pause
goto b
:materials
:explore
:inv2
echo invalid input!
pause
goto b

message edited by koi1212


See More: something wrong with my batch game.

Reply ↓  Report •

✔ Best Answer
April 18, 2020 at 10:57:56
Try removing the space between o2 and the equal sign:

Change set /p o2 =

To set /p o2=

MIKE

http://www.skeptic.com/



#1
April 17, 2020 at 12:46:04

Reply ↓  Report •

#2
April 17, 2020 at 18:07:15
Batch files aren't my thing, but there sure are a lot of misspelled words.

Reply ↓  Report •

#3
April 18, 2020 at 02:00:07
nope, didint work, batch files dont work like that


Reply ↓  Report •

Related Solutions

#4
April 18, 2020 at 10:57:56
✔ Best Answer
Try removing the space between o2 and the equal sign:

Change set /p o2 =

To set /p o2=

MIKE

http://www.skeptic.com/


Reply ↓  Report •

#5
April 19, 2020 at 16:02:29
Try this:

echo Some info
timeout /t 3 > nul

:question
echo:
echo ========== Question? ==========
echo:
echo [A] Choice 1
echo:
echo [B] Choice 2
echo:
echo [C] Exit
echo ______________________________
echo:
choice /c ABC /n /m "Your Choice? "

if %errorlevel%==1 goto:choice1
if %errorlevel%==2 goto:choice2
if %errorlevel%==3 goto:eof
else goto:question

:choice1
REM insert code

:choice2
REM insert code

You wont need to specify exit with eof.
goto:eof means goto end of file.
I like to use errorlevels for choices: Choice A is errorlevel 1, B is errorlevel 2 and so on.. Remember to add more letters or numbers to the choice command as well as adding more errorlevels if needed.
The "echo:" will be displayed as an empty line, and is a nice way to make the output look a bit better and tidy.

I would recommend checking out powershell.
Anyway, hope this helps.

Edit: Prompts

set /p question=Some question?
if /i %question% -eq "1" goto:choice1

you can also use -neq, -gtr and so on.

message edited by Kilavila


Reply ↓  Report •

Ask Question