Evarcha,
Actually It may be better to leave this thread going and I'll post how to create a Sierra like adventure here.
Reason: I kind of stepped on Timesplitter's thread. And while I was posting my reply (which tooK a while) other posts came in. So I'm not sure if he was aiming for an actual Text Adventure.
So perhaps a mod can delete my post in Timesplitters thread, and I will move my Text Adventure stuff herE.
I'll follow up later with how the command parsing token system works
~zen
========
Tower Of Mystery (on-going code)
Last edit Sunday May 22,2005 @10:00pm EST
-Currently working on the Command Parser
-Parsed 1st word second word
-gets verb token and objec token
Rem Project: Tower Of Mystery
Rem Created: 5/13/2005 9:49:14 PM
Rem ***** Main Source File *****
`============================================================================================
` I N I T I A L I Z A T I O N
`============================================================================================
Set display mode 1024, 768, 32
backdrop off
sync on
sync rate 60
ink RGB(128,255,128),0
`CONSTANTS
NUMROOMS=14
NUMTHINGS=11
NUMPOBJ=11
NUMVERBS=29
NUMOBJ=NUMTHINGS+NUMPOBJ
`Dimension Arrays
dim Access(NUMROOMS,6)
dim Verb$(NUMVERBS)
dim Object$(NUMOBJ+20)
dim RoomDesc$(NUMROOMS)
dim ItemDesc$(NUMTHINGS)
dim VerbToken(NUMVERBS)
dim ItemLoc(NUMTHINGS)
dim ItemFlag(NUMTHINGS)
`Initialize Variables and flags
global cmd$
global cmd1$
global cmd2$
CurrRoom=1
CompStartTime=0
CoinFound=0
RatsTrouble=-1
CompAct=0
ManualFound=0
CompDoa=0
RdRFlag=-1
LoggedIn=0
BatsTrouble=-1
verbfound=0
`Initialize Arrays
`Roomdesc$ array
for i=1 to NUMROOMS
read RoomDesc$(i)
next i
`Verb$, VerbToken arrays
for i=1 to NUMVERBS
read Verb$(i),VerbToken(i)
next i
`Object$ array
for i=1 to NUMOBJ
read Object$(i)
next i
`ItemDesc$, ItemLoc, ItemFlag
for i=1 to NUMTHINGS
read ItemDesc$(i), ItemLoc(i), ItemFlag(i)
next i
`Access array
for i =1 to NUMROOMS
for j =1 to 6
read Access(i,j)
next j
next i
ink RGB(0,128,255),0
print " /\"
print " /\ /--\ /\"
print " ,.-, | | ,-.,"
print " :#: |, .| |. ,|#: :"
print " :#:: .- __ -. #: :"
print " ::## ;' /\_\ `;# :"
print " ;:;|; \__/ |:;"
print " ;:| ____ :;"
print " :| //###&\\ |:"
print " :| ||##% || |:"
print " :| ||#% || |;"
print " ::||\________/||:;"
print " ::|| } { } { ||::"
print " ;:|| { } { } ||::"
print " ::|\_}_{__}_{_/|:; _____ ___ _ _ __ ___ "
print " .\___.,_._,.__/. |_ _| | |_| | _| \ "
print " ;MMMMMMMMMMMMMM; | | | ` | / \ | _| ` / "
print " :::::::;;;:::;;:;; |_| |___|_/-\_|__|_|_\ "
print " ;`#.`````''`````. `; "
print " : #||~|~| |~|~|| : ___ ___ "
print " : #||_|_| |_|_|| ; | | __| "
print " ; #|| | | #| | || : | ` | _| "
print " : #||_|_|##|_|_|| : |___|_| "
print " :,#;____________; : "
print " [][][][][][][][][][] _ _ _ _ ___ _____ __ ___ _ _ "
print " :#||~|~|##|~|~|| : | \_/ | \/ / __/_ _| _| \ \/ / "
print " :#|| | |##| | || : | \_/ |\ /\__ \ | | | _| ` /\ / "
print " ;#|| | |##| | ||#; |_| |_|/_/ /___/ |_| |__|_|_\/_/ "
print " ;#||_|_|##|_|_||#;_____________________________________________________________ "
print " :#|| | |##| | ||#:%%%%% Translated to DBpro by ~Zenassem %%%%%%%%%%%%%%%%%%%\ "
print " :#|| | |##| | ||#:%%%%%% %%%%%%%%%%%%%%%%%%%%%%\ "
print " :#|| | |##| | ||#:%%%%%%%% Press <any key> to continue %%%%%%%%%%%%%%%%%%%%%%%%%%%\ "
print " :#||_|_|##|_|_||#:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~_ "
print " _:________________:_ ==== ==== ==== ==--------------== | "
print " / [][][][][][][][][] \ |++| |++| |++| ==|T I I|== | "
print " / /\._ _./\ \ |++| |++| |++| ==|L____I_____]|== . | "
print " / /; ; `----------` ; ;\ \ ==== ==== ==== ==--------------== ._.-` ;~ | "
print " |_/ : : : / ____ \ : : :##\ \______________________________________ . '--.{} | "
print " |#; ; ; =| |/\/\| |= ; ;####\ \ ^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\ ~`-,++{{}{++ | "
print " |#: : : =| |\/\/| |= : :######\ \^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\ ; +{++}\+/++,| "
print " |#; ; ; =| |/\/\| |= ; ;######| |-------------------------------------- `~}/}{,+}++; | "
print " |#: : : =| |\/\/| |= : :######| | __ __ __ __ __ __ | ++(+}~~{;+ | "
print " |#; ; ; =| |/\/\| |= ; ;######| | L,.I |/\| |/\| |/\| |/\| |/\| | ;'+;~}{??+++ | "
print " |#: : : =| |\/\/| |= : :######| |,-' `-L\/| |\/|__|\/| |\/| |\/| | , , , , , , , , , , , , , , , , , "
print " |#: ; . | | 00 | | ;.-,,__| / ``-._|.` `--.__|/\| |/\| | |||||||||||||||||||||||||||||||||| "
print " |#: , | |/\/\| | _.` . ( `-.._ _.--` `..| |\/| | |||||||||||||||||||||||||||||||||| "
print " |#:## | |\/\/| | / ) `-. `) _..-`-----``\| |||||||||||||||||||||||||||||||||| "
print " |#### | |/\/\ .-` -` .-`` `-,_||||||||||||||||||||||||||||||| "
print " |### | |\/\. / ( \ |||||||||||||||||||||||||||||| "
sync
sync
wait key
print ""
`============================================================================================
` M A I N G A M E L O O P
`============================================================================================
do
if RdRFlag=0
ink RGB(255,255,255),0
print
print "> ";
gosub Command_Input
else
RdRFlag=0
ink RGB(255,255,128),0
print RoomDesc$(CurrRoom)
k=0
for i=1 to NUMTHINGS
if ItemLoc(i)=CurrRoom
if k=0
k=1
print "You See:"
print ItemDesc$(i)
endif
endif
next i
print "Exits Are: "
for i=1 to 6
if Access(CurrRoom,i)<>0 then print verb$(i);" ";
next i
print
endif
`Test Stub
ink RGB(255,0,0),0
print
print "cmd$ "; cmd$
print
print "cmd1$ "; cmd1$
print
print "cmd2$ "; cmd2$
print
print "verbfound "; verbfound
print
print "VerbTkn "; VerbTkn
print
print "Verb$(c1) "; Verb$(c1)
print
print "ObjTkn "; ObjTkn
print
print "Object$(ObjTkn) "; Object$(ObjTkn)
print
if verbfound = 0
print "I don't know the verb "; cmd1$
endif
sync
loop
end
`============================================================================================
` E N D M A I N G A M E L O O P
`============================================================================================
`================== S U B R O U T I N E S =======================
Command_Input:
`***** Command INPUT/PARSER
`c2
`space
input cmd$: rem Get user input
str_length = len(cmd$):rem Find the length (str_length) of input
cmd1$="": rem Init cmd1$
cmd2$="": rem Init cmd2$
rem Initialize variables
c1=0
c2=0
v2=0
v1=0
space=0:
verbfound=0:
VerbTkn=0
ObjTkn=0
for i=1 to str_length: rem Look at each character (a$) in the users input
a$=mid$(cmd$,i): rem
a=asc(a$)
if a>=97 and a<=122
a$=chr$(a-32): rem Make everything upper-case
endif
if a$<>" ": rem If the character is not a space
if space=0: rem If we have not encounterd a space,
cmd1$=cmd1$+a$: rem Add the character to the first word.
else
cmd2$=cmd2$+a$: rem add the character to the second word
endif
endif
if a$=" "
space=1: rem We have encountered a Space
endif
next i
cmd1$=left$(cmd1$,5): rem Truncate cmd1$ to 5 characters
cmd2$=left$(cmd2$,5): rem Truncate cmd2$ to 5 characters
for v1=1 to NUMVERBS: rem Search the verb array for match with cmd1$
if Verb$(v1)=cmd1$: rem If we find a match
VerbTkn=VerbToken(v1): rem get the verbtoken and store it in VerbTkn
verbfound=1: rem A match was found
c1=v1: rem Save contentes of v1 to c1
v1=NUMVERBS: rem No need to search anymore Verb is Found!
endif
next v1
for v2=1 to NUMOBJ: rem Search the object array for match with cmd2$
if Object$(v2)=cmd2$: rem If we find a match
ObjTkn=v2: rem Store contents of v2 in ObjTkn
v2=NUMOBJ: rem No need to searvh anymore Object is Found!
endif
next v2
return
`=============== D A T A S E C T I O N ===============
`Room/Area Descriptions
data "You are in the front of an old factory with a clock tower."
data "You are at the bottom of a stairwell."
data "You are at the top of the basement steps."
data "You are in a damp cellar."
data "You are in a storeroom."
data "You're in the cafeteria."
data "You're at a landing on the stairs."
data "Around you is a manufacturing area."
data "You're at a landing on the third floor."
data "You are in the computer room."
data "You are inside the clock tower."
data "You are at the top of the stairs."
data "You are in a long corridor going East."
data "You're at the East end of the corridor."
`Verb,Verbtoken data
data "N",1,"S",2,"E",3,"W",4,"U",5,"D",6,"GO",7,"EAT",8,"KICK",9,"INSER",10,"DEPOS",10,"TYPE",11
data "TAKE",12,"GET",12,"DROP",13,"THROW",13,"INVEN",14,"I",14,"MOUNT",15,"READ",16
data "FIGHT",17,"KILL",17,"START",18,"POWER",18,"OPEN",19,"QUIT",20,"LOOK",21
data "WIND",22,"EXAM",23
`Object data
data "RATS","TAPE","MACHI","TERMI","COIN","CANDY","COMPU","BATS","DESK","MANUA","CLOCK","ROAD"
data "DIR","ADVEN","COPY","LOGOU","NORTH","SOUTH","EAST","WEST","UP","DOWN"
`Item data
data "HUNGRY RATS",4,0,"COMPUTER TAPE",5,1,"VENDING MACHINE",6,0
data "BROKEN-DOWN TERMINAL",8,1,"COIN",-1,1,"CANDY BAR",-1,1,"Computer",10,0
data "BATS",13,0,"DESK",14,0,"COMPUTER MANUAL",-1,1,"ELABORATE CLOCKWORK",11,0
`Access data: Interconnections between rooms
data 2,0,0,0,0,0
data 3,1,0,0,7,0
data 0,2,0,0,0,4
data 0,0,5,0,3,0
data 0,0,0,4,0,0
data 0,0,7,0,0,0
data 0,0,8,6,9,2
data 0,0,0,7,0,0
data 0,0,10,0,12,7
data 0,0,0,9,0,0
data 0,12,0,0,0,0
data 11,0,13,0,0,9
data 0,0,14,12,0,0
data 0,0,0,13,0,0