It's programming time!/Batch/CYOA

From Create Your Own Story

< It's programming time! | Batch(Difference between revisions)
(Something kind of cool for peaking interest.)
m (CYOA)
 
(One intermediate revision not shown)
Line 41: Line 41:
  goto BEGIN
  goto BEGIN
  :BIKE
  :BIKE
-
  set/p color=What color bike do you have^?
+
  set/p color=What kind of bike do you have^?  
  echo You ride your %color% bike for a while.
  echo You ride your %color% bike for a while.
  echo Now what^?
  echo Now what^?
Line 56: Line 56:
*[[It's_programming_time!/Batch/Intro|This is cool. Let me start from the beginning.]]
*[[It's_programming_time!/Batch/Intro|This is cool. Let me start from the beginning.]]
 +
*[[It's_programming_time!/Batch/Goto|I want to know how '''goto''' works.]]
 +
*[[It's_programming_time!/Batch/If|'''if''' looks tricky, how do I use it?]]
 +
*[[It's_programming_time!/Batch/Variable|I want to '''set''' variables too. Tell me how that works.]]
[[Category:It's programming time!|Batch]]
[[Category:It's programming time!|Batch]]
[[Category:It's programming time!/Batch|CYOA]]
[[Category:It's programming time!/Batch|CYOA]]

Current revision as of 04:18, 16 July 2016

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