Objects

Object variables

namevalue rangecomment
relative_x0..255X-coordinate (top right -> bottom left) of the tile relative to the northernmost tile.
relative_y0..255Y-coordinate (top left -> bottom right) of the tile relative to the northernmost tile.
relative_pos0xYYXXA combination of relative_x and relative_y in the format 0xYYXX. Useful if you want to check for a single position.
terrain_typeTILETYPE_NORMAL, TILETYPE_DESERT, TILETYPE_RAIN_FOREST, TILETYPE_SNOW
tile_slopeWhich corners are raised on the given tile. Bit 0: west corner is above the lowest corner.
Bit 1: south corner is above the lowest corner.
Bit 2: east corner is above the lowest corner.
Bit 3: north corner is above the lowest corner.
Bit 4: this tile is a steep slope (the corner opposite to the lowest corner is 2 units higher).
See tile slopes for an illustration
build_dateThe date this object was build.
animation_frame0..255Current animation frame
company_colour0..15Colour used for the company colour mask
owner0..0x10CompanyID of the owner of the object or 0x10 if it was build in the scenario editor
town_manhattan_distManhattan distance to the nearest town
town_euclidean_distEuclidean distance to the nearest town
town_zonetown zoneThe town zone of the current tile. The town zone from the closest town (measured in manhattan distance) is used.
Variables that require some parameters.
name arguments value range comment
nearby_tile_object_type x, y offset (-8..7) ID of the object on a nearby tile, if defined by the same grf. OBJECT_TYPE_OTHER_GRF if the object is defined by a different grf (or none at all). OBJECT_TYPE_NO_OBJECT if the tile does not contain an object.
nearby_tile_random_bits x, y offset (-8..7) Random bits of the given tile
nearby_tile_slope x, y offset (-8..7) See tile_slope
nearby_tile_is_same_object x, y offset (-8..7) 0 .. 1 Is the given tile part of the same object?
nearby_tile_is_water x, y offset (-8..7) 0 .. 1 Is the given tile a water tile?
nearby_tile_terrain_type x, y offset (-8..7) See terrain_type
nearby_tile_height x, y offset (-8..7) 0 .. 120 The minimum height of the given tile. 8 units correspond to one height level
nearby_tile_class x, y offset (-8..7) Tile class
nearby_tile_animation_frame x, y offset (-8..7) See animation_frame
object_type_count object id [, grfid] 0..0xFFFF Number of objects with the given object id currently on the map. Grfid is the grfid of the newgrf you want to check the object count of (default is current grf).
object_type_nearest object id [, grfid] 0..0xFFFF Manhattan distance to the closest object of the given type. Grfid is the grfid of the newgrf you want to check the minimum object distance of (default is current grf). If the given object type is not yet built, this will return 0xFFFF

Object properties

propertyvalue rangecomment
classString literal of length 4Unlike station classes, there is currently no default yet. You have to set the class ID before any other property or graphics. Characters allowed in the IDs are A-Z, 0-9. While you are technically free to chose your own class, it's highly recommended you stick to one of the default classes.
classnamestringYou only need to set this for one object in every class.
namestring
climates_availablebitmask(CLIMATE_XXX, CLIMATE_YYY, ...)XXX = [TEMPERATE | ARCTIC | TROPICAL | TOYLAND], alternatively NO_CLIMATE or ALL_CLIMATES
size[x, y]Size in x and y direction. Both x and y must be compiletime constants
build_cost_multipliermultiplicator to the base purchase cost
remove_cost_multipliermultiplicator to the base removal cost
introduction_datedateThe date this object becomes available to build.
end_of_life_datedateThe last date this object is buildable. Must be at least 365 days after introduction_date
object_flagsbitmask(OBJ_FLAG_XXX, OBJ_FLAG_YYY)See list of object flags
animation_infoArray [ANIMATION_XXX, frame-count]XXX = [LOOPING | NON_LOOPING], 1..253 frames
animation_speed0..16Speed of animation, see animation speed table for the meaning of the values.
animation_triggers
callback_flagsbitmask(OBJ_CBF_XXX, OBJ_CBF_YYY)XXX = [SLOPE_CHECK | DECIDE_ANIM | DECIDE_ANIM_SPEED | DECIDE_COLOUR | ADDITIONAL_TEXT | AUTOSLOPE]
height0..255Height of the object / 8. For example if your object is 16 pixels height you should set height to 2. In OpenTTD this property is used to determine the height of the build object window; the height for the object preview is set to 32 + "value of property" * 8. The property is also used to determine how high a bridge must be if it is allowed by the bit in object_flags.

