Excellent work Fangs!
Looks like you are on top of it.
This brings me to talk about the different methods of coding the game. I noticed you used a flag for the rug. That is a method that actually works fine and I also use that method as well, nothing wrong with it at all.
The trigger method is an alternative to using flags, it's just another way to do the same thing. I like the trigger method because I can keep most of the stuff in one code block and it's easier for me to manage. Yet, either way is ok, as long as it does the job! I just wanted you to know about the other methods so that way you can have another tool at your disposal.
I have added the 'MOVE' command to the latest build of the zork engine. I coded a trigger management system that monitors the rug, the kitchen window and the trapdoor. The system is simply a small subroutine that I put right after the main gameloop. You are welcome to take a look at it and take whatever you want from it. It's completely up to you. Anyway, you are doing great as it is!
REM Project: Zork Tutorial
REM Created: 5/19/2008 7:37:05 PM
REM
REM ***** Main Source File *****
REM
REMSTART
CONTAINER RULES
1. PLAYER CANNOT TAKE 'ON' TYPE CONTAINERS
REMEND
REM set display mode 640, 480, 16
set display mode 800, 640, 32
REM SET TEXT FONT "TIMES NEW ROMAN"
SET TEXT FONT "ARIAL"
SET TEXT SIZE 14
SET TEXT TO BOLD
REM MAXIMUM NUMBER OF LOCATIONS
MAX_LOC = 8
REM CREATE A TYPE DEFINITION FOR THE LOCATION VARIABLES
type LOC
LOCATION as string
NORTH as integer
SOUTH as integer
EAST as integer
WEST as integer
UP as integer
DOWN as integer
endtype
REM CREATE AN ARRAY OF LOCATIONS
dim LOC_ARRAY(MAX_LOC) as LOC
REM POPULATE THE ARRAY WITH MAP LOCATION DATA
for i = 1 to MAX_LOC
read LOC_ARRAY(i).LOCATION
read LOC_ARRAY(i).NORTH
read LOC_ARRAY(i).SOUTH
read LOC_ARRAY(i).EAST
read LOC_ARRAY(i).WEST
read LOC_ARRAY(i).UP
read LOC_ARRAY(i).DOWN
next i
REM LOCATION N S E W U D - NORTH SOUTH EAST WEST UP DOWN
data "West of House", 2,4,-1,0,0,0
data "North of House", 0,-2,3,1,0,0
data "East of House", 2,4,0,0,0,0
data "South of House", -2,0,3,1,0,0
data "Kitchen", 0,0,0,6,7,0
data "Living Room", 0,0,5,-3,0,0
data "Attic", 0,0,0,0,0,5
data "Cellar", 0,0,0,0,0,0
REM OBJECTS
REM DECLARE MAXIMUM NUMBER OF OBJECTS IN GAME
MAX_OBJ = 18
REM CREATE A TYPE DEFINITION FOR OBJECTS
TYPE OBJ
NAME AS STRING
DESC1 AS STRING
DESC2 AS STRING
LOCATION AS FLOAT
INVENTORY AS INTEGER
SHOW AS INTEGER
TAKE AS INTEGER
C_BELONGS_TO AS INTEGER
C_ON AS INTEGER
C_IN AS INTEGER
C_LOCATION AS INTEGER
C_INVENTORY AS INTEGER
OPEN AS INTEGER
WEIGHT_UNITS AS INTEGER
SIZE_UNITS AS INTEGER
WEIGHT_LIMIT AS INTEGER
SIZE_LIMIT AS INTEGER
LOCKED AS INTEGER
MOVE AS INTEGER
ENDTYPE
REM CREATE AN ARRAY OF OBJECTS
DIM OBJ_ARRAY(MAX_OBJ) AS OBJ
REM POPULATE THE ARRAY WITH OBJECT DATA
FOR I = 1 to MAX_OBJ
READ OBJ_ARRAY(I).NAME
READ OBJ_ARRAY(I).DESC1
READ OBJ_ARRAY(I).DESC2
READ OBJ_ARRAY(I).LOCATION
READ OBJ_ARRAY(I).INVENTORY
READ OBJ_ARRAY(I).SHOW
READ OBJ_ARRAY(I).TAKE
READ OBJ_ARRAY(I).C_BELONGS_TO
READ OBJ_ARRAY(I).C_ON
READ OBJ_ARRAY(I).C_IN
READ OBJ_ARRAY(I).C_LOCATION
READ OBJ_ARRAY(I).C_INVENTORY
READ OBJ_ARRAY(I).OPEN
READ OBJ_ARRAY(I).WEIGHT_UNITS
READ OBJ_ARRAY(I).SIZE_UNITS
READ OBJ_ARRAY(I).WEIGHT_LIMIT
READ OBJ_ARRAY(I).SIZE_LIMIT
READ OBJ_ARRAY(I).LOCKED
READ OBJ_ARRAY(I).MOVE
NEXT I
REM OPEN OBJECTS, 0 = NOT OPENABLE, 1 = CLOSED POSITION, 2 = OPEN POSITION
REM MOVE OBJECTS, 0 - NOT MOVEABLE, 1 - MOVEABLE, 2 - MOVED ONCE & NO LONGER MOVEABLE (RUG)
REM NAME, DESC1, DESC2, LOCATION, INVENTORY, SHOW, TAKE, C_BELONGS_TO, C_ON, C_IN
DATA "mailbox","small","",1,0,1,-10,0,0,1,0,0,1,0,0,0,2,0,0
DATA "leaflet","","",0,0,1,1,1,0,0,1,0,0,0,0,0,0,0,1
DATA "sword","elvish","",5,0,1,1,0,0,0,0,0,0,10,3,0,0,0,1
DATA "table","","",5,0,0,-6,0,1,0,0,0,0,0,0,30,10,0,0
DATA "sack","brown","elongated",0,0,1,1,8,0,1,0,0,1,1,1,0,0,0,1
DATA "garlic","clove of","clove",0,0,1,1,5,0,0,0,0,0,0,0,0,0,0,1
DATA "sandwich","pepper","hot",0,0,1,1,5,0,0,0,0,0,0,0,0,0,0,1
DATA "trunk","wooden","",5,0,1,1,0,0,1,0,0,1,7,5,5,4,0,1
DATA "platter","","",5,0,1,1,0,1,0,0,0,0,2,2,2,2,0,1
DATA "window","small","",3,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0
DATA "trapdoor","small","",3,0,0,-6,0,0,0,0,0,1,0,0,0,0,0,0
DATA "rug","large","oriental",6,0,0,-18,0,0,0,0,0,1,0,0,0,0,0,1
DATA "north","","",0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
DATA "south","","",0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
DATA "east","","",0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
DATA "west","","",0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
DATA "up","","",0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
DATA "down","","",0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
REM PLAYER STARTING LOCATION
PLR_LOC = 5; REM LOCATION NUMBER 1 = WEST OF HOUSE
REM PLAYER CAN'T GO THAT WAY MESSAGES
MAX_NOGO = 3
DIM NOGO$(MAX_NOGO)
FOR I = 0 TO MAX_NOGO
READ NOGO$(I)
NEXT I
REM MESSAGES 0 - 3
DATA "You can't go that way."
DATA "The door is boarded and you can't remove the boards."
DATA "The windows are all boarded."
DATA "The door is nailed shut."
REM PARSER VARIABLES
REM COMMAND LENGTH
CL = 0
REM KEYWORDS
TYPE KW
KWORD AS STRING
KTYPE AS INTEGER
ENDTYPE
MAX_KW = 13 : REM TOTAL KEYWORDS
DIM KW_ARRAY(MAX_KW) AS KW
FOR I = 1 TO MAX_KW
READ KW_ARRAY(I).KWORD
READ KW_ARRAY(I).KTYPE
NEXT I
DATA "take", 1
DATA "drop", 1
DATA "put", 1
DATA "go", 1
DATA "open", 1
DATA "close", 1
DATA "move", 1
DATA "on", 4
DATA "in", 4
DATA "from", 4
DATA "and", 5
DATA "of", 6
DATA "top", 6
REM BATCH COMMAND ARRAY
TYPE BCA
CWORD AS STRING
CTYPE AS INTEGER
CNUM AS INTEGER
ENDTYPE
REMSTART
0 - UNKNOWN TYPE
1 - VERB
2 - OBJECT DESCRIPTION
3 - OBJECT
4 - PREPOSITION
5 - CONJUNCTION
REMEND
REM CREATE DYNAMIC ARRAY
DIM BWORDS() AS BCA
REM DISPLAY CURRENT LOCATION
GOSUB CRNT_LOC
REM DISPLAY CURRENT LOCATION DESCRIPTION
GOSUB CRNT_LOC_DESC
REM LINE SPACING
PRINT
REM DISPLAY OBJECTS AT PLAYER LOCATION
GOSUB DISPLAY_OBJECTS
REM *******************************************************
REM MAIN GAME LOOP
REM *******************************************************
DO
REM LINE SPACING
PRINT
REM GET PLAYER COMMAND
INPUT "> ", CMD$
CMD$ = LOWER$(CMD$)
REM RESET TO TOP OF SCREEN AFTER FOUR COMMANDS
CLS_CNT = CLS_CNT + 1
IF CLS_CNT > 3
CLS_CNT = 0
CLS
ENDIF
REM PROCESS COMMAND
GOSUB PARSE
REM LINE SPACING
PRINT
REM UPDATE GAMEWORLD - TRIGGERS
GOSUB UPDATE_GAMEWORLD
SYNC
LOOP
REM *******************************************************
REM END MAIN LOOP
REM *******************************************************
REM UPDATE GAMEWORLD
UPDATE_GAMEWORLD:
REM WINDOW TRIGGER
REM WINDOW IN KITCHEN AND EAST OF HOUSE
IF PLR_LOC = 5 OR PLR_LOC = 3
OBJ_ARRAY(10).LOCATION = PLR_LOC
ENDIF
REM IF WINDOW IS OPEN PLAYER CAN MOVE OUTSIDE OR INSIDE HOUSE ELSE HE CAN'T
IF OBJ_ARRAY(10).OPEN = 2
LOC_ARRAY(3).WEST = 5
LOC_ARRAY(5).EAST = 3
ELSE
LOC_ARRAY(3).WEST = 0
LOC_ARRAY(5).EAST = 0
ENDIF
REM RUG TRIGGER
REM IF RUG HAS BEEN MOVED THEN PUT TRAPDOOR IN LIVING ROOM
IF OBJ_ARRAY(12).MOVE = 2
OBJ_ARRAY(11).LOCATION = 6
ENDIF
REM TRAPDOOR TRIGGER
REM IF TRAPDOOR IS OPEN THEN LIVINGROOM.DOWN = CELLAR
REM ELSE LIVINGROOM.DOWN = NO
IF OBJ_ARRAY(11).OPEN = 2
LOC_ARRAY(6).DOWN = 8
ELSE
LOC_ARRAY(6).DOWN = 0
ENDIF
RETURN
REM DISPLAY CURRENT LOCATION
CRNT_LOC:
PRINT LOC_ARRAY(PLR_LOC).LOCATION
RETURN
REM END GOSUB
REM DISPLAY CURRENT LOCATION
CRNT_LOC_DESC:
SELECT PLR_LOC
CASE 1
PRINT "You are standing in an open field west of a white house, with a boarded front door."
ENDCASE
CASE 2
PRINT "You are facing the north side of a white house. There is no door here, and all"
PRINT "the windows are boarded up. To the north a narrow path winds through the trees."
ENDCASE
CASE 3
PRINT "You are behind the white house. A path leads into the forest to the east. In"
PRINT "one corner of the house there is a small window which is slightly ajar."
ENDCASE
CASE 4
PRINT "You are facing the south side of a white house. There is no door here, and all"
PRINT "the windows are boarded."
ENDCASE
CASE 5
PRINT "You are in the kitchen of the white house. A table seems to have been used"
PRINT "recently for the preparation of food. A passage leads to the west and a dark"
PRINT "staircase can be seen leading upward. A dark chimney leads down and to the east"
PRINT "is a small window which is open."
ENDCASE
CASE 6
PRINT "You are in the living room. There is a doorway to the east, a wooden door with"
PRINT "strange gothic lettering to the west, which appears to be nailed shut, a trophy"
PRINT "case, and a large oriental rug in the center of the room."
ENDCASE
CASE 7
PRINT "This is the attic. The only exit is a stairway leading down."
ENDCASE
CASE 8
PRINT "You are in a dark and damp cellar with a narrow passageway leading north, and"
PRINT "a crawlway to the south. On the west is the bottom of a steep metal ramp which"
PRINT "is unclimbable."
ENDCASE
ENDSELECT
RETURN
REM END GOSUB
REM DISPLAY OBJECTS
DISPLAY_OBJECTS:
REM LIST ANY OBJECTS AT PLAYER LOCATION
FOR I = 1 TO MAX_OBJ
IF OBJ_ARRAY(I).LOCATION = PLR_LOC AND OBJ_ARRAY(I).C_LOCATION = 0
IF OBJ_ARRAY(I).SHOW = 1
IF LEN(OBJ_ARRAY(I).DESC1) > 0
PRINT "There is a " + OBJ_ARRAY(I).DESC1 + " " + OBJ_ARRAY(I).NAME + " here."
ELSE
PRINT "There is a " + OBJ_ARRAY(I).NAME + " here."
ENDIF
ENDIF
IF OBJ_ARRAY(I).C_IN = 1 OR OBJ_ARRAY(I).C_ON = 1
DISPLAY_CNTNRS(I, MAX_OBJ)
ENDIF
ENDIF
NEXT I
RETURN
REM END SUB
REM DISPLAY CONTAINER OBJECTS
FUNCTION DISPLAY_CNTNRS(OBJECT AS INTEGER, MAX_OBJECT AS INTEGER)
IF OBJ_ARRAY(OBJECT).C_IN = 1 AND OBJ_ARRAY(OBJECT).OPEN <> 1
FRST_OBJ_CNT = 0
FOR I = 1 TO MAX_OBJECT
IF OBJ_ARRAY(I).C_BELONGS_TO = OBJECT
INC FRST_OBJ_CNT
IF FRST_OBJ_CNT = 1
PRINT "The " + OBJ_ARRAY(OBJECT).NAME + " contains:"
ENDIF
IF LEN(OBJ_ARRAY(I).DESC1) > 0
PRINT " A " + OBJ_ARRAY(I).DESC1 + " " + OBJ_ARRAY(I).NAME
ELSE
PRINT " A " + OBJ_ARRAY(I).NAME
ENDIF
IF OBJ_ARRAY(I).C_IN = 1 OR OBJ_ARRAY(I).C_ON = 1
DISPLAY_CNTNRS(I, MAX_OBJECT)
ENDIF
ENDIF
NEXT I
ENDIF
IF OBJ_ARRAY(OBJECT).C_ON = 1 AND OBJ_ARRAY(OBJECT).OPEN <> 1
FRST_OBJ_CNT = 0
FOR I = 1 TO MAX_OBJECT
IF OBJ_ARRAY(I).C_BELONGS_TO = OBJECT
INC FRST_OBJ_CNT
IF FRST_OBJ_CNT = 1
PRINT "On the " + OBJ_ARRAY(OBJECT).NAME + " sits:"
ENDIF
IF LEN(OBJ_ARRAY(I).DESC1) > 0
PRINT " A " + OBJ_ARRAY(I).DESC1 + " " + OBJ_ARRAY(I).NAME
ELSE
PRINT " A " + OBJ_ARRAY(I).NAME
ENDIF
IF OBJ_ARRAY(I).C_IN = 1 OR OBJ_ARRAY(I).C_ON = 1
DISPLAY_CNTNRS(I, MAX_OBJECT)
ENDIF
ENDIF
NEXT I
ENDIF
ENDFUNCTION
REM PARSE PLAYER COMMAND
PARSE:
REM RETURN TO MAIN LOOP IF CMD$ IS EMPTY
IF LEN(CMD$) < 1
PRINT "Time passes."
RETURN
ENDIF
MOV_MSG = 0
PLR_MOVE = 0
SELECT CMD$
CASE "n", "north", "go north"
IF LOC_ARRAY(PLR_LOC).NORTH > 0
PLR_LOC = LOC_ARRAY(PLR_LOC).NORTH
PLR_MOVE = 1
ELSE
MOV_MSG = ABS(LOC_ARRAY(PLR_LOC).NORTH)
PLR_MOVE = -1
ENDIF
ENDCASE
CASE "s", "south", "go south"
IF LOC_ARRAY(PLR_LOC).SOUTH > 0
PLR_LOC = LOC_ARRAY(PLR_LOC).SOUTH
PLR_MOVE = 1
ELSE
MOV_MSG = ABS(LOC_ARRAY(PLR_LOC).SOUTH)
PLR_MOVE = -1
ENDIF
ENDCASE
CASE "e", "east", "go east"
IF LOC_ARRAY(PLR_LOC).EAST > 0
PLR_LOC = LOC_ARRAY(PLR_LOC).EAST
PLR_MOVE = 1
ELSE
MOV_MSG = ABS(LOC_ARRAY(PLR_LOC).EAST)
PLR_MOVE = -1
ENDIF
ENDCASE
CASE "w", "west", "go west"
IF LOC_ARRAY(PLR_LOC).WEST > 0
PLR_LOC = LOC_ARRAY(PLR_LOC).WEST
PLR_MOVE = 1
ELSE
MOV_MSG = ABS(LOC_ARRAY(PLR_LOC).WEST)
PLR_MOVE = -1
ENDIF
ENDCASE
CASE "u", "up", "go up"
IF LOC_ARRAY(PLR_LOC).UP > 0
PLR_LOC = LOC_ARRAY(PLR_LOC).UP
PLR_MOVE = 1
ELSE
PLR_MOVE = -1
MOV_MSG = ABS(LOC_ARRAY(PLR_LOC).UP)
ENDIF
ENDCASE
CASE "d", "down", "go down"
IF LOC_ARRAY(PLR_LOC).DOWN > 0
PLR_LOC = LOC_ARRAY(PLR_LOC).DOWN
PLR_MOVE = 1
ELSE
PLR_MOVE = -1
MOV_MSG = ABS(LOC_ARRAY(PLR_LOC).DOWN)
ENDIF
ENDCASE
REM LOOK
CASE "l", "look"
PLR_MOVE = 1
ENDCASE
REM INVENTORY
CASE "i", "inv", "inventory"
INV_CNT = 0
FOR I = 1 TO MAX_OBJ
IF OBJ_ARRAY(I).INVENTORY = 1
INC INV_CNT
IF INV_CNT = 1 THEN PRINT "You are carrying:"
IF LEN(OBJ_ARRAY(I).DESC1) > 0
PRINT "A " + OBJ_ARRAY(I).DESC1 + " " + OBJ_ARRAY(I).NAME
ELSE
PRINT "A " + OBJ_ARRAY(I).NAME
ENDIF
DISPLAY_CNTNRS(I, MAX_OBJ)
ENDIF
NEXT I
IF INV_CNT = 0
PRINT "You are empty-handed."
ENDIF
RETURN
ENDCASE
ENDSELECT
IF PLR_MOVE = 1
REM DISPLAY NEW LOCATION
GOSUB CRNT_LOC
REM DISPLAY NEW LOCATION DESCRIPTION
GOSUB CRNT_LOC_DESC
REM LINE SPACING
PRINT
REM DISPLAY OBJECTS AT PLAYER LOCATION
GOSUB DISPLAY_OBJECTS
RETURN
ELSE
IF PLR_MOVE = -1
REM DISPLAY APPROPRIATE MESSAGE THAT PLAYER CANNOT GO THAT DIRECTION
PRINT NOGO$(MOV_MSG)
RETURN
ENDIF
ENDIF
REM FIRST STEP: COLLECT ALL WORS FROM SENTENCE AND PUT THEM IN AN ARRAY
GOSUB PARSER
RETURN
REM END SUB
REM PARSER
PARSER:
REM FIRST STEP: COLLECT ALL WORS FROM SENTENCE AND PUT THEM IN AN ARRAY
GOSUB WBATCH
REM SECOND STEP: ASSIGN A TYPE TO EACH WORD AND CHECK FOR SYNTAX ERRORS
GOSUB WTYPE
REM OBJECT VARIABLES
OBJECT1 = 0
OBJECT2 = 0
REM CHECK FOR COMMAND SENTENCE ERRORS
REM IF WORD NOT KNOWN
IF BWORDS(BW_INDX).CTYPE < 1 THEN RETURN
REM IF OBJECT DESC DOES NOT MATCH OBJECT
IF DWORD$ <> "" THEN RETURN
REM IF FIRST WORD NOT A VERB
IF BWORDS(0).CTYPE <> 1
COMMAND_MSG(1, "")
RETURN
ENDIF
REM IF COMMAND MORE THAN FOUR PARTS
IF BW_INDX > 3
COMMAND_MSG(1, "")
RETURN
ENDIF
REM IF COMMAND SENTENCE IS NOT STRUCTURED CORRECTLY
SELECT WT_INDX
CASE 1
COMMAND_MSG(1, "")
RETURN
ENDCASE
CASE 2
IF BWORDS(1).CTYPE <> 3
COMMAND_MSG(1, "")
RETURN
ELSE
OBJECT1 = BWORDS(1).CNUM
ENDIF
ENDCASE
CASE 3
COMMAND_MSG(1, "")
RETURN
ENDCASE
CASE 4
IF BWORDS(1).CTYPE <> 3 AND BWORDS(2).CTYPE <> 4 AND BWORDS(3).CTYPE <> 3
COMMAND_MSG(1, "")
RETURN
ELSE
OBJECT1 = BWORDS(1).CNUM
OBJECT2 = BWORDS(3).CNUM
ENDIF
ENDCASE
ENDSELECT
REM EXECUTE COMMAND
SELECT BWORDS(0).CWORD
CASE "take"
GOSUB CMD_TAKE
ENDCASE
CASE "drop"
GOSUB CMD_DROP
ENDCASE
CASE "put"
GOSUB CMD_PUT
ENDCASE
CASE "open"
GOSUB CMD_OPEN
ENDCASE
CASE "close"
GOSUB CMD_CLOSE
ENDCASE
CASE "move"
GOSUB CMD_MOVE
ENDCASE
ENDSELECT
RETURN
REM END PARSER
REM TAKE
CMD_TAKE:
REM IF PLAYER ALREADY HAS THAT OBJECT
IF OBJ_ARRAY(OBJECT1).INVENTORY = 1
COMMAND_MSG(3, "")
RETURN
ENDIF
REM CHECK IF FOUR PART COMMAND
IF WT_INDX = 4
REM CORRECT PREPOSITION?
IF BWORDS(2).CWORD <> "from"
COMMAND_MSG(1, "")
RETURN
ENDIF
REM IS SECOND OBJECT AT PLR LOCATION OR IN INVENTORY?
IF OBJ_ARRAY(OBJECT2).LOCATION <> PLR_LOC AND OBJ_ARRAY(OBJECT2).INVENTORY = 0
COMMAND_MSG(4, OBJ_ARRAY(OBJECT2).NAME)
RETURN
ENDIF
REM DOES FIRST OBJECT BELONG TO SECOND OBJECT?
IF OBJ_ARRAY(OBJECT1).C_BELONGS_TO <> OBJECT2
PRINT "The " + OBJ_ARRAY(OBJECT1).NAME + " isn't in the " + OBJ_ARRAY(OBJECT2).NAME + "."
RETURN
ENDIF
ENDIF
REM IF OBJECT NOT AT PLAYER LOCATION
IF OBJ_ARRAY(OBJECT1).LOCATION <> PLR_LOC
REM IF OBJECT IN CONTAINER AT PLAYERS LOCATION OR IN CONTAINER IN PLAYER INVENTORY
IF OBJ_ARRAY(OBJECT1).C_LOCATION <> PLR_LOC
IF OBJ_ARRAY(OBJECT1).C_INVENTORY <> 1
COMMAND_MSG(4, OBJ_ARRAY(OBJECT1).NAME)
RETURN
ENDIF
ENDIF
ENDIF
REM IS OBJECT TAKABLE?
IF OBJ_ARRAY(OBJECT1).TAKE < 1
COMMAND_MSG(ABS(OBJ_ARRAY(OBJECT1).TAKE), OBJ_ARRAY(OBJECT1).NAME)
RETURN
ENDIF
REM TAKE OBJECT
OBJ_ARRAY(OBJECT1).C_BELONGS_TO = 0
OBJ_ARRAY(OBJECT1).C_INVENTORY = 0
OBJ_ARRAY(OBJECT1).C_LOCATION = 0
OBJ_ARRAY(OBJECT1).INVENTORY = 1
OBJ_ARRAY(OBJECT1).LOCATION = 0
PRINT "Taken."
REM IF OBJECT IS CONTAINER THEN CHANGE INVENTORY STATUS OF ALL OBJECTS AND CONTAINERS INSIDE
IF OBJ_ARRAY(OBJECT1).C_IN > 0 OR OBJ_ARRAY(OBJECT1).C_ON > 0
TAKE_CNT_OBJ_STAT_CHANGE(OBJECT1, MAX_OBJ)
ENDIF
RETURN
REM END TAKE
REM IF OBJECT IS CONTAINER THEN CHANGE INVENTORY STATUS OF ALL OBJECTS AND CONTAINERS INSIDE
FUNCTION TAKE_CNT_OBJ_STAT_CHANGE(OBJECT AS INTEGER, MAX_OBJECT AS INTEGER)
IF OBJ_ARRAY(OBJECT).C_IN = 1
FOR I = 1 TO MAX_OBJECT
IF OBJ_ARRAY(I).C_BELONGS_TO = OBJECT
REM IF CONTAINER IS OPEN AND IT IS VISIBLE
IF OBJ_ARRAY(OBJECT).OPEN = 2 AND (OBJ_ARRAY(OBJECT).C_INVENTORY = 1 OR OBJ_ARRAY(OBJECT).INVENTORY = 1)
OBJ_ARRAY(I).C_INVENTORY = 1
ELSE
OBJ_ARRAY(I).C_INVENTORY = 0
ENDIF
OBJ_ARRAY(I).C_LOCATION = 0
OBJ_ARRAY(I).INVENTORY = 0
OBJ_ARRAY(I).LOCATION = 0
IF OBJ_ARRAY(I).C_IN = 1 OR OBJ_ARRAY(I).C_ON = 1
TAKE_CNT_OBJ_STAT_CHANGE(I, MAX_OBJECT)
ENDIF
ENDIF
NEXT I
ENDIF
IF OBJ_ARRAY(OBJECT).C_ON = 1
FOR I = 1 TO MAX_OBJECT
IF OBJ_ARRAY(I).C_BELONGS_TO = OBJECT
REM IF CONTAINER IS OPEN AND IT IS VISIBLE
OBJ_ARRAY(I).C_INVENTORY = 1
OBJ_ARRAY(I).C_LOCATION = 0
OBJ_ARRAY(I).INVENTORY = 0
OBJ_ARRAY(I).LOCATION = 0
IF OBJ_ARRAY(I).C_ON = 1 OR OBJ_ARRAY(I).C_IN = 1
TAKE_CNT_OBJ_STAT_CHANGE(I, MAX_OBJECT)
ENDIF
ENDIF
NEXT I
ENDIF
ENDFUNCTION
REM DROP
CMD_DROP:
REM IF PLAYER DOES NOT HAVE THAT OBJECT
IF OBJ_ARRAY(OBJECT1).INVENTORY = 0
COMMAND_MSG(5, OBJ_ARRAY(OBJECT1).NAME)
RETURN
ENDIF
REM DROP OBJECT
OBJ_ARRAY(OBJECT1).C_BELONGS_TO = 0
OBJ_ARRAY(OBJECT1).C_INVENTORY = 0
OBJ_ARRAY(OBJECT1).INVENTORY = 0
OBJ_ARRAY(OBJECT1).LOCATION = PLR_LOC
PRINT "Dropped."
REM IF OBJECT IS CONTAINER THEN CHANGE INVENTORY STATUS OF ALL OBJECTS AND CONTAINERS INSIDE
IF OBJ_ARRAY(OBJECT1).C_IN > 0
DROP_CNT_OBJ_STAT_CHANGE(OBJECT1, MAX_OBJ, PLR_LOC)
ENDIF
RETURN
REM END DROP
REM IF OBJECT IS CONTAINER THEN CHANGE INVENTORY STATUS OF ALL OBJECTS AND CONTAINERS INSIDE
FUNCTION DROP_CNT_OBJ_STAT_CHANGE(OBJECT AS INTEGER, MAX_OBJECT AS INTEGER, PLAYER_LOC AS INTEGER)
IF OBJ_ARRAY(OBJECT).C_IN = 1
FOR I = 1 TO MAX_OBJECT
IF OBJ_ARRAY(I).C_BELONGS_TO = OBJECT
OBJ_ARRAY(I).C_INVENTORY = 0
IF OBJ_ARRAY(OBJECT).OPEN <> 1
OBJ_ARRAY(I).C_LOCATION = PLAYER_LOC
ELSE
OBJ_ARRAY(I).C_LOCATION = 0
ENDIF
OBJ_ARRAY(I).INVENTORY = 0
OBJ_ARRAY(I).LOCATION = 0
IF OBJ_ARRAY(I).C_IN = 1
DROP_CNT_OBJ_STAT_CHANGE(I, MAX_OBJECT, PLAYER_LOC)
ENDIF
ENDIF
NEXT I
ENDIF
ENDFUNCTION
REM TAKE
CMD_PUT:
REM PUT COMMAND IS A FOUR-PART COMMAND
REM IF CORE COMMAND IS NOT 4 WORDS (words 0-3) THEN DISPLAY MESSAGE AND EXIT
IF BW_INDX <> 3
COMMAND_MSG(1, "")
RETURN
ENDIF
REM IF PLAYER DOES NOT HAVE FIRST OBJECT IN INVENTORY
IF OBJ_ARRAY(OBJECT1).INVENTORY = 0
COMMAND_MSG(5, OBJ_ARRAY(OBJECT1).NAME)
RETURN
ENDIF
REM IF PREPOSITION IS 'IN'
IF BWORDS(2).CWORD = "in"
REM IF SECOND OBJECT IS NOT AN 'IN' CONTAINER
IF OBJ_ARRAY(OBJECT2).C_IN <> 1
COMMAND_MSG(6, "")
RETURN
ENDIF
REM CHECK THAT OBJECT1 AND OBJECT2 ARE NOT THE SAME!!
IF OBJECT1 = OBJECT2
COMMAND_MSG(9, "")
RETURN
ENDIF
REM IF SECOND OBJECT IS CLOSED
IF OBJ_ARRAY(OBJECT2).OPEN = 1
COMMAND_MSG(7, OBJ_ARRAY(OBJECT2).NAME)
RETURN
ENDIF
REM IF FIRST OBJECT EXCEEDS SIZE LIMIT OF SECOND OBJECT
REM GET REMAINING CAPACITY OF SECOND OBJECT
IF (OBJ_ARRAY(OBJECT2).SIZE_LIMIT - REM_CAP(OBJECT2, MAX_OBJ)) < OBJ_ARRAY(OBJECT1).SIZE_UNITS
COMMAND_MSG(14, "")
RETURN
ENDIF
REM CHECK IF OBJECT AT PLAYER'S LOCATION?
IF OBJ_ARRAY(OBJECT2).LOCATION = PLR_LOC OR OBJ_ARRAY(OBJECT2).C_LOCATION
REM PLACE OBJECT1 IN OBJECT2
OBJ_ARRAY(OBJECT1).C_BELONGS_TO = OBJECT2
OBJ_ARRAY(OBJECT1).INVENTORY = 0
OBJ_ARRAY(OBJECT1).C_INVENTORY = 0
OBJ_ARRAY(OBJECT1).C_LOCATION = PLR_LOC
OBJ_ARRAY(OBJECT1).LOCATION = 0
PRINT "Done."
PUT_CNT_OBJ_STAT_CHANGE(OBJECT1, MAX_OBJ, PLR_LOC)
RETURN
ENDIF
REM CHECK IF OBJECT IN PLAYER'S INVENTORY:
IF OBJ_ARRAY(OBJECT2).INVENTORY = 1 OR OBJ_ARRAY(OBJECT2).C_INVENTORY = 1
REM PLACE OBJECT1 IN OBJECT2
OBJ_ARRAY(OBJECT1).C_BELONGS_TO = OBJECT2
OBJ_ARRAY(OBJECT1).INVENTORY = 0
OBJ_ARRAY(OBJECT1).C_INVENTORY = 1
OBJ_ARRAY(OBJECT1).C_LOCATION = 0
OBJ_ARRAY(OBJECT1).LOCATION = 0
PRINT "Done."
PUT_INV_CNT_OBJ_STAT_CHANGE(OBJECT1, MAX_OBJ, PLR_LOC)
RETURN
ENDIF
REM OBJECT NOT HERE
COMMAND_MSG(4, OBJ_ARRAY(OBJECT2).NAME)
RETURN
ENDIF
REM IF PREPOSITION IS 'ON'
IF BWORDS(2).CWORD = "on"
REM IF SECOND OBJECT IS NOT AN 'IN' CONTAINER
IF OBJ_ARRAY(OBJECT2).C_ON <> 1
COMMAND_MSG(11, OBJ_ARRAY(OBJECT2).NAME)
RETURN
ENDIF
REM CHECK THAT OBJECT1 AND OBJECT2 ARE NOT THE SAME!!
IF OBJECT1 = OBJECT2
COMMAND_MSG(9, "")
RETURN
ENDIF
REM IF FIRST OBJECT EXCEEDS SIZE LIMIT OF SECOND OBJECT
REM GET REMAINING CAPACITY OF SECOND OBJECT
IF (OBJ_ARRAY(OBJECT2).SIZE_LIMIT - REM_CAP(OBJECT2, MAX_OBJ)) < OBJ_ARRAY(OBJECT1).SIZE_UNITS
COMMAND_MSG(14, "")
RETURN
ENDIF
REM CHECK IF OBJECT AT PLAYER'S LOCATION?
IF OBJ_ARRAY(OBJECT2).LOCATION = PLR_LOC OR OBJ_ARRAY(OBJECT2).C_LOCATION
REM PLACE OBJECT1 IN OBJECT2
OBJ_ARRAY(OBJECT1).C_BELONGS_TO = OBJECT2
OBJ_ARRAY(OBJECT1).INVENTORY = 0
OBJ_ARRAY(OBJECT1).C_INVENTORY = 0
OBJ_ARRAY(OBJECT1).C_LOCATION = PLR_LOC
OBJ_ARRAY(OBJECT1).LOCATION = 0
PRINT "Done."
PUT_CNT_OBJ_STAT_CHANGE(OBJECT1, MAX_OBJ, PLR_LOC)
RETURN
ENDIF
REM CHECK IF OBJECT IN PLAYER'S INVENTORY:
IF OBJ_ARRAY(OBJECT2).INVENTORY = 1 OR OBJ_ARRAY(OBJECT2).C_INVENTORY = 1
REM PLACE OBJECT1 IN OBJECT2
OBJ_ARRAY(OBJECT1).C_BELONGS_TO = OBJECT2
OBJ_ARRAY(OBJECT1).INVENTORY = 0
OBJ_ARRAY(OBJECT1).C_INVENTORY = 1
OBJ_ARRAY(OBJECT1).C_LOCATION = 0
OBJ_ARRAY(OBJECT1).LOCATION = 0
PRINT "Done."
PUT_INV_CNT_OBJ_STAT_CHANGE(OBJECT1, MAX_OBJ, PLR_LOC)
RETURN
ENDIF
REM OBJECT NOT HERE
COMMAND_MSG(4, OBJ_ARRAY(OBJECT2).NAME)
RETURN
ENDIF
RETURN
REM END TAKE
REM IF OBJECT IS CONTAINER THEN CHANGE INVENTORY STATUS OF ALL OBJECTS AND CONTAINERS INSIDE
FUNCTION PUT_CNT_OBJ_STAT_CHANGE(OBJECT AS INTEGER, MAX_OBJECT AS INTEGER, PLAYER_LOC AS INTEGER)
IF OBJ_ARRAY(OBJECT).C_IN = 1
FOR I = 1 TO MAX_OBJECT
IF OBJ_ARRAY(I).C_BELONGS_TO = OBJECT
OBJ_ARRAY(I).C_INVENTORY = 0
IF OBJ_ARRAY(OBJECT).C_LOCATION = PLAYER_LOC AND OBJ_ARRAY(OBJECT).OPEN <> 1
OBJ_ARRAY(I).C_LOCATION = PLAYER_LOC
ELSE
OBJ_ARRAY(I).C_LOCATION = 0
ENDIF
OBJ_ARRAY(I).INVENTORY = 0
OBJ_ARRAY(I).LOCATION = 0
IF OBJ_ARRAY(I).C_IN = 1 OR OBJ_ARRAY(I).C_ON = 1
PUT_CNT_OBJ_STAT_CHANGE(I, MAX_OBJECT, PLAYER_LOC)
ENDIF
ENDIF
NEXT I
ENDIF
IF OBJ_ARRAY(OBJECT).C_ON = 1
FOR I = 1 TO MAX_OBJECT
IF OBJ_ARRAY(I).C_BELONGS_TO = OBJECT
OBJ_ARRAY(I).C_INVENTORY = 0
OBJ_ARRAY(I).C_LOCATION = PLAYER_LOC
OBJ_ARRAY(I).INVENTORY = 0
OBJ_ARRAY(I).LOCATION = 0
IF OBJ_ARRAY(I).C_IN = 1 OR OBJ_ARRAY(I).C_ON = 1
PUT_CNT_OBJ_STAT_CHANGE(I, MAX_OBJECT, PLAYER_LOC)
ENDIF
ENDIF
NEXT I
ENDIF
ENDFUNCTION
REM IF OBJECT IS CONTAINER THEN CHANGE INVENTORY STATUS OF ALL OBJECTS AND CONTAINERS INSIDE
FUNCTION PUT_INV_CNT_OBJ_STAT_CHANGE(OBJECT AS INTEGER, MAX_OBJECT AS INTEGER, PLAYER_LOC AS INTEGER)
IF OBJ_ARRAY(OBJECT).C_IN = 1 OR OBJ_ARRAY(OBJECT).C_ON = 1
FOR I = 1 TO MAX_OBJECT
IF OBJ_ARRAY(I).C_BELONGS_TO = OBJECT
OBJ_ARRAY(I).C_LOCATION = 0
OBJ_ARRAY(I).INVENTORY = 0
OBJ_ARRAY(I).LOCATION = 0
IF OBJ_ARRAY(I).C_IN = 1 OR OBJ_ARRAY(I).C_ON = 1
PUT_INV_CNT_OBJ_STAT_CHANGE(I, MAX_OBJECT, PLAYER_LOC)
ENDIF
ENDIF
NEXT I
ENDIF
ENDFUNCTION
REM RETURN REMAINING CAPACITY
FUNCTION REM_CAP(OBJECT AS INTEGER, MAX_OBJECT AS INTEGER)
SIZE_TOTAL = 0
FOR I = 1 TO MAX_OBJECT
IF OBJ_ARRAY(I).C_BELONGS_TO = OBJECT
SIZE_TOTAL = SIZE_TOTAL + OBJ_ARRAY(I).SIZE_UNITS
ENDIF
NEXT I
ENDFUNCTION SIZE_TOTAL
REM OPEN
CMD_OPEN:
REM IF OBJECT AT PLAYER'S LOCATION OR INVENTORY
IF OBJ_ARRAY(OBJECT1).LOCATION <> PLR_LOC
IF OBJ_ARRAY(OBJECT1).C_LOCATION <> PLR_LOC
IF OBJ_ARRAY(OBJECT1).INVENTORY <> 1
IF OBJ_ARRAY(OBJECT1).C_INVENTORY <> 1
COMMAND_MSG(4, OBJ_ARRAY(OBJECT1).NAME)
RETURN
ENDIF
ENDIF
ENDIF
ENDIF
REM CHECK IF OBJECT IS OPENABLE
IF OBJ_ARRAY(OBJECT1).OPEN = 0
COMMAND_MSG(6, "")
RETURN
ENDIF
REM IF ALREADY OPENED
IF OBJ_ARRAY(OBJECT1).OPEN = 2
COMMAND_MSG(12, "")
RETURN
ENDIF
GOSUB OPEN_OBJ
RETURN
RETURN
REM END OPEN
REM OPEN_OBJ
OPEN_OBJ:
REM OBJECT IS NOW OPENED
OBJ_ARRAY(OBJECT1).OPEN = 2
REM SPECIAL OBJECTS
REM TRAPDOOR
IF OBJECT1 = 11
PRINT "The door reluctantly opens to reveal a rickety staircase descending into the"
PRINT "darkness."
RETURN
ENDIF
REM IF OBJECT IS A CONTAINER THEN SHOW THE STUFF INSIDE
FRST_OBJ_CNT = 0
FOR I = 1 TO MAX_OBJ
IF OBJ_ARRAY(I).C_BELONGS_TO = OBJECT1
INC FRST_OBJ_CNT
IF FRST_OBJ_CNT = 1
PRINT "Opening the ";
PRINT OBJ_ARRAY(OBJECT1).NAME;
PRINT " reveals a ";
ENDIF
IF FRST_OBJ_CNT > 1
PRINT ", ";
ENDIF
PRINT OBJ_ARRAY(I).DESC1;
PRINT " ";
PRINT OBJ_ARRAY(I).NAME;
ENDIF
NEXT I
IF FRST_OBJ_CNT <> 0
PRINT "."
ENDIF
IF FRST_OBJ_CNT = 0
PRINT "Opened."
ELSE
IF OBJ_ARRAY(OBJECT1).LOCATION = PLR_LOC OR OBJ_ARRAY(OBJECT1).C_LOCATION = PLR_LOC
REM MAKE ALL OBJECTS IN OPENED CONTAINER VISIBLE
VISIBLE_CNTNRS(OBJECT1, MAX_OBJ, PLR_LOC)
ELSE
VISIBLE_INV_CNTNRS(OBJECT1, MAX_OBJ, PLR_LOC)
ENDIF
ENDIF
RETURN
REM MAKE OBJECTS VISIBLE INSIDE OF CONTAINER THAT WAS JUST OPENED
FUNCTION VISIBLE_CNTNRS(OBJECT AS INTEGER, MAX_OBJECT AS INTEGER, PLAYER_LOC AS INTEGER)
IF (OBJ_ARRAY(OBJECT).C_IN = 1 AND OBJ_ARRAY(OBJECT).OPEN <> 1) OR OBJ_ARRAY(OBJECT).C_ON = 1
FOR I = 1 TO MAX_OBJECT
IF OBJ_ARRAY(I).C_BELONGS_TO = OBJECT
OBJ_ARRAY(I).C_LOCATION = PLAYER_LOC
IF OBJ_ARRAY(I).C_IN = 1 OR OBJ_ARRAY(I).C_ON = 1
VISIBLE_CNTNRS(I, MAX_OBJECT, PLAYER_LOC)
ENDIF
ENDIF
NEXT I
ENDIF
ENDFUNCTION
REM MAKE INVENTORY OBJECTS VISIBLE INSIDE OF CONTAINER THAT WAS JUST OPENED
FUNCTION VISIBLE_INV_CNTNRS(OBJECT AS INTEGER, MAX_OBJECT AS INTEGER, PLAYER_LOC AS INTEGER)
IF (OBJ_ARRAY(OBJECT).C_IN = 1 AND OBJ_ARRAY(OBJECT).OPEN <> 1) OR OBJ_ARRAY(OBJECT).C_ON = 1
FOR I = 1 TO MAX_OBJECT
IF OBJ_ARRAY(I).C_BELONGS_TO = OBJECT
OBJ_ARRAY(I).C_INVENTORY = 1
IF OBJ_ARRAY(I).C_IN = 1 OR OBJ_ARRAY(I).C_ON = 1
VISIBLE_INV_CNTNRS(I, MAX_OBJECT, PLAYER_LOC)
ENDIF
ENDIF
NEXT I
ENDIF
ENDFUNCTION
REM CLOSE
CMD_CLOSE:
REM IF OBJECT AT PLAYER'S LOCATION OR INVENTORY
IF OBJ_ARRAY(OBJECT1).LOCATION <> PLR_LOC
IF OBJ_ARRAY(OBJECT1).C_LOCATION <> PLR_LOC
IF OBJ_ARRAY(OBJECT1).INVENTORY <> 1
IF OBJ_ARRAY(OBJECT1).C_INVENTORY <> 1
COMMAND_MSG(4, OBJ_ARRAY(OBJECT1).NAME)
RETURN
ENDIF
ENDIF
ENDIF
ENDIF
REM CHECK IF OBJECT IS OPENABLE
IF OBJ_ARRAY(OBJECT1).OPEN = 0
COMMAND_MSG(6, "")
RETURN
ENDIF
REM IF ALREADY CLOSED
IF OBJ_ARRAY(OBJECT1).OPEN = 1
COMMAND_MSG(13, "")
RETURN
ENDIF
GOSUB CLOSE_OBJ
RETURN
RETURN
REM END OPEN
REM CLOSE_OBJ
CLOSE_OBJ:
OBJ_ARRAY(OBJECT1).OPEN = 1
PRINT "Closed."
IF OBJ_ARRAY(OBJECT1).LOCATION = PLR_LOC OR OBJ_ARRAY(OBJECT1).C_LOCATION = PLR_LOC
REM MAKE ALL OBJECTS IN CLOSE CONTAINER INVISIBLE
INVISIBLE_CNTNRS(OBJECT1, MAX_OBJ, PLR_LOC)
ELSE
INVISIBLE_INV_CNTNRS(OBJECT1, MAX_OBJ, PLR_LOC)
ENDIF
RETURN
REM MAKE OBJECTS INVISIBLE INSIDE OF CONTAINER THAT WAS JUST OPENED
FUNCTION INVISIBLE_CNTNRS(OBJECT AS INTEGER, MAX_OBJECT AS INTEGER, PLAYER_LOC AS INTEGER)
IF OBJ_ARRAY(OBJECT).C_IN = 1 OR OBJ_ARRAY(OBJECT).C_ON = 1
FOR I = 1 TO MAX_OBJECT
IF OBJ_ARRAY(I).C_BELONGS_TO = OBJECT
OBJ_ARRAY(I).C_LOCATION = 0
IF OBJ_ARRAY(I).C_IN = 1 OR OBJ_ARRAY(I).C_ON = 1
INVISIBLE_CNTNRS(I, MAX_OBJECT, PLAYER_LOC)
ENDIF
ENDIF
NEXT I
ENDIF
ENDFUNCTION
REM MAKE INVENTORY OBJECTS VISIBLE INSIDE OF CONTAINER THAT WAS JUST OPENED
FUNCTION INVISIBLE_INV_CNTNRS(OBJECT AS INTEGER, MAX_OBJECT AS INTEGER, PLAYER_LOC AS INTEGER)
IF OBJ_ARRAY(OBJECT).C_IN = 1 OR OBJ_ARRAY(OBJECT).C_ON = 1
FOR I = 1 TO MAX_OBJECT
IF OBJ_ARRAY(I).C_BELONGS_TO = OBJECT
OBJ_ARRAY(I).C_INVENTORY = 0
IF OBJ_ARRAY(I).C_IN = 1 OR OBJ_ARRAY(I).C_ON = 1
INVISIBLE_INV_CNTNRS(I, MAX_OBJECT, PLAYER_LOC)
ENDIF
ENDIF
NEXT I
ENDIF
ENDFUNCTION
REM MOVE
CMD_MOVE:
REM IF OBJECT NOT AT PLAYER'S LOCATION OR INVENTORY
IF OBJ_ARRAY(OBJECT1).LOCATION <> PLR_LOC
IF OBJ_ARRAY(OBJECT1).C_LOCATION <> PLR_LOC
IF OBJ_ARRAY(OBJECT1).INVENTORY <> 1
IF OBJ_ARRAY(OBJECT1).C_INVENTORY <> 1
COMMAND_MSG(4, OBJ_ARRAY(OBJECT1).NAME)
RETURN
ENDIF
ENDIF
ENDIF
ENDIF
REM CHECK IF OBJECT IS NOT MOVEABLE
IF OBJ_ARRAY(OBJECT1).MOVE = 0
COMMAND_MSG(15, OBJ_ARRAY(OBJECT1).NAME)
RETURN
ENDIF
REM CHECK IF OBJECT WAS MOVED ONCE AND CAN NO LONGER BE MOVED
IF OBJ_ARRAY(OBJECT1).MOVE = 2
COMMAND_MSG(17, OBJ_ARRAY(OBJECT1).NAME)
RETURN
ENDIF
REM MOVE OBJECT
REM RUG
IF OBJECT1 = 12
OBJ_ARRAY(OBJECT1).MOVE = 2
PRINT "With a great effort, the rug is moved to one side of the room, revealing the"
PRINT "dusty cover of a closed trap door."
RETURN
ENDIF
REM STANDARD MOVE OBJECT RESPONSE
COMMAND_MSG(16, OBJ_ARRAY(OBJECT1).NAME)
RETURN
RETURN
REM END OPEN
REM GET BATCH COMMANDS
WBATCH:
REM CHARACTER LENGTH OF PLAYER COMMAND
CL = LEN(CMD$)
HWORD$ = ""
REM SPACES COUNTER
CP = 1
BW_INDX = 0
EMPTY ARRAY BWORDS()
ARRAY INDEX TO BOTTOM BWORDS()
REM PERFORM LOOP UNTIL ENTIRE BATCH IS COMPLETE
REPEAT
REM COME UPON A SPACE THEN PUT TRAILING WORD INTO BATCH
IF MID$(CMD$, CP) = CHR$(32)
ARRAY INSERT AT BOTTOM BWORDS()
BW_INDX = ARRAY COUNT(BWORDS())
HWORD$ = LEFT$(CMD$, (CP-1))
BWORDS(BW_INDX).CWORD = HWORD$
REM IF WORD IS 'THE' THEN DELETE IT FROM ARRAY
IF HWORD$ = "the" OR HWORD$ = "of" OR HWORD$ = "top"
ARRAY DELETE ELEMENT BWORDS(0).CWORD, BW_INDX
ENDIF
REM IDENTICAL WORDS
SELECT HWORD$
CASE "into", "inside"
BWORDS(BW_INDX).CWORD = "in"
ENDCASE
CASE "onto"
BWORDS(BW_INDX).CWORD = "on"
ENDCASE
CASE "get", "retrieve"
BWORDS(BW_INDX).CWORD = "take"
ENDCASE
CASE "shut"
BWORDS(BW_INDX).CWORD = "close"
ENDCASE
CASE "place"
BWORDS(BW_INDX).CWORD = "put"
ENDCASE
ENDSELECT
INC BW_INDX
CMD$ = RIGHT$(CMD$, (CL-CP))
CL = LEN(CMD$)
CP = 0
ENDIF
INC CP
SYNC
UNTIL CP => CL : REM REPEAT LOOP UNTIL LAST CHARACTER OF COMMAND IS REACHED
REM GET LAST WORD
ARRAY INSERT AT BOTTOM BWORDS()
BW_INDX = ARRAY COUNT(BWORDS())
BWORDS(BW_INDX).CWORD = CMD$
REM IF LAST WORD A 'the' or 'of' JUST IGNORE IT
IF CMD$ = "the" OR CMD$ = "of" THEN DEC BW_INDX :REM PUSH BACK ARRAY INDEX SO PARSER NEVER GETS TO LAST WORD
RETURN
REM END OF GBATCH
REM ASSIGN TYPES TO WORDS
WTYPE:
REM COMMAND WORD TYPE INDEX
WT_INDX = 0
DWORD$ = ""
REPEAT
REM CHECK ALL OBJECTS AND DESCRIPTIONS TO SEE IF ANY MATCH COMMAND WORD
FOR I = 1 to MAX_OBJ
REM IF COMMAND WORD MATCHES AN OBJECT
IF BWORDS(WT_INDX).CWORD = OBJ_ARRAY(I).NAME
REM ASSIGN TYPE TO ARRAY
BWORDS(WT_INDX).CTYPE = 3
REM ASSIGN THE OBJECT
BWORDS(WT_INDX).CNUM = I
ENDIF
REM FOUND OBJECT DESCRIPTIONS MATCH
IF BWORDS(WT_INDX).CWORD = OBJ_ARRAY(I).DESC1 OR BWORDS(WT_INDX).CWORD = OBJ_ARRAY(I).DESC2
REM ASSIGN TYPE TO ARRAY
BWORDS(WT_INDX).CTYPE = 2
REM ASSIGN THE OBJECT NUMBER
BWORDS(WT_INDX).CNUM = I
ENDIF
NEXT I
REM COMPARE KEYWORDS
FOR I = 1 TO MAX_KW
REM IF COMMAND WORD MATCHES A KEYWORD
IF BWORDS(WT_INDX).CWORD = KW_ARRAY(I).KWORD
REM ASSIGN TYPE TO ARRAY
BWORDS(WT_INDX).CTYPE = KW_ARRAY(I).KTYPE
ENDIF
NEXT I
REM IF UNKNOWN WORD RETURN ERROR MESSAGE
IF BWORDS(WT_INDX).CTYPE < 1
COMMAND_MSG(2, BWORDS(WT_INDX).CWORD )
BW_INDX = WT_INDX
EXIT
ENDIF
REM IF OBJECT, CHECK PREVIOUS OBJECT DESCRIPTIONS. IF THEY EXIST CHECK TO SEE THEY MATCH OBJECT
REM IF NOT THEN SYNTAX ERROR MESSAGE. IF THEY DO MATCH THEN DELETE THEM FROM ARRAY.
IF BWORDS(WT_INDX).CTYPE = 3 AND WT_INDX <> 0
REM SET INDX VARIABLE AND CHECK EACH PREVIOUS WORD UNTIL DOES NOT = DESC
INDX = WT_INDX - 1
WHILE BWORDS(INDX).CTYPE = 2
IF BWORDS(INDX).CNUM <> BWORDS(WT_INDX).CNUM
FOR I = INDX TO WT_INDX
DWORD$ = DWORD$ + BWORDS(I).CWORD + " "
NEXT I
COMMAND_MSG(8, DWORD$)
ELSE
ARRAY DELETE ELEMENT BWORDS(0), INDX
DEC WT_INDX
DEC BW_INDX
ENDIF
DEC INDX
ENDWHILE
IF DWORD$ <> ""
EXIT
ENDIF
ENDIF
INC WT_INDX
UNTIL WT_INDX > ARRAY COUNT(BWORDS())
RETURN
REM END ASSIGN TYPE
REM COMMAND SYNTAX ERROR MESSAGES
FUNCTION COMMAND_MSG(MSG_NUM AS INTEGER, MWORD AS STRING)
SELECT MSG_NUM
CASE 1
PRINT "That sentence isn't one I recognize."
ENDCASE
CASE 2
PRINT "I don't know the word '" + MWORD + "'."
ENDCASE
CASE 3
PRINT "You already have that!"
ENDCASE
CASE 4
PRINT "You can't see any '" + MWORD + "' here!"
ENDCASE
CASE 5
PRINT "You don't have the " + MWORD + "."
ENDCASE
CASE 6
PRINT "You can't do that."
ENDCASE
CASE 7
PRINT "The " + MWORD + " isn't opened."
ENDCASE
CASE 8
PRINT "You can't see any '" + MWORD + "' here!"
ENDCASE
CASE 9
PRINT "How can you do that?"
ENDCASE
CASE 10
PRINT "It is securely anchored."
ENDCASE
CASE 11
PRINT "There's no good surface on the " + MWORD + "."
ENDCASE
CASE 12
PRINT "It is already opened."
ENDCASE
CASE 13
PRINT "It is already closed."
ENDCASE
CASE 14
PRINT "There is no room."
ENDCASE
CASE 15
PRINT "You can't move the " + MWORD + "."
ENDCASE
CASE 16
PRINT "Moving the " + MWORD + " reveals nothing."
ENDCASE
CASE 17
PRINT "Having moved the " + MWORD + " previously, you find it impossible to move again."
ENDCASE
CASE 18
PRINT "The " + MWORD + " is extremely heavy and cannot be carried."
ENDCASE
ENDSELECT
ENDFUNCTION