Loading...
 
Classes        

Classes

Classes define a kind of thing that can be instantiated in the engine, like a street lamp, a building, or a chunk of land. They have attributes that define their, such as the mesh, rendering distance, etc.

Grammar

 class `path/name` (parent) { ...attributes... }

Attributes are separated by commas.

Remember that you don't need to specify the path if the class is to be defined in the same folder as the lua that it is defined on. The mesh will be the name of the class with '.mesh' appended unless overridden (see below).

Parents

Classes inherit from some abstract parents that set up the majority of their behaviour. You just need to override a few remaining things to make your class unique. It is also possible to create your own parent class if you want to make something very sophisticated, such as a special kind of vehicle.

BaseClass

The BaseClass doesn't have TCOL, you will just walk through it like it's not there. Useful for grass, lighting effects, etc.

ColClass

This class needs a TCOL collision file. You don't need to specify it if it has the same name as the class.

Vehicles

Each vehicle class, e.g. Evo, Seat, etc defines a parent, each of which in term inherit from the parent 'Vehicle'. This is necessary due to limitations in the engine. At some point in the future, the only parent will be 'Vehicle' and creating a custom vehicle will just require a class declaration as you would use for a custom building, etc.

There is also currently a 'Plane' class and a 'Bike' class. Vehicles are a work in progress, it is best just to look at the lua files and ask questions on IRC or the forums.

Attributes

 renderingDistance=400

The rendering distance of the mesh, in game units. If the distance between the camera and the object is bigger than its renderingDistance, it will start to fade.

 gfxMesh = `path/name.mesh`

The mesh file to use. Defaults to the name of the class suffixed with '.mesh'

 colMesh = `path/name.tcol`

For ColClass only (ignored by BaseClass). The TCOL file to use. Defaults to the name of the class suffixed with '.tcol'

 castShadows = true

If you want the object to cast shadows, set to true. Defaults to false.

 receiveShadows = true

If you want the object to not receive shadows, set to false. Defaults to true.

 placementZOffset = 0.5

If an object of this class with the 'place' function or with procedural objects, this defines the vertical offset used to prevent it intersecting with the ground.

 placementRandomRotation = true

Set this to true if you want objects to be randomly rotated about Z when you place them with 'place'.

Tools


See also


Category:Mapping?