Default object classes

Note: the class names listed below are recommended, you still need to set the class name for at least one object in every class or you risk to end up with objects in a class without a name. If multiple NewGRFs define objects for the same class the name defined in the last NewGRF will be used.

ClassName of the classDescription
STRUStructuresMultitile engineered objects that don't quite fit in as industries, houses or stations - dams etc.
INFRInfrastructurelightpoles, communication towers, transmission towers, road signs, etc.
BLDGBuildingsNormally accomodated by industries, houses or stations but the author feels there are limiting circumstances.
NATRNatural objectscaves, coral reefs, swamps, etc.
PARKPublic areasNormally accomodated by towns or industries (tourist stuff ...) but the author feels there are limiting circumstances - Parks, statues, etc.
ARTFArtifactsThey really don't fit under any of the above - shipwrecks, etc.
MISCMiscellaneousFor the author who is unable to accommodate his/her object under any of the previous labels.

List of object flags

NameMeaning
OBJ_FLAG_ONLY_SEOnly available in the scenario editor (incompatible with OBJ_FLAG_ONLY_INGAME)
OBJ_FLAG_IRREMOVABLEObject cannot be removed with the normal dynamite tool. In OpenTTD you can only remove the object with the magic bulldozer cheat, in TTDPatch you can remove it by holding ctrl while using the bulldozer tool. The cost of removing this object is multiplied by 25.
OBJ_FLAG_ANYTHING_REMOVEAnything can remove this object (owned land behavior)
OBJ_FLAG_ON_WATERAllow construction of the object on water
OBJ_FLAG_REMOVE_IS_INCOMERemoval cost is actually income (owned land behaviour)
OBJ_FLAG_NO_FOUNDATIONSDo not display foundations if on a slope
OBJ_FLAG_ANIMATEDSetting this flag will allow the object's animation counter to be increased, must be set if you plan to make use of animations.
OBJ_FLAG_ONLY_INGAMEOnly available during game play (incompatible with OBJ_FLAG_ONLY_SE)
OBJ_FLAG_2CCAllows 2cc mapping for objects instead of the default 1cc
OBJ_FLAG_NOT_ON_LANDDisallows construction on land (implies OBJ_FLAG_ON_WATER)
OBJ_FLAG_DRAW_WATERDraws the water under the object. Only applies when built on top of a water tile, also replaces the ground tile of the object completely. Does not work when object built on sloped water tiles.
OBJ_FLAG_ALLOW_BRIDGEAllow bridge over the object taking the building height into account.
OBJ_FLAG_RANDOM_ANIMATIONRandom bits in the "next animation frame" callback

List of object callbacks

NameMeaning
OBJ_CB_SLOPE_CHECKCheck for the slope of a tile
OBJ_CB_DECIDE_ANIMDecide whether animation continues: 0xFF stops animation, 0xFE continues with next frame
OBJ_CB_DECIDE_ANIM_SPEEDDecide the animation frame to jump to. Or alternatively: 0xFF to stop animation, 0xFE to start animation with current frame, 0xFD to keep the current animation frame and do nothing
OBJ_CB_DECIDE_COLOURReturn the colour, or for 2 company colours the two colours, to be used. In the case of 2CC the 2nd company colour goes into the high 4 bits of the return value
OBJ_CB_ADDITIONAL_TEXTReturn an additional string which is shown in the purchase menu. It should not exceed in length three lines.
OBJ_CB_AUTOSLOPEReturn a value different from 0 in order to disable autoslope behaviour.