Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Anyone interested in making a text adventure as a group?
#60
This is a very brief example of how things could work:

[syntax="qbasic"]#DEFINE Obj_NotHere 1
#DEFINE Obj_None 2
#DEFINE Obj_Unable 3

#DEFINE Scene_Invalid 1

DECLARE FUNCTION SceneValid(sceneID as integer) AS INTEGER
DECLARE FUNCTION ObjectValid(obj as string) AS INTEGER
DECLARE FUNCTION Obj_in_Scene(sceneID as integer, obj as string) as integer
DECLARE FUNCTION Obj_Act(obj as string, act as string) as integer
DECLARE FUNCTION Get_Root_Action(u_command as string) as string

DECLARE SUB Parse(action as string)

' lots of jibberish

INPUT "> ", action$
Parse(action$)

' lots more jibberish

FUNCTION SceneValid(sceneID as integer) AS INTEGER
' How-ever we save and load scenes will take care of this.
' This will be more of a shortcut...

SceneValid = 1 'By default, it is assumed valid....

DIM f as integer = FreeFile
open "scene" + str$(sceneID) + ".scn" for input as #f
if(lof(f) = 0) then SceneValid = Scene_Invalid

' If the file is empty, then it's not
' valid. I assume we'll use a different
' system to save/load...this is just
' an example

close #f

END FUNCTION

FUNCTION ObjectValid(obj as string) AS INTEGER

ObjectValid = 1 'By default, it is assumed valid....

DIM f as integer = FreeFile
open "obj_" + trim$(obj) + ".obj" for input as #f

if(lof(f) = 0) then ObjectValid = -1

close #f

END FUNCTION

FUNCTION Obj_in_Scene(sceneID as integer, obj as string) as integer
'We have some sort of header to determine what is where...
' For no, i'll leave this empty, as i'm not even sure how we'd
' save/load scenes.....
END FUNCTION

FUNCTION Get_Root_Action(u_command as string) as string
' This would be a "smart" function that would do something like this:
' The user inputs: "grab the microphone"
' This will get the "grab" part, and check to see what that means
' and will translate it into something like "take"

' We'd have to do some sort of database search.....
' this would also be good for language translations

' This isn't done Tongue
END FUNCTION

FUNCTION Obj_Act(obj as string, act as string) as integer
' Are you able to do <act> to the <obj> ?
' This will determine this (probably through headers)

' Again, dependant on how we load/save things
END FUNCTION

SUB Parse(action as string)
DIM position AS INTEGER = 0, oldpos AS INTEGER = 1
DIM AS STRING Chunk, Action, Object

' Loop through all the commands we have...
while(position = instr(lcase$(action), "then", oldpos + 1) > 0)
chunk = MID$(lcase$(action), oldpos, position)
action = "move" ' seee below for reasoning
' Seperate the chunk
' Probably use " " to seperate...more instr.......too lazy right now
' If there is no command, assume "move"...such as input "north"
' really is move north


' Do some validation checks

' If it's valid, then initiate it
oldpos = position
wend
END SUB[/syntax]

[syntax="qbasic"]TYPE cmdType
act AS STRING
assoc AS FUNCTION() as any
END TYPE

DECLARE FUNCTION Take(obj as string)

DIM commands(999) AS cmdType

commands(1).act = "take"
commands(1).assoc = @Take()

' Now, if we call commands(1).assoc, it will go to Take(obj as string)

commands(1).assoc("example")

FUNCTION Take(obj as string)
' This should check for valid object, and Obj_Act() should be checked
' If it goes through put into inventory, and take away from scene
' may do respawns, too.....
END FUNCTION[/syntax]

i hope that clears up some ideas.....may even spawn some new ones, i hope

oz~
Reply


Messages In This Thread
Anyone interested in making a text adventure as a group? - by Oz - 10-17-2005, 11:36 PM
been thinkin - by zoasterboy - 10-22-2005, 10:54 AM
sorry! - by phycowelder - 10-23-2005, 12:13 PM
before... - by zoasterboy - 10-24-2005, 07:43 AM
story line - by zoasterboy - 10-25-2005, 04:47 AM
yah - by zoasterboy - 10-25-2005, 07:26 AM
main menu - by zoasterboy - 10-26-2005, 05:13 AM
joining - by phycowelder - 10-26-2005, 05:25 AM
^^ - by zoasterboy - 10-26-2005, 05:27 AM
Anyone interested in making a text adventure as a group? - by Anonymous - 10-26-2005, 05:34 AM
Re: ^^ - by Liquid Snake - 10-26-2005, 06:18 AM
cool! - by phycowelder - 10-26-2005, 06:56 AM

Forum Jump:


Users browsing this thread: 5 Guest(s)