Loading Your ScriptsThere is no real need to discuss the writing of your script files from VB, as you can simply use notepad or another plain-text editor to do this. But, loading your script files into your game for use is another story. There are numerous questions which can be asked about how to do this, such as how the lines of 'script' can be parsed into separate pieces, and how to store the scripts while in memory. User-Defined Types - Gotta Have 'Em!The first thing to be done is define a user-defined type for a script command line. I suggest placing this into a class module, probably called something such as CScriptParser in order to allow for further expansion in later parts of this series of articles.
This should be placed in the declarations section of your class module. Another useful UDT that should be created is one for an event block:
Storage VariablesTo prepare for storing your scripts, you'll need a variable array (put it into your declarations section of the class module you created earlier as well):
This creates a limit of 1024 possible blocks loaded simultaneously. You can always increase this if you need to. The iLastBlock variable is simply to keep track of the last element in the array which is occupied. You should initialize this variable to -1 when an instance of the class is created, so in the Class_Initialize method of your class, put:
|
||||||||||||||||||||