The m4nfo User manual and Technical Report

Houses

Defining properties for and handling of houses

Introduction

The code for houses consists of three parts:

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

The house 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 house's activation function.

The house activation instantiates the house by finally assigning graphics sets and/or callback or other variable-referencing functions to this particular house-ID. This is done by supplying a list of references to the house's activation function. See below.

Functions

FunctionMeaning
definehouse(<House-ID>, <House-size>, <block>)House definition
disablehouse(<List::(Range::House-ID> | <House-ID>)>)Disable 'old' house type(s)
makehouse(<House-ID>, <List::ref()>)House activation

Description

definehouse(<House-ID>, <House-size>, <block>)

This function defines a house. Its parameters are the house's ID, its size and a block of property-defining functions, where the relative position of the property functions is irrelevant. <House-size> will be either SINGLE (1 x 1), DOUBLEX (2 x 1), DOUBLEY (1 x 2), or QUAD (2 x 2).

Example (2-tile house):
definehouse(_HOUSE1, DOUBLEX,
	substitutetype(8, 8)
	climate({TEMPERATE, ARCTIC})
	housename(smallhouse)
	population(30)
	mailgen(4)
	passaccept(4)
	mailaccept(0, 4)
	rating(500)
	removalcost(10)
	probability(8)
	timeframe(1880 .. 1930)
	lifespan(80)
	flags(HISTORIC)
	callbacks({CB_BUILD, CB_AUTOSLOPE})
)

Note that if a house is composed from more than one tile, there will be more than one House-ID as well, additional ones are created automatically in a successive way. I.e., when defining a house with ID = "5", and function substitutetype(8,8,8,8) defines four parts for this building, corresponding house-IDs would be "5", "6", "7", and "8". I.e., the next house to be defined would need ID "9".

Depending on the type of property functions, or on house definition requirements, it is possible to either set a single property value for all house tiles, or to specify different values for each of the house tiles (see example above, you might have to bracket value lists for the tiles).

In this way, it is also possible to define a number of single tile houses in a single definehouse() function. Because of internal limitations, this is only possible with houses of size SINGLE, i.e. all multi-tile houses (DOUBLEX, DOUBLEY, QUAD) must be defined in separate definehouse() functions.

disablehouse(<List::(Range::House-ID> | <House-ID>)>)

This function disables old house type(s). The <House-ID> used must be the ID(s) of the old house type(s) you want to disable. Disabling only prevents building the type but houses already present on the map will stay unchanged. The type can still be overridden, and overriding affects houses present on the map.

Example (disable old houses):
disablehouse(0 .. 15, 20, 22)

makehouse(<House-ID>, <List::ref()>)

This function activates a previously defined house. Its parameters are a house-ID and a list of references. The number of references given must match the number of house parts, respectively the number of house-IDs allocated internally:

Example (2-tile house):
makehouse(_HOUSE1, ref(10), ref(11))