VariationalAction2/Towns: Difference between revisions

From GRFSpecs
Jump to navigation Jump to search
Content deleted Content added
m Reverted edits by Hgnmu128 (Talk) to last revision by Planetmaker
Zephyris (talk | contribs)
Add cargo production
 
(17 intermediate revisions by 4 users not shown)
Line 1: Line 1:
==Introduction==
==Introduction==


==Variables==
== Variables ==


{| |-
{| |-
!Variable!!Size!!Content
!Variable!![[GRFActionsDetailed|Size]]!!Version!!Content
|-
|-
|40||B||Larger town effect on this town
|40||B||{{ottdp| |}}||Larger town effect on this town
|-
|-
|41||W (B)||{{ottdp| |}}||Town index<ref>In OpenTTD this variable is word-sized, in TTDPatch this variable is byte-sized.</ref>
|41||B||Town index
|-
|-
|42||W (B)||{{ottdp|16|no}}||Town properties
⚫
|82||W||Population
|-
|-
|43||W (B)||{{ottdp|16|no}}||Number of nearby stations
|94..9C||W*5||5 WORD values of the town zone radii
|-
|-
|60||D||{{ottdp|16|no|}}||Land info for nearby tiles.
⚫
|B6||W||number of buildings
|-
|61||D||{{ottdp|16|no|}}||Amount of cargo produced this month (so far).
|-
|62||D||{{ottdp|16|no|}}||Amount of cargo transported this month (so far).
|-
|63||D||{{ottdp|16|no|}}||Amount of cargo produced last month.
|-
|64||D||{{ottdp|16|no|}}||Amount of cargo transported last month.
|-
|65||D||{{ottdp|16|no|}}||Amount of cargo accepted this month (so far).
|-
|66||D||{{ottdp|16|no|}}||Amount of cargo accepted last month.
|-
⚫
|82||W||{{ottdp| |}}||Population
|-
|94, 96, 98, 9A, 9C||W||{{ottdp| |}}||Square of [[TownZones|town zone]] radii for the [[TownZones|town zones]] 0 ... 4
|-
⚫
|B6||W||{{ottdp| |}}||number of buildings
|}
|}

<references />


These are accessed by using a type 82/86/8A action 2 for stations, town buildings, or industries.
These are accessed by using a type 82/86/8A action 2 for stations, town buildings, or industries.


