The m4nfo User manual and Technical Report

Functions for towns

Using functions for towns

Introduction

In m4nfo, towns have only one type of functions, namely functions to get information about the nearest town like location, population, town zones, number of town buildings, etc.

Functions

Function Description
townbuildings(<block>)Number of town buildings
towncargo(<CargoType>, THISMONTH | LASTMONTH, <block>)Actual number of cargo transported
townmaxcargo(<CargoType>, THISMONTH | LASTMONTH, <block>)Maximum number of cargo that could be transported
towncargofraction(<Cargotype>, <block>)Fraction of cargo transported last month
towneffect(<block>)Larger town effect on this town
townflags(<block>)Special town flags
townhousefunding(<block>)Building fund active in town, for still this many months
townindex(<block>)Town index
townlocation(<block>)Location of town on map
townpopulation(<block>)Population of town, capped at 65535
townroadworks(<block>)Road works active in town, for still this many months
townzonesize(<TownZone>, <block>)Square of given town zone radius

Description

towncargo(<CargoType>, THISMONTH | LASTMONTH, <block>)

This function returns the actual number of cargo that has been transported, either so far this month or last month. Valid CargoType is PASS, MAIL, FOOD or WATER. In case of FOOD ("fizzy drinks" in toyland) or WATER, this function returns the units delivered to this town.

Note: in climates other than sub-tropical WATER is bogus: it would be either counted as STEL, PAPR or "bubbles" (in toyland).

townmaxcargo(<CargoType>, THISMONTH | LASTMONTH, <block>)

This function returns the maximum number of cargo that could be transported, either so far this month or last month. Valid CargoType is PASS and MAIL

towncargofraction(<CargoType>, <block>)

This function returns the fraction of cargo transported last month (0xFF means 100%). Valid CargoType is PASS or MAIL.

towneffect(<block>)

This function returns a value describing how the "largertowns" / "economy.larger_towns" setting affects this town:

ValueMeaning
0largertowns is enabled, but it won't allow this town to grow larger than usual
1largertowns is enabled, and it allows to grow this town larger
2largertowns is disabled, so no towns are allowed to grow larger

townflags(<block>)

This function returns miscellaneous information about the town's behaviour:

FlagMeaning
EXPANDINGTown is in expanding mode
HASCHURCHTown has already built a church
HASSTADIUMTown has already built a stadium

townindex(<block>)

This function returns the index of the town in the town array. You can use this value to treat some towns specially. (For example, the first town on the map can be considered the capital and you can allow a Parliament to be built there, but nowhere else)

In TTDPatch, this variable has a value between 0 and 69 (inclusive).

townlocation(<block>)

This function returns the x/y-coordinate of the town's center. The function requires to test its return value by using the auxiliary function coordinate(), because its return value is a packed byte containing both coordinates.

townzonesize(<TownZone>, <block>)

This function returns the square of the town zone given as parameter:

ParameterMeaning
TZ_CENTREInnermost zone, street lights
TZ_COMMERCIALTrees
TZ_RESIDENTIALPaved roads
TZ_PERIPHERYPlain roads
TZ_OUTSKIRTS

Please note that smaller towns have fewer zones.