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
88 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
 Getting Started
 Loading Your
 Scripts

 Conclusion

 Printable version

 


  The Series

 Storing/Reading
 Doing Something
 Control Structures

 

Actually Loading the Script File

Now that we've got all of our storage structures created, we can actually load our script file. Put this function into your class module:

Popup : Source Listing 1

An explanation!

Hopefully the comments in the code for the LoadScriptFile function are sufficient to explain what the more confusing lines do. The use of string manipulation functions such as InStr, Left$, and Right$ can become very confusing if you have not used them before, or don't know how they work. Therefore, if you wish to truly understand how the string parsing works, I suggest you read up on these functions, and other related ones including Mid and Split.

Until next time...

By now, you should understand how to load and store your script files on disk and in memory. This is the most important piece, and can be the most complicated. The actual loading and splitting up of the individual lines is integral to the use of your scripting engine, and thus you have to make absolutely sure that it is foolproof (or as close to this as possible!). I suggest adding error handlers, and using the return value of LoadScriptFile to check whether the file was loaded correctly when you call it.

In the next article in this series, the actual use of your scripting will be discussed. The third part of this series will then continue along that theme and go into much more depth with the implementation, including a section on interfacing the scripting engine with a tile-based system in order to create events.

Source Code

Though simple, if you would like the source code to this part of the series, the class module is available at:

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

Contact + Future Releases

Updated versions of this article, as well as the later parts of the series as they are written, will be available from my website, the black hole.

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

I can be reached for comments or questions at

[ dgoodlad@junction.net ]

I sincerely hope you've gained from this article, and look forward to the next part of the series!

David Goodlad