Torque Game EngineTorque Game Engine Documentation
Version 1.3.x

GameBaseData

GameBaseData is another very simple DataBlock that provides a good base from which to build more advanced DataBlocks.

GameBaseData is slightly more complex than SimDataBlock. In particular, GameBaseData can be used to create datablocks which can be viewed in the Mission Editor . Also, GameBaseData adds support for demo- recording (demo-recording is the ability to record games in the Torque Game Engine as they are played out).

Below is a table describing GameBaseData's two pre-defined member fields.

Table D.1. GameBaseData Member Fields

Field NameTypeDefault ValueDescription
CategoryString Identifies which category in the Mission Editor objects based on this datablock will show up in.
classNameStringGameBaseDataUsed to identify this datablock's class. Value can be over-ridden in script.

Example D.2. Creating a GameBaseData Datablock in TorqueScript

In this example, we create a new GameBaseData datablock. The process is similar to that used to create a SimDataBlock .

datablock GameBaseData(myGBD) {
    category = "Brand New Category";
    newItem = "Brand new field";
};

echo(myGBD.category);
echo(myGBD.newItem);
echo(myGBD.className);
            

Running this code will result in the following lines being output to the console:

Brand New Category
Brand new field
GameBaseData
            

Note that we did not explicitly set the className field ourselves. This value is set by the engine. However, we can over-ride the className, if we want to.

As stated above, specifying a category for a GameBase datablock defines a new category of shapes in the MissionEditor. To check this, open the Mission Editor by pressing F11, then go to the Window menu, and click World Editor Creator. In the GUI that comes up, click the Shapes node, and you will see a new category called Brand New Category. Click this category to expand it, and you will see myGBD. Note: if you simply typed the above code into the console you will need to start a new mission before the changes will take effect.