Blockland Wiki
Advertisement

The datablock keyword is used to declare a new datablock in a 'server.cs'-file. A datablock object is used in the declaration and initialization of a special set of classes that take a datablock(s). Datablocks are created on the server and ghosted to clients.

Syntax

datablock DatablockClass (NewDatablockName : InheritDatablock)
{
   className = "SomeName";
 
   //DatablockBody here
};
  • DatablockClass - A predefined engine class which inherits from SimDataBlock or one of its children.
  • NewDataBlockName - The name for this datablock. Must be unique.
  • InheritDataBlock - Previously defined datablock to inherit (copy) DataBlockBody values from. Optional.
  • className - This is a special field which can be initialized with the name of a previously defined (in Torque Script) datablock. In effect, this inserts the 'SomeName' Name into the Namespace calling sequence between NewDatablockName and DatablockClass. For some datablock classes, className can be a non-datablock name, but it isn't guaranteed to work for all calling sequences or classes.
  • DataBlockBody - Fields and the values they will be assigned for this datablock.
datablock SimDataBlock (myDataBlock)
{
newField = "Hello";
newField2 = 10;
};

Here we have delcared a new SimDataBlock datablock named myDataBlock. Additionally, we have given it a new field named newField, initialized to "hello" and a new field named newField2 initialized to 10. The namespace calling sequence for this datablock is:
myDatablock -> SimDatablock

datablock SimDataBlock( mySecondDataBlock : myDataBlock)
{
className = "myDataBlock";
newField2 = 15;
};

Here we have declared a new SimDataBlock datablock named mySecondDataBlock that derives from myDataBlock. Because it is deriving from a prior datablock, it will copy any fields that were declared and/or initialized in the 'parent' datablock. However, we are re-declaring the field newField2 -- the new initialization value is taken in preference to the copied value, meaning that newField has the value "Hello" and newField2 has the value of 15. Finally, we have defined className as myDataBlock, making the namespace calling sequence for mySecondDataBlock:

mySecondDataBlock -> myDataBlock -> SimDataBlock

'Brick Example'[]

datablock fxDTSBrickData (brick1x1x1Data)
{
	brickFile = "./1x1x1.blb";
	category = "Bricks";
	subCategory = "Bricks x1";
	uiName = "1x1x1";
};

See Also[]

Advertisement