Upcoming Events
Unite 2010
11/10 - 11/12 @ Montréal, Canada

GDC China
12/5 - 12/7 @ Shanghai, China

Asia Game Show 2010
12/24 - 12/27  

GDC 2011
2/28 - 3/4 @ San Francisco, CA

More events...
Quick Stats
63 people currently visiting GDNet.
2406 articles in the reference section.

Help us fight cancer!
Join SETI Team GDNet!
Link to us Events 4 Gamers
Intel sponsors gamedev.net search:

  Contents

 Introduction
 Explanation
 Command Blocks
 Improvements

 Printable version

 


  The Series

 Storing/Reading
 Doing Something
 Control Structures

 

A Few Suggestions For Custom Improvements

I have kept the code and structure of this scripting engine as simple as possible so as to be able to explain the concepts much more easily. But, you will definately want to make improvements and alterations to it customized for your own game. I have a few suggestions for things that should be done for any type of game:

Firstly, split up the CommandBlocks array variable into multiple arrays, one for each 'BlockType' or associated BlockTypes. This will make a couple of the functions a little longer, but it will generate a huge speed increase because they will no longer have to search through each and every one of the commandblocks to find the one you are trying to use. Another way to avoid searching through a huge array is to use VB Collections, or Dictionaries. This way you could use the BlockName as the key for each entry.

Secondly, add error-checking code. You never know what might happen!

Third and finally, instead of using plain text, do as I mentioned in the first part of this series: integrate your script files into a custom resource file along with all of your graphics/sounds etc. This should really be done with everything in your game that you do not want people to change.

Conclusion, and What's Coming!

I sure hope that with this second part out of the way, the ideas behind the scripting engine are becoming much clearer. By actually seeing how the script files are used, you can understand much easier why things are done a certain way. But, you must remember that none of this is set in stone; feel free to play around with adding things to the engine that you feel might be useful, such as lists of items in the game and associated events for interacting with them in different ways.

As stated in the introduction, the third part of this series should discuss the actual commands that should be in the scripting engine no matter what type of game they will be used for, such as decision-making structures and loops. This will get into setting/getting flags using scripting, and other such things.

Hopefully you are well on your way, now, to creating a complete, flexible scripting engine for your game!

Source Code

As before, if you would like the source code to this part in the series, the class module is available at:

[ http://blackhole.thenexus.bc.ca/articles/CScriptParser-pt2.cls ]

Contact + Future Releases

As before, updated versions of this second part of the series, as well as later parts as they are written, will be available from my website, the black hole:

[ http://blackhole.thenexus.bc.ca/ ]

I welcome any questions or comments, as well as *constructive* criticism :) I can be reached via email at:

[dgoodlad@junction.net ]

Thanks for reading!

David Goodlad