10-17-2005, 11:36 PM
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
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~
[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

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~