It's programming time!/Batch/CYOA

From Create Your Own Story

CYOA

Let's try something fun.

We can make a Choose Your Own Story in a batch script:

  1. Hopefully you're able to make a batch file by now.
  2. Add the following lines to the file:
@echo off
echo Today you are going on an adventure.
:BEGIN
echo 1.) Go outside.
echo 2.) Stay inside.
set/p input=What do you do^? 
if %input%==1 goto OUTSIDE
echo But you need adventure. Maybe you should consider again.
goto BEGIN
:OUTSIDE
echo You're outside now. What will you do^?
:OPTIONS
echo 1.) Climb a tree.
echo 2.) Go back inside.
echo 3.) Ride your bike.
set/p input=Pick an option^? 
if %input%==1 goto TREE
if %input%==2 goto INSIDE
goto BIKE
:TREE
echo You're up a tree. Now what^?
echo 1.) Stay in the tree.
echo 2.) Climb back down.
echo 3.) Ride your bike.
set/p input=Pick an option^? 
if %input%==1 goto TREE
if %input%==3 goto DEATH
echo You decide to climb down.
goto OPTIONS
:INSIDE
echo But what about your adventure^? Maybe you should consider going back out.
goto BEGIN
:BIKE
set/p color=What kind of bike do you have^? 
echo You ride your %color% bike for a while.
echo Now what^?
goto OPTIONS
:DEATH
echo You try to ride your %color% bike in a tree. That was not a good idea.
echo. You've died.
echo.
pause
exit
  1. Save your file without any formatting (Plain text).
  2. Double click your .bat file to execute the commands.

Remember: Don't edit the batch file while it's running. You can get unexpected errors that way. Be careful with complicated scripts.

Personal tools