BBC BASIC 2.31 for the Tatung Einstein, showing DRIFT, the text adventure the course builds, in the middle of a game
← Back to Courses
module
23

Things

Introduction

A ship needs things in it: things to find, to carry, and to use. DRIFT has four. Two you can pick up - a data pad and a power cell - and two are part of the ship - the navigation console and a wall locker. This section writes down what they are and where they are, and lets the player see them.

Four Lists

Each object has four facts, kept in four arrays, all numbered alike:

ArrayHoldsFor the pad
O$()the word the player typesPAD
OD$()how the game names itA DATA PAD
L%()where it is1 - the cryo bay
F%()whether it is fixed in place0 - no

L%() is the clever one. A room number means the object is in that room. Two other numbers mean something else, and the next sections use them: 0 means the player is carrying it, and -1 means it is nowhere yet - the power cell is shut in the locker, and will not be anywhere until the locker is opened.

Console and locker are fixed (F% is 1). The room descriptions already mention them, so the game does not list them again.

What Is Here

PROCITEMS goes through the objects and prints each one that is in this room and not fixed. PROCLOOK calls it after the exits.

The Code

LOAD "ADV3". Add:

1040 DIM O$(4),OD$(4),L%(4),F%(4):RESTORE 3200:FOR I%=1 TO 4:READ O$(I%),OD$(I%),L%(I%),F%(I%):NEXT
1140 PROCITEMS
1400 DEF PROCITEMS
1410 LOCAL I%
1420 FOR I%=1 TO 4
1430 IF L%(I%)=R% AND F%(I%)=0 THEN PRINT "YOU CAN SEE ";OD$(I%);"."
1440 NEXT
1450 ENDPROC
3200 DATA PAD,A DATA PAD,1,0
3210 DATA CELL,A POWER CELL,-1,0
3220 DATA CONSOLE,THE CONSOLE,4,1
3230 DATA LOCKER,THE LOCKER,2,1

Starting from

LOAD "ADV3" from S22. When it works, SAVE "ADV4".

What you should see

The cryo bay now ends with YOU CAN SEE A DATA PAD., and it is still there when you come back:

CRYO BAY
YOU WAKE IN THE CRYO BAY. YOUR SLEEP
POD STANDS OPEN. THE OTHER PODS ARE
EMPTY AND DARK.
EXITS: EAST
YOU CAN SEE A DATA PAD.
WHAT NOW?

The data pad in the cryo bay

Change One Thing

  • Change line 3210 to DATA CELL,A POWER CELL,1,0. What do you see in the cryo bay now?
  • Put it back and change line 3200 to DATA PAD,A DATA PAD,1,1. Where has the pad gone?
  • Run it, QUIT, and type at the >: FOR I%=1 TO 4:PRINT O$(I%);" ";L%(I%);" ";F%(I%):NEXT. Read the table: where is everything?

Exercises

23.1 Make the game start with the power cell lying in the corridor instead of shut in the locker.

23.2 What would L%(1)=0 mean, if the program set it? Try it at the > after a QUIT, then type PROCITEMS. Is the pad still in the room?

Worked solutions are in Appendix II.

When It Goes Wrong

SymptomCause
Out of DATA at line 1040An object's DATA line has too few items. It needs four.
An object you placed does not showIt is fixed (F% 1), or in another room.

Summary

Four arrays describe the objects: the word, the name, where it is, and whether it is fixed. A room number places it; 0 will mean carried and -1 nowhere yet. PROCITEMS lists what can be seen. Save it as ADV4.

Next

S24, Taking And Dropping - picking things up.

Get the Newsletter

New guides, disk images and community finds, roughly once a quarter. No spam, we promise, this isn't Tatung's marketing department.
Your subscription could not be saved. Please try again.
Your subscription has been successful.

Newsletter

Subscribe to our newsletter and stay updated.