The m4nfo User manual and Technical Report

Objects

Defining properties for and handling of objects

Introduction

The code for objects consists of three parts:

The definition sets the feature properties of the object like introduction date, size, object-related texts, etc. Please note that an object definition may only occur after a prior grfinit() function call for the grf file.

The object's performance functions are used to group sets of graphics sprites from a previous spriteblock(), or to evaluate game-intrinsic variables, and make both of them accessible to the object's activation function.

The object activation instantiates the object by finally assigning graphics sets and/or callback or other variable-referencing functions to this particular object. This is done by supplying a block of special functions handling references and cargo types to the object's activation. See below.

Functions

FunctionMeaning
defineobject(<Object-ID>,<block>)Object definition
makeobject(<Object-ID>,<block>)Object activation

Description

defineobject(<Object-ID>, <block>)

This function defines an object. Its parameters are the object's ID and a block of property-defining functions, where the relative position of the property functions is irrelevant.

Example:
defineobject(_MOLE,
	classid("MC01")
	classname(moles)
	objectname(mole)
	climate(TEMPERATE, ARCTIC, TROPIC)
	size(1,1)
	price(20)
	timeframe(1.1.1880 .. 1.1.2050)
	flags(NOFOUNDATION, BUILDONWATER)
	callbacks(CB_SLOPE, CB_AUTOSLOPE, CB_TEXT)
	buildingheight(1)
	numviews(4)
)

makeobject(<Object-ID<, <block>)

This function activates a previously defined object. Its parameters are the object's ID and a block of special cargo-associated functions:

FunctionMeaning
link(<ref()>, <CargoType>)Linking a chain of graphics or variable-dependencies to this object
default(<ref()>)Default chain to use with this object

link(<ref()>, <CargoType>)

This function links a reference to a chain of functions describing graphics and/or variable evaluations with a particular cargo type. Its parameters are the reference to the function chain and a cargo type. The only cargo type allowed for objects is MENU, used for graphics shown in the purchase or construction window.

default(<ref()>)

This function is used if no entry from the link() function(s) matches, or if there are no special cargo-types listed at all in a link() function.

Example:
makeobject(_MOLE,
	link(ref(62),MENU)
	default(ref(60)) // graphics
)

References