The Intermediate Text Adventure Tutorial
Welcome to the Intermediate Text Adventure Course. In this section, you will learn how to declare variables, polish your if then statements, and some other things.

First how to declare variables. We do this by using the DIM statement. Observe.

DIM pencil AS STRING

Here we are declaring the variable pencil, and we are telling the computer that it will be a string. A string is just a string of characters such as the following: This is a string. That's all it is.

DIM pencil AS INTEGER

Here we are declaring the variable pencil as an integer, or number. Now lets put it into a program, shall we?

DIM pencil AS STRING
pencil = "nottaken"
5 CLS
PRINT "Do you want to take the pencil? y\n"
INPUT a$
IF pencil = "taken" AND a$ = "y" then 10
if a$ = "y" then 20
If a$ = "n" then 30
If pencil = "taken" AND a$ = "n" then 40

10 PRINT "You already have the pencil. press enter"
input a$
goto 5
20 pencil = "taken"
print "You have taken the pencil. press enter"
input a$
goto 5
30 print "That's ok. I used to be scared of pencils too. Press "
input a$
goto 5
40 print "That's good because you already have the pencil. Press "
input a$
goto 5


You can see what all of these lines do. When you take the pencil the variable pencil = "taken". You can manipulate this when you write games to do many good things.

One last thing about if then statements.

10 cls
print "Are you ready? y\n"
input a$
if a$ = "" then 5
5 goto 10

This program is not finished, but for the sake of explanation, it will do. Look at the line: if a$ = "" then 5. Always include something like this with the quote marks "" with nothing in them first, never last. What this does, is now the first thing you type, if it's not one of the choices, will go right back to line 10. So, it makes it look like nothing happend. What's this good for? You make it so you have to type in a valid command, or it won't respond. This is also how you would password protect a program.

The EEEEEEEEENNNNNNNNNNNNDDDDDDDDDDDDDD

Go on to The Next Text Adventure Tutorial