Torque Game EngineTorque Game Engine Documentation
Version 1.3.x

Appendix D. Torque Datablocks

Table of Contents

SimDataBlock
GameBaseData
ShapeBaseData
PlayerData
ItemData
MissionMarkerData, CameraData, PathCameraData, and StaticShapeData
VehicleData
FlyingVehicleData
HoverVehicleData
WheeledVehicleData
TriggerData
ProjectileData
DebrisData
SplashData
LightningData
PrecipitationData
ExplosionData
ParticleEmitterNodeData and ParticleEmitterData
ParticleData
WheeledVehicleTire and WheeledVehicleSpring
Summary And Thanks

Abstract

Datablocks are a very important feature of the Torque Game Engine. They can help to quickly define common data for various game objects, and can be used in conjunction with Torque's networking capabilities to enhance and speed-up network play. The Torque Game Engine comes with several pre-defined datablocks which game makers can use to rapidly implement many common kinds of game objects. Game makers can also create their own new kinds of datablocks.

This appendix offers a reference listing of all the datablocks that are pre-defined in Torque, and provides a detailed description of every member field exposed to TorqueScript. This reference approaches datablocks as they are used in TorqueScript. Documentation on Torque Game Engine datablocks as they are used in C++ is also available.

Note

A word on style: this reference is written from a technical point of view, and in the interest of offering the most precise descriptions possible, uses technical language. The goal is to provide datablock field descriptions which are as close to the source-code as possible, without simply doing a code-dump. As such, this reference should not be approached as a tutorial on datablocks. Of course, it strives to be as clear as possible without jeapordizing the technical accuracy of the descriptions offered.

For an easy to read tutorial on datablocks which does a much better job of answering questions like "what are datablocks?", "why do you use them?", and "how do you use them?", see forthcoming official TorqueScript tutorials, which should be available in the coming weeks.

SimDataBlock

The most basic DataBlock available for use in TorqueScript is the SimDataBlock. This DataBlock is extremely simple; in fact, by default it defines no data which is visible within TorqueScript. However, the SimDataBlock can be useful in script as a base from which to build more detailed datablocks. Within the engine itself, all datablocks are derived from SimDataBlock.

Example D.1. Creating a SimDataBlock Datablock in TorqueScript

In this example, we will introduce the syntax used to work with datablocks in TorqueScript by creating a new SimDataBlock. The new SimDataBlock will be named "myDataBlock", and we will give it a new member field, called "newMemberItem". The names "myDataBlock" and "newMemberItem" are arbitrary, we could name them anything we want.

datablock SimDataBlock(myDataBlock) {
    newMemberItem = "Hello";
};

echo(myDataBlock.newMemberItem);
            

Running this code will result in the text "Hello" being output to the console. More complex datablocks are defined in a similar fashion.

Note that datablocks of any kind must have at least one member field defined and filled with data in order to be valid. The item may be either pre-defined in the engine or added in script. The above code would not work if we had not defined newMemberItem (or some other member field).