the black hole 
it all ends here. 
bhC login
name:
pass:
 
home
 
 the black hole's front page. all the latest vb rpg development and vbgaming news, as well as this week's feature rpg project!
articles
 
rpg theory (7)
directx in vb (3)
vb rpg programming (4)
miscellaneous (4)
files
 
rpg / tile engine source (23)
full vb games w/ source (5)
'helper' libraries and utilities (13)
effect samples (5)
miscellaneous (10)
rpg projects
 
 vb rpg projects under development by members of the bhC. show them your support, and check out their games!
message board
 
 a forum to interact with your fellow vb rpg programmers. you do *not* have to be a bhC member to post!
links
 
vb rpg programming (5)
vb gaming (14)
general game programming (6)
vb sites (6)
miscellaneous (2)
general rpg programming (2)
contact
 
 you want to contact the guy behind the black hole? here's where to do it!


 
 


<< Back to Category List

Simple Game Scripting Part 2:
Making Your Scripts DO Something
- page 2


pages: prev | 1 | 2 | 3 | 4 | 5 | next


Two Possibilities...

After much thought, two obvious options for the implementation of the scripts occurred to me. The first one is probably the simplest: use a giant Select...Case statement to choose which functions to call, etc. The problem with this method, though, is that it rapidly becomes very confusing, and much slower the more commands that you have.

The second option that I came up with uses a new method introduced in VB6: CallByName. This function will allow you to call any sub/function/property of an object by passing it's name as a string. If you think about this in the context of scripting, you will realize that we already have each command that needs to be executed for our script in memory as a string. This provides an extremely easy-to-use method to split up our commands logically, and make it *very* flexible.

How Do We Use This?

Now that we have a method that we can use to flexibly call any possible command that is named in a string, we should create a single function that will handle any command, and from there call the associated function. In your CScriptParser class module, put this function:

Public Function ExecuteCommand(Command As String, Parameters() As String) As Integer
  ExecuteCommand = CallByName(Me, "ExecuteCmd" & Command, VbMethod, Parameters())
End Function



pages: prev | 1 | 2 | 3 | 4 | 5 | next