For other 80+x variables confer the [http://marcin.ttdpatch.net/sv1codec/TTD-locations.html#_TownArray|TTD town structure].
For other 80+x variables confer the [http://marcin.ttdpatch.net/sv1codec/TTD-locations.html#_TownArray TTD town structure].


==Description==
== Description ==
===Larger town effect (40)===
=== Larger town effect (40) ===


This returns how the &quot;largertowns&quot; switch affects this town:
This returns how the "largertowns" / "economy.larger_towns" setting affects this town:


{| |-
{| |-
Line 36: Line 56:
|}
|}


===Town index (41)===
=== Town index (41) ===

⚫
This 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)

TTDPatch only: This variable has a value between 0 and 69 (inclusive).

=== Town properties (42) ===

{| |-
!Bits!!Values!!Variable
|-
|0..1||0..4||Road layout (0: Original; 1: Improved; 2: 2x2 Grid; 3: 3x3 Grid)
|}

Higher bits are reserved for future use.

=== Land info for nearby tiles (60) ===

This variable works exactly like [[VarAction2IndustryTiles#Land info of nearby tiles (62)|var. 62 for industry tiles]], except that bit 0 of the '''bb''' part is undefined.

=== Cargo info variables (61..66) ===

These variables allow to query information about accepted, produced and transported cargos.
The variables are independent of the number of cargo types and their order. The 60+x parameter specifies the cargo type as index into the cargo translation table.

(61..66) {{ottdp|16|no}}

* Variable 61: amount of cargo produced this month.
* Variable 62: amount of cargo transported this month.
* Variable 63: amount of cargo produced last month.
* Variable 64: amount of cargo transported last month.
* Variable 65: amount of cargo accepted this month.
* Variable 66: amount of cargo accepted last month.

=== Population (82) ===
Returns the population of the town, but at most 65535.

=== [[TownZones|Town zone]] radii (94, 96, 98, 9A, 9C) ===

Squares of radii of 5 [[TownZones| town zones]] where variable 94 refers to the outermost zone 0 and variable 9C to the inner most zone 4.


=== Number of buildings (B6) ===
⚫
This returns the index of the town in the town array. This value is between 0 and 69 (inclusive). 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)
Returns the number of buildings the town possesses.


==Example==
==Example==

Latest revision as of 21:29, 20 October 2026

Introduction

Variables

Variable Size Version Content
40 B Supported by OpenTTD Supported by TTDPatch Larger town effect on this town
41 W (B) Supported by OpenTTD Supported by TTDPatch Town index[1]
42 W (B) Supported by OpenTTD 1616 Not supported by TTDPatch Town properties
43 W (B) Supported by OpenTTD 1616 Not supported by TTDPatch Number of nearby stations
60 D Supported by OpenTTD 1616 Not supported by TTDPatch Land info for nearby tiles.
61 D Supported by OpenTTD 1616 Not supported by TTDPatch Amount of cargo produced this month (so far).
62 D Supported by OpenTTD 1616 Not supported by TTDPatch Amount of cargo transported this month (so far).
63 D Supported by OpenTTD 1616 Not supported by TTDPatch Amount of cargo produced last month.
64 D Supported by OpenTTD 1616 Not supported by TTDPatch Amount of cargo transported last month.
65 D Supported by OpenTTD 1616 Not supported by TTDPatch Amount of cargo accepted this month (so far).
66 D Supported by OpenTTD 1616 Not supported by TTDPatch Amount of cargo accepted last month.
82 W Supported by OpenTTD Supported by TTDPatch Population
94, 96, 98, 9A, 9C W Supported by OpenTTD Supported by TTDPatch Square of town zone radii for the town zones 0 ... 4
B6 W Supported by OpenTTD Supported by TTDPatch number of buildings
  1. ↑ In OpenTTD this variable is word-sized, in TTDPatch this variable is byte-sized.

These are accessed by using a type 82/86/8A action 2 for stations, town buildings, or industries.

For other 80+x variables confer the TTD town structure.

Description

Larger town effect (40)

This returns how the "largertowns" / "economy.larger_towns" setting affects this town:

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

Town index (41)

This 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)

TTDPatch only: This variable has a value between 0 and 69 (inclusive).

Town properties (42)

Bits Values Variable
0..1 0..4 Road layout (0: Original; 1: Improved; 2: 2x2 Grid; 3: 3x3 Grid)

Higher bits are reserved for future use.

Land info for nearby tiles (60)

This variable works exactly like var. 62 for industry tiles, except that bit 0 of the bb part is undefined.

Cargo info variables (61..66)

These variables allow to query information about accepted, produced and transported cargos. The variables are independent of the number of cargo types and their order. The 60+x parameter specifies the cargo type as index into the cargo translation table.

(61..66) Supported by OpenTTD 1616 Not supported by TTDPatch

  • Variable 61: amount of cargo produced this month.
  • Variable 62: amount of cargo transported this month.
  • Variable 63: amount of cargo produced last month.
  • Variable 64: amount of cargo transported last month.
  • Variable 65: amount of cargo accepted this month.
  • Variable 66: amount of cargo accepted last month.

Population (82)

Returns the population of the town, but at most 65535.

Town zone radii (94, 96, 98, 9A, 9C)

Squares of radii of 5 town zones where variable 94 refers to the outermost zone 0 and variable 9C to the inner most zone 4.

Number of buildings (B6)

Returns the number of buildings the town possesses.

Example