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 3


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


An Explanation

That ExecuteCommand function can be called whenever you want to parse ANY of your scripting commands. It is a 'generic' function that will 'wrap' around each of the other functions for the individual scripting commands.

Speaking of the individual scripting commands' functions, how do we make them? Here is a very simple example :

Public Function ExecuteCmdFoo(a() As String) As Integer
  Debug.Print a(0)
  Foo = 1
End Function
Basically, you create a function for each of your possible scripting commands, named the same as the command but prefixed with 'ExecuteCmd'. In the above example, the command that would call this function would be 'Foo'. By returning a value of 1, the call to ExecuteCommand would also return a value of 1. The return value gets passed down the chain, you can return values from your 'wrapped' command functions.

The only 'sad' part about using CallByName is that the functions *must* be Public, not Private. But, having those command functions public can actually be a good thing; You can use them from within your code as well. For example, say you had a tile-based game with multiple maps, and you knew that every single map would be linked in a uniform fashion to other maps on the edge tiles. You could have a scripting command 'TeleportToMap' that could not only be used in your scripts for events such as walking onto a door tile to bring you inside a building, but you could have your player movement code check all the time if the player moves off the map, and call the ExecuteCmdTeleportToMap function without the 'wrapper' ExecuteCommand function to move the player to the adjacent map. Therefore, it's not so bad to have the functions public anyways.


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