Difference between revisions of "NML:Industries"

From GRFSpecs
Jump to navigationJump to search
m (remove double title heading)
(Added example code for setting a specific bit to return a custom message)
 
(73 intermediate revisions by 13 users not shown)
Line 1: Line 1:
  +
{{NMLNavPropVarCB}}
This page contains information on both industry and industry tile properties, variables and callbacks.
 
  +
  +
This page contains information on industry properties, variables and callbacks. [[NML:IndustryTiles|Industry tiles]] are closely related.
  +
  +
== Industry ID allocation ==
  +
Industry IDs are local to the NewGRF, you are free to choose any ID in the 0..127-range. You should start your item definition with the 'substitute'-property, which allocates a new industry. The value of this property should be the ID of a [[IndustryDefaultProps|default industry]], which will be used instead of your item if it is not available for whatever reason (for example, missing NewGRF).
  +
  +
Furthermore, you can set the 'override'-property, which will cause the existing industry to be replaced with your item. You should use this if you are for example defining a coal mine which changes production more dynamically. If your type is not a direct replacement of an existing item, don't set this property.
   
 
==Industry properties==
 
==Industry properties==
Line 5: Line 12:
 
Industry properties. Default industry type numbers can be found at [[NML:Default industries|default industries]].
 
Industry properties. Default industry type numbers can be found at [[NML:Default industries|default industries]].
   
{| class="t"
+
{| class="wikitable sortable"
 
! property
 
! property
 
! value range
 
! value range
Line 12: Line 19:
 
| substitute
 
| substitute
 
| industry type
 
| industry type
| Number of the original industry type that replaces this one, should it not be available for some reason (e.g. missing NewGRF). This ''must'' be the first property to be set, before any other properties or graphics. All properties of the old type are copied to your new industry.
+
| Number of the original industry type that replaces this one, should it not be available for some reason (e.g. missing NewGRF). '''This property ''must'' be set first, before any other properties or graphics.''' All properties of the old type are copied to your new industry.
 
|-
 
|-
 
| override
 
| override
Line 24: Line 31:
 
|-
 
|-
 
| life_type
 
| life_type
| One of IND_LIFE_TYPE_XXX, XXX = BLACK_HOLE | EXTRACTIVE | ORGANIC | PROCESSING
+
| One of IND_LIFE_TYPE_XXX, XXX = BLACK_HOLE <nowiki>|</nowiki> EXTRACTIVE <nowiki>|</nowiki> ORGANIC <nowiki>|</nowiki> PROCESSING
 
| The generic type of industry. This determines the production changes that occur by default (when not using the callback). Examples are respectively power plants, coal mines, forests en steel mills.
 
| The generic type of industry. This determines the production changes that occur by default (when not using the callback). Examples are respectively power plants, coal mines, forests en steel mills.
 
|-
 
|-
Line 45: Line 52:
 
| 0..255
 
| 0..255
 
| Fund cost multiplier. Note that in OpenTTD the unmodified base cost is 8x higher for building (not prospecting) raw (=extractive / organic, see life_type) industries.
 
| Fund cost multiplier. Note that in OpenTTD the unmodified base cost is 8x higher for building (not prospecting) raw (=extractive / organic, see life_type) industries.
  +
|-
  +
| cargo_types
  +
| array of accept_cargo(input, outputs...) and produce_cargo(output, level) expressions
  +
| {{nml|0.5}} {{ottd|1.9}} Types of cargo accepted and produced by the industry, and their production levels and production multipliers. See [[#Cargo_types_array|cargo types array]] below.
 
|-
 
|-
 
| prod_cargo_types
 
| prod_cargo_types
 
| array of up to 2 ints
 
| array of up to 2 ints
| Types of cargo produced. Use the cargotype(&lt;label&gt;) built-in function to specify a label from the cargotable.
+
| {{nml|0.4}} Types of cargo produced. Use the cargotype(&lt;label&gt;) built-in function to specify a label from the cargotable. {{nml|0.5}} Removed, use cargo_types instead.
 
|-
 
|-
 
| accept_cargo_types
 
| accept_cargo_types
 
| array of up to 3 ints
 
| array of up to 3 ints
| Types of cargo accepted. Use the cargotype(&lt;label&gt;) built-in function to specify a label from the cargotable
+
| {{nml|0.4}} Types of cargo accepted. Use the cargotype(&lt;label&gt;) built-in function to specify a label from the cargotable. {{nml|0.5}} Removed, use cargo_types instead.
 
|-
 
|-
 
| prod_multiplier
 
| prod_multiplier
 
| array of up to 2 ints (0..255)
 
| array of up to 2 ints (0..255)
| Amount of each output cargo to produce every 256 ticks (8 or 9 times a month)
+
| {{nml|0.4}} Amount of each output cargo to produce every 256 ticks (8 or 9 times a month) {{nml|0.5}} Removed, use cargo_types instead.
 
|-
 
|-
 
| min_cargo_distr
 
| min_cargo_distr
Line 67: Line 78:
 
|-
 
|-
 
| conflicting_ind_types
 
| conflicting_ind_types
| array of up to 3x industry_type(IND_TYPE_OLD | IND_TYPE_NEW, id)
+
| array of up to 3x industry_type(IND_TYPE_OLD <nowiki>|</nowiki> IND_TYPE_NEW, id)
 
|
 
|
 
Three industry types that should not be nearby. Use the [[NML:Builtin functions|builtin function]] <code style="color:darkgreen">industry_type(..)</code> to define either an old industry (using the global ID) or a new industry from your grf (using the grf-local ID).
 
Three industry types that should not be nearby. Use the [[NML:Builtin functions|builtin function]] <code style="color:darkgreen">industry_type(..)</code> to define either an old industry (using the global ID) or a new industry from your grf (using the grf-local ID).
 
|-
 
|-
 
| prob_random
 
| prob_random
| 0..10
+
| 0..255
| Probability of occurring while generating initial industries.
+
| (up to NML v5796-418, use prob_map_gen otherwise) Probability of occurring while generating initial industries. If the random game probability value is nonzero and IND_FLAG_DO_NOT_FORCE_INSTANCE_AT_MAP_GENERATION is not set, at least one instance of this type is guaranteed to appear on the map.
  +
|-
  +
| prob_map_gen
  +
| 0..255
  +
| (NML v5796-418 or newer) Probability of occurring while generating initial industries. If the random game probability value is nonzero and IND_FLAG_DO_NOT_FORCE_INSTANCE_AT_MAP_GENERATION is not set, at least one instance of this type is guaranteed to appear on the map.
 
|-
 
|-
 
| prob_in_game
 
| prob_in_game
| 0..10
+
| 0..255
 
| Probability of occurring while creating industries during the game.
 
| Probability of occurring while creating industries during the game.
 
|-
 
|-
Line 95: Line 110:
 
| input_multiplier_1
 
| input_multiplier_1
 
| array of up to 2 floats (0..255)
 
| array of up to 2 floats (0..255)
| Output cargo multiplication factors for getting a unit of the first accepted cargo.
+
| {{nml|0.4}} Output cargo multiplication factors for getting a unit of the first accepted cargo. {{nml|0.5}} Removed, use cargo_types instead.
 
|-
 
|-
 
| input_multiplier_2
 
| input_multiplier_2
 
| array of up to 2 floats (0..255)
 
| array of up to 2 floats (0..255)
| Output cargo multiplication factors for getting a unit of the second accepted cargo.
+
| {{nml|0.4}} Output cargo multiplication factors for getting a unit of the second accepted cargo. {{nml|0.5}} Removed, use cargo_types instead.
 
|-
 
|-
 
| input_multiplier_3
 
| input_multiplier_3
 
| array of up to 2 floats (0..255)
 
| array of up to 2 floats (0..255)
| Output cargo multiplication factors for getting a unit of the third accepted cargo.
+
| {{nml|0.4}} Output cargo multiplication factors for getting a unit of the third accepted cargo. {{nml|0.5}} Removed, use cargo_types instead.
 
|-
 
|-
 
| name
 
| name
Line 125: Line 140:
 
| nearby_station_name
 
| nearby_station_name
 
| string
 
| string
| Default additional name for a nearby station
+
| Default name for a nearby station.
  +
To follow the "<Town Name> <Industry Name>" convention, the string should include a "{STRING}" at the position the town name shall be inserted. For example:
  +
STR_HARBOR_NEARBY_NAME :{STRING} water side
 
|}
 
|}
  +
  +
===Cargo types array===
  +
The ''cargo_types'' property takes an array of accept_cargo and produce_cargo expressions. This array is used to define which cargo types the industry accepts, which it produces, and how much cargo is produced on production ticks and on delivery. All cargo types the industry handles must be mentioned in its ''cargo_types'' property even when they are handled by production callbacks.
  +
  +
The following is an example of a ''cargo_types'' property:
  +
  +
cargo_types: [
  +
produce_cargo("GOOD", 4),
  +
accept_cargo("PASS"),
  +
produce_cargo("PASS", 0),
  +
accept_cargo("IORE", produce_cargo("STEL", 1), produce_cargo("SLAG", 0.25))
  +
]
  +
  +
The above example has four items in its ''cargo_types'' array, two produce_cargo expressions and two accept_cargo expressions.
  +
  +
# <code>produce_cargo("GOOD", 4)</code> specifies the industry produces GOOD at a rate of 4 every production tick (256 game ticks), this production rate is scaled by the industry's production level.
  +
# <code>accept_cargo("PASS")</code> specifies the industry accepts PASS as a "black hole", that is no cargo is produced when PASS is delivered. If you have a production callback that consumes a cargo you will also need to specify that cargo in this way.
  +
# <code>produce_cargo("PASS", 0)</code> specifies the industry produces PASS but not on the production ticks as usual. Specifying a production rate of zero is only useful for cargo types you produce via a production callback.
  +
# <code>accept_cargo("IORE", produce_cargo(...), ...)</code> specifies the industry produces the listed cargo types every time IORE is delivered. In the example above, delivering one IORE will result in one STEL produced and no SLAG produced (because 1*0.25 is zero after rounding down), and delivering 4 IORE will result in 4 STEL and 1 SLAG produced.
  +
  +
At most 16 different cargo labels may appear in accept_cargo and at most 16 different cargo labels in produce_cargo, for a single industry. The same cargo label can be used in as many accept_cargo or produce_cargo as necessary.
  +
  +
More complex production rules can be set up via the production callbacks, see [[#Industry_callbacks|callbacks]] below.
   
 
===Industry special flags===
 
===Industry special flags===
   
{| class="t"
+
{| class="wikitable sortable"
 
! flag
 
! flag
 
! meaning
 
! meaning
Line 187: Line 227:
 
| IND_FLAG_ALLOW_CLOSING_LAST_INSTANCE
 
| IND_FLAG_ALLOW_CLOSING_LAST_INSTANCE
 
| Allow closing down the last instance of this type (No industry has this bit set by default.)
 
| Allow closing down the last instance of this type (No industry has this bit set by default.)
|}
 
 
==Industry tile properties==
 
 
{| class="t"
 
! property
 
! value range
 
! comment
 
 
|-
 
|-
  +
| IND_FLAG_LONG_CARGO_TYPE_LISTS
| substitute
 
  +
| New format for callbacks <code>callbacks cargo_subtype_display</code>, <code>cargo_input</code>, <code> cargo_output</code> to support more input/output cargos. See the callbacks for details.
|
 
[[NML:Default industry tiles|0..174]]
 
| Number of the default industry tile that replaces this one, if this industry tile is not available for some reason. This property ''must'' be set first, before any other properties or graphics. All properties of the old type are copied to your new house.
 
 
|-
 
|-
  +
| IND_FLAG_DO_NOT_CLAMP_PASSENGER_PRODUCTION
| override
 
  +
| {{nml|0.7}} {{ottd|1.11}} By default OpenTTD's smooth economy clamps the production of passenger (like for oil rigs). This flag disables the clamping.
|
 
[[NML:Default industry tiles|0..174]]
 
| id of the default industry tile which this industry tile replaces. This will cause your industry tile to be placed instead of the default industry tile. This is ignored, if the default industry tile has already been overridden. You can define this property multiple times
 
|-
 
| accepted_cargos
 
| Array with up to 3 [cargo_id, amount]-pairs.
 
| The cargos that are accepted by this tile. CargoID is a cargo type from your cargo translation table, amount is the acceptance of the given cargo in 1/8 units.<br /> Example: to make a tile accept both COAL and IORE you could use this: <code style="color:darkgreen"><nowiki>accepted_cargos: [[COAL, 8], [IORE, 8]];</nowiki></code><br /> Example: for a tile that doesn't any cargos at all you'd use: <code style="color:darkgreen">accepted_cargos: [];</code>
 
|-
 
| land_shape_flags
 
|
 
bitmask([[#Land shape flags|Land shape flags]])
 
|
 
|-
 
| callback_flags
 
| bitmask(INDTILE_CBF_XXX, INDTILE_CBF_YYY)
 
|
 
Do not set this, unless you use [[NML:Old style callbacks|old-style callbacks]].
 
|-
 
| animation_info
 
| Array [ANIMATION_XXX, frame-count]
 
| XXX = [LOOPING | NON_LOOPING], 1..253 frames
 
|-
 
| animation_speed
 
| 0..16
 
|
 
Speed of animation, see [[NML:Animation speed|animation speed table]] for the meaning of the values.
 
|-
 
| animation_triggers
 
| bitmask(ANIM_TRIGGER_INDTILE_XXX, ... )
 
|
 
Bitmask of triggers that will trigger the <code style="color:darkgreen">anim_control</code> callback, see the [[#Animation triggers|table]] below.
 
|-
 
| special_flags
 
| bitmask(INDTILE_FLAG_XXX)
 
| XXX is a special flag description. Currently there's only one flag defined: set INDTILE_FLAG_RANDOM_ANIMATION if the decision in anim_control callback needs random bits via extra_callback_info1
 
 
|}
 
|}
   
  +
{{NML:IndustryCommonVariables}}
===Land shape flags===
 
 
{| class="t"
 
! Flag
 
! Meaning
 
|-
 
| LSF_CANNOT_LOWER_NW_EDGE
 
| North-west edge cannot be lowered
 
|-
 
| LSF_CANNOT_LOWER_NE_EDGE
 
| North-east edge cannot be lowered
 
|-
 
| LSF_CANNOT_LOWER_SW_EDGE
 
| South-west edge cannot be lowered
 
|-
 
| LSF_CANNOT_LOWER_SE_EDGE
 
| South-east edge cannot be lowered
 
|-
 
| LSF_ONLY_ON_FLAT_LAND
 
| This tile can only be built on flat land
 
|-
 
| LSF_ALLOW_ON_WATER
 
| The land/water check is disabled for this tile so it can be built on water. If you need more control over this use callback 0x2F.
 
|}
 
 
==Common variables==
 
 
The following variables are available to both industries and industry tiles. All of them require an x, y offset. For industries, this offset is unsigned and relative to the northernmost tile. For industry tiles, it is signed and relative to the current tile.
 
 
{| class="t"
 
! name
 
! value range
 
! comment
 
|-
 
| nearby_tile_slope
 
| SLOPE_XXX
 
|
 
See [[NML:List of tile slopes|tile slopes]] for an overview of possible values
 
|-
 
| nearby_tile_is_water
 
| 1 if the tile is water, 0 otherwise
 
|
 
|-
 
| nearby_tile_terrain_type
 
| TILETYPE_XX
 
| TILETYPE_NORMAL, TILETYPE_DESERT, TILETYPE_RAIN_FOREST, TILETYPE_SNOW
 
|-
 
| nearby_tile_water_class
 
| WATER_CLASS_XXX
 
| XXX = [NONE | SEA | CANAL | RIVER] Note that tiles for which <code style="color:darkgreen">nearby_tile_is_water</code> is 0 may still have a water class, e.g. industry tiles with water beneath them.
 
|-
 
| nearby_tile_height
 
| 0..120
 
| The height of the lowest corner of the given tile.
 
|-
 
| nearby_tile_class
 
|
 
[[NML:List of tile classes|Tile class]]
 
|
 
|-
 
| nearby_tile_animation_frame
 
| 0..255
 
| Animation frame of the given tile
 
|-
 
| nearby_tile_industrytile_id
 
| 0x00aa, 0xFFbb, 0xFFFE or 0xFFFF
 
| 0x00aa: The tile is an industry tile that is part of this GRF, the tile id is aa.<br /> 0xFFbb: The tile is an original industry tile with id bb.<br /> 0xFFFE: The tile is an industry tile defined in another GRF.<br /> 0xFFFF: The tile is not an industry tile or it belongs to another GRF.
 
|}
 
   
 
==Industry variables==
 
==Industry variables==
   
{| class="t"
+
{| class="wikitable sortable"
 
! name
 
! name
 
! value range
 
! value range
Line 321: Line 250:
 
| waiting_cargo_1
 
| waiting_cargo_1
 
| 0..65535
 
| 0..65535
| If any of the production callbacks is enabled, this variable will contain the amount of the first cargo type awaiting to be processed.
+
| If any of the production callbacks is enabled, this variable will contain the amount of the first cargo type awaiting to be processed. {{nml|0.5}} Removed. Use <code>incoming_cargo_waiting</code> instead.
 
|-
 
|-
 
| waiting_cargo_2
 
| waiting_cargo_2
 
| 0..65535
 
| 0..65535
| If any of the production callbacks is enabled, this variable will contain the amount of the second cargo type awaiting to be processed.
+
| If any of the production callbacks is enabled, this variable will contain the amount of the second cargo type awaiting to be processed. {{nml|0.5}} Removed. Use <code>incoming_cargo_waiting</code> instead.
 
|-
 
|-
 
| waiting_cargo_3
 
| waiting_cargo_3
 
| 0..65535
 
| 0..65535
| If any of the production callbacks is enabled, this variable will contain the amount of the third cargo type awaiting to be processed.
+
| If any of the production callbacks is enabled, this variable will contain the amount of the third cargo type awaiting to be processed. {{nml|0.5}} Removed. Use <code>incoming_cargo_waiting</code> instead.
 
|-
 
|-
| produced_cargo_waiting_1
+
| produced_cargo_waiting_1
 
| 0..65535
 
| 0..65535
| The amount of produced 'output cargo type 1' that this waiting to be transported.
+
| The amount of produced 'output cargo type 1' that this waiting to be transported. {{nml|0.5}} Removed. Use <code>produced_cargo_waiting</code> instead.
 
|-
 
|-
 
| produced_cargo_waiting_2
 
| produced_cargo_waiting_2
 
| 0..65535
 
| 0..65535
| The amount of produced 'output cargo type 2' that this waiting to be transported.
+
| The amount of produced 'output cargo type 2' that this waiting to be transported. {{nml|0.5}} Removed. Use <code>produced_cargo_waiting</code> instead.
 
|-
 
|-
 
| produced_this_month_1
 
| produced_this_month_1
 
| 0..65535
 
| 0..65535
| The amount of 'output cargo type 1' that was produced this month.
+
| The amount of 'output cargo type 1' that was produced this month. {{nml|0.5}} Removed. Use <code>this_month_production</code> instead.
 
|-
 
|-
 
| produced_this_month_2
 
| produced_this_month_2
 
| 0..65535
 
| 0..65535
| The amount of 'output cargo type 2' that was produced this month.
+
| The amount of 'output cargo type 2' that was produced this month. {{nml|0.5}} Removed. Use <code>this_month_production</code> instead.
 
|-
 
|-
 
| produced_last_month_1
 
| produced_last_month_1
 
| 0..65535
 
| 0..65535
| The amount of 'output cargo type 1' that was produced last month.
+
| The amount of 'output cargo type 1' that was produced last month. {{nml|0.5}} Removed. Use <code>last_month_production</code> instead.
 
|-
 
|-
 
| produced_last_month_2
 
| produced_last_month_2
 
| 0..65535
 
| 0..65535
| The amount of 'output cargo type 2' that was produced last month.
+
| The amount of 'output cargo type 2' that was produced last month. {{nml|0.5}} Removed. Use <code>last_month_production</code> instead.
 
|-
 
|-
 
| transported_this_month_1
 
| transported_this_month_1
 
| 0..65535
 
| 0..65535
| The amount of 'output cargo type 1' that was transported this month.
+
| The amount of 'output cargo type 1' that was transported this month. {{nml|0.5}} Removed. Use <code>this_month_transported</code> instead.
 
|-
 
|-
 
| transported_this_month_2
 
| transported_this_month_2
 
| 0..65535
 
| 0..65535
| The amount of 'output cargo type 2' that was transported this month.
+
| The amount of 'output cargo type 2' that was transported this month. {{nml|0.5}} Removed. Use <code>this_month_transported</code> instead.
 
|-
 
|-
 
| transported_last_month_1
 
| transported_last_month_1
 
| 0..65535
 
| 0..65535
| The amount of 'output cargo type 1' that was produced last month.
+
| The amount of 'output cargo type 1' that was produced last month. {{nml|0.5}} Removed. Use <code>last_month_transported</code> instead.
 
|-
 
|-
 
| transported_last_month_2
 
| transported_last_month_2
 
| 0..65535
 
| 0..65535
| The amount of 'output cargo type 2' that was produced last month.
+
| The amount of 'output cargo type 2' that was produced last month. {{nml|0.5}} Removed. Use <code>last_month_transported</code> instead.
 
|-
 
|-
 
| transported_last_month_pct_1
 
| transported_last_month_pct_1
 
| 0..100
 
| 0..100
| Percentage of produced 'output cargo type 1' that was transported last month.
+
| Percentage of produced 'output cargo type 1' that was transported last month. {{nml|0.5}} Removed. Use <code>transported_last_month_pct</code> instead.
 
|-
 
|-
 
| transported_last_month_pct_2
 
| transported_last_month_pct_2
 
| 0..100
 
| 0..100
| Percentage of produced 'output cargo type 2' that was transported last month.
+
| Percentage of produced 'output cargo type 2' that was transported last month. {{nml|0.5}} Removed. Use <code>transported_last_month_pct</code> instead.
  +
|-
  +
| production_rate_1
  +
| 0..255
  +
| {{nml|0.3}} Amount of 'output cargo type 1' that is produced every 256 ticks. Initial value from the <code>prod_multiplier</code>-property, but it will change accordingly when the production level changes. {{nml|0.5}} Removed. Use <code>production_rate</code> instead.
  +
|-
  +
| production_rate_2
  +
| 0..255
  +
| {{nml|0.3}} Amount of 'output cargo type 2' that is produced every 256 ticks. Initial value from the <code>prod_multiplier</code>-property, but it will change accordingly when the production level changes. {{nml|0.5}} Removed. Use <code>production_rate</code> instead.
 
|-
 
|-
 
| water_distance
 
| water_distance
Line 425: Line 362:
 
| date(year, month, day)
 
| date(year, month, day)
 
| Date when cargo was accepted for the last time. Not valid before 1920 and after 2090.
 
| Date when cargo was accepted for the last time. Not valid before 1920 and after 2090.
  +
|-
  +
| random_bits
  +
| 0 ... 65535
  +
| Random data that can be used to randomize certain descisions. (see [[NML:Random_switch|Random switch]]) (NML r1666)
  +
|
  +
|-
  +
| gs_disallows_prod_decrease
  +
| [0 <nowiki>|</nowiki> 1]
  +
| {{nml|0.7}}{{ottd|1.11}} GameScript can optionally set a property that to indicate that production should not decrease at this industry. This will be automatically applied for organic and extractive industries, *if* the NewGRF industry production callback is *not* used *and* smooth economy is enabled. In other cases, NewGRF industries can provide behaviour as requested by the GameScript by reading this variable during production callbacks.
  +
|
  +
|-
  +
| gs_disallows_prod_increase
  +
| [0 <nowiki>|</nowiki> 1]
  +
| {{nml|0.7}}{{ottd|1.11}} GameScript can optionally set a property that to indicate that production should not increase at this industry. This will be automatically applied for organic and extractive industries, *if* the NewGRF industry production callback is *not* used *and* smooth economy is enabled. In other cases, NewGRF industries can provide behaviour as requested by the GameScript by reading this variable during production callbacks.
  +
|
  +
|-
  +
| gs_disallows_closure
  +
| [0 <nowiki>|</nowiki> 1]
  +
| {{nml|0.7}}{{ottd|1.11}} GameScript can optionally set a property that to indicate that this industry should not close. NewGRF industries can use this variable to read the property set by GameScript and provide the appropriate closure behaviour. Any closure already scheduled will still take place.
 
|}
 
|}
   
 
<br /> Variables that require some parameters.
 
<br /> Variables that require some parameters.
   
{| class="t"
+
{| class="wikitable sortable"
 
! name
 
! name
 
! arguments
 
! arguments
Line 435: Line 391:
 
|-
 
|-
 
| industry_count
 
| industry_count
| industry_type, grfid = -1
+
| industry_type, grfid = -1
 
|
 
|
 
The value of this variable is the number of industries of a given type that are currently on the map. industry_type is either the ID of an industry. GRFid is the grf in which the industry was defined. The default value is -1, which means current newgrf. A grfid of 0 lets you check the number of default industries of a given type. Use the [[NML:Builtin functions|builtin function]] <code style="color:darkgreen">str2number()</code> to convert a grfid to its numeric representation.<br />''Warning: using this variable trashes the contents of temporary storage register 0x100''
 
The value of this variable is the number of industries of a given type that are currently on the map. industry_type is either the ID of an industry. GRFid is the grf in which the industry was defined. The default value is -1, which means current newgrf. A grfid of 0 lets you check the number of default industries of a given type. Use the [[NML:Builtin functions|builtin function]] <code style="color:darkgreen">str2number()</code> to convert a grfid to its numeric representation.<br />''Warning: using this variable trashes the contents of temporary storage register 0x100''
 
|-
 
|-
 
| industry_distance
 
| industry_distance
| industry_type, grfid = -1
+
| industry_type, grfid = -1
 
| The value of this variable is the manhattan distance the closest instance of the given industry or 0xFFFF if not applicable. See industry_count for a description of the parameters.<br />''Warning: using this variable trashes the contents of temporary storage register 0x100.''
 
| The value of this variable is the manhattan distance the closest instance of the given industry or 0xFFFF if not applicable. See industry_count for a description of the parameters.<br />''Warning: using this variable trashes the contents of temporary storage register 0x100.''
 
|-
 
|-
 
| industry_layout_count / industry_layout_distance
 
| industry_layout_count / industry_layout_distance
| industry_type, layout, grfid = -1.
+
| industry_type, layout, grfid = -1.
 
| See industry_count / industry_distance for description of industry_type, grfid and return value. The results are filtered to industries that have the given layout number.<br />''Warning: using this variable trashes the contents of temporary storage registers 0x100 and 0x101.''
 
| See industry_count / industry_distance for description of industry_type, grfid and return value. The results are filtered to industries that have the given layout number.<br />''Warning: using this variable trashes the contents of temporary storage registers 0x100 and 0x101.''
 
|-
 
|-
 
| industry_town_count
 
| industry_town_count
| industry_type, grfid = -1.
+
| industry_type, grfid = -1.
 
| See industry_count / industry_distance for description of industry_type, grfid and return value. The results are filtered to industries that have the same town than the current industry.<br />''Warning: using this variable trashes the contents of temporary storage registers 0x100 and 0x101.''
 
| See industry_count / industry_distance for description of industry_type, grfid and return value. The results are filtered to industries that have the same town than the current industry.<br />''Warning: using this variable trashes the contents of temporary storage registers 0x100 and 0x101.''
 
|-
 
|-
Line 467: Line 423:
 
| x, y
 
| x, y
 
| Parameters indicate an unsigned offset relative to the northern tile. Returns the random bits of the selected industry tile, or 0 if it is not an industry tile that's part of this industry.
 
| Parameters indicate an unsigned offset relative to the northern tile. Returns the random bits of the selected industry tile, or 0 if it is not an industry tile that's part of this industry.
|}
 
 
==Industry tile variables==
 
 
{| class="t"
 
! name
 
! value range
 
! comment
 
 
|-
 
|-
  +
| incoming_cargo_waiting
| construction_state
 
  +
| cargo label from the cargotable
| 0..3
 
  +
| {{nml|0.5}} If any of the production callbacks is enabled, this variable will contain the amount of the cargo type waiting to be processed. Returns 0..65535. Example: <code>incoming_cargo_waiting("FOOD")</code>.
| Current construction state of the industry tile.
 
 
|-
 
|-
  +
| produced_cargo_waiting
| terrain_type
 
  +
| cargo label from the cargotable
| TILETYPE_XX
 
  +
| {{nml|0.5}} For the given cargo label, the amount of produced cargo that this waiting to be transported. Returns 0..65535. Example: <code>produced_cargo_waiting("GOOD")</code>.
| TILETYPE_NORMAL, TILETYPE_DESERT, TILETYPE_RAIN_FOREST, TILETYPE_SNOW
 
 
|-
 
|-
  +
| this_month_production
| town_zone
 
  +
| cargo label from the cargotable
|
 
  +
| {{nml|0.5}} For the given cargo label, amount of cargo that was produced this month. Returns 0..65535. Example: <code>this_month_production("COAL")</code>.
[[NML:List of town zones|town zone]]
 
| The town zone of the current tile.
 
 
|-
 
|-
  +
| last_month_production
| relative_x
 
  +
| cargo label from the cargotable
| 0..255
 
  +
| {{nml|0.5}} For the given cargo label, amount of cargo that was produced last month. Returns 0..65535. Example: <code>last_month_production("WOOD")</code>.
| X-coordinate (top right -&gt; bottom left) of the tile relative to the northernmost tile.
 
 
|-
 
|-
  +
| this_month_transported
| relative_y
 
  +
| cargo label from the cargotable
| 0..255
 
  +
| {{nml|0.5}} For the given cargo label, amount of produced cargo that was transported this month. Returns 0..65535. Example: <code>this_month_transported("IORE")</code>.
| Y-coordinate (top left -&gt; bottom right) of the tile relative to the northernmost tile.
 
 
|-
 
|-
  +
| last_month_transported
| relative_pos
 
  +
| cargo label from the cargotable
| 0xYYXX
 
  +
| {{nml|0.5}} For the given cargo label, amount of produced cargo that was transported last month. Returns 0..65535. Example: <code>last_month_transported("PAPR")</code>.
|
 
A combination of relative_x and relative_y in the format 0xYYXX. Useful if you want to check for a single position. The [[NML:Builtin functions|builtin function]] relative_coord(x, y) may be useful when making comparisons.
 
 
|-
 
|-
  +
| transported_last_month_pct
| animation_frame
 
  +
| cargo label from the cargotable
| 0..255
 
  +
| {{nml|0.5}} For the given cargo label, percentage of produced cargo that was transported last month. Returns 0..100. Example: <code>transported_last_month_pct("BATT")</code>.
| Current animation frame.
 
|}
 
 
<br />
 
 
Industry tiles have access to the [[#Common variables|common variables]] described above. Additionally, they have access to the following:
 
 
{| class="t"
 
! name
 
! arguments
 
! comment
 
 
|-
 
|-
  +
| production_rate
| nearby_tile_is_same_industry
 
  +
| cargo label from the cargotable
| x, y
 
  +
| {{nml|0.5}} For the given cargo label, amount of output cargo that is produced every 256 ticks. Initial value from the <code>cargo_types</code> property, but it will change accordingly when the production level changes. Returns 0..255. Example: <code>production_rate("SUGR")</code>.
| Parameters indicate a signed tile offset relative to the current tile. Returns 1 if the tile is part of the same industry, 0 otherwise
 
 
|}
 
|}
   
 
==Industry callbacks==
 
==Industry callbacks==
   
{| class="t"
+
{| class="wikitable sortable"
 
! callback
 
! callback
 
! return value
 
! return value
Line 533: Line 469:
 
|-
 
|-
 
| produce_cargo_arrival
 
| produce_cargo_arrival
| Produce-block
+
| [[NML:Produce|Produce-block]]
 
| Called to produce cargo when it arrives.
 
| Called to produce cargo when it arrives.
 
|-
 
|-
 
| produce_256_ticks
 
| produce_256_ticks
| Produce-block
+
| [[NML:Produce|Produce-block]]
 
| Called to produce cargo every 256 ticks.
 
| Called to produce cargo every 256 ticks.
 
|-
 
|-
Line 543: Line 479:
 
| CB_RESULT_IND_ALLOW or CB_RESULT_IND_DISALLOW
 
| CB_RESULT_IND_ALLOW or CB_RESULT_IND_DISALLOW
 
|
 
|
Called when the game needs to know if the industry type is available. It is limited to the type as a whole, so you can't access industry-specific variables. <code style="color:darkgreen">extra_callback_info2</code> contains the [[#Industry creation types|creation type]].
+
{{nml|0.2}} Only available in NML 0.2 or earlier. Called when the game needs to know if the industry type is available. It is limited to the type as a whole, so you can't access industry-specific variables. <code style="color:darkgreen">extra_callback_info2</code> contains the [[#Industry creation types|creation type]].
  +
|-
  +
| construction_probability
  +
| CB_RESULT_IND_NO_CONSTRUCTION, CB_RESULT_IND_PROBABILITY_FROM_PROPERTY or a relative probability 0..255
  +
|
  +
{{nml|0.3}}. Called when the game needs to know if the industry type is available. It is limited to the type as a whole, so you can't access industry-specific variables.
  +
* <code style="color:darkgreen">getbits(extra_callback_info2, 0, 8)</code>: The [[#Industry creation types|creation type]].
  +
If you return CB_RESULT_IND_NO_CONSTRUCTION or 0 the industry won't be build. If you return CB_RESULT_IND_PROBABILITY_FROM_PROPERTY it'll be build according to the relative probability as defined in the <code style="color:darkgreen">prob_random</code> or <code style="color:darkgreen">prob_in_game</code> properties, otherwise it'll use the value as returned as relative probability.
 
|-
 
|-
 
| location_check
 
| location_check
Line 549: Line 492:
 
See the [[#Location check results|table]] below.
 
See the [[#Location check results|table]] below.
 
|
 
|
  +
Called to check if a location is suitable.
Called to check if a location is suitable. <code style="color:darkgreen">extra_callback_info2</code> contains the [[#Industry creation types|creation type]]. Since the industry isn't built yet, industry variables aren't available.
 
  +
* <code style="color:darkgreen">getbits(extra_callback_info2, 0, 8)</code>: The [[#Industry creation types|creation type]].
  +
Since the industry isn't built yet, industry variables aren't available. If this callback is not implemented or fails, constructing the industry will be allowed. Construction might also be prevented via the <code style="color:darkgreen">tile_check</code> industry tile callback, though.
 
|-
 
|-
 
| monthly_prod_change
 
| monthly_prod_change
 
|
 
|
 
See [[#Production change callback results|below]]
 
See [[#Production change callback results|below]]
| Called each month to (possibly) change the industry production. <code style="color:darkgreen">extra_callback_info2</code> contains random bits.
+
| Called each month to (possibly) change the industry production.
  +
* <code style="color:darkgreen">extra_callback_info2</code>: 32 random bits.
 
|-
 
|-
 
| random_prod_change
 
| random_prod_change
Line 560: Line 506:
 
See [[#Production change callback results|below]]
 
See [[#Production change callback results|below]]
 
| Works exactly the same as <code style="color:darkgreen">monthly_prod_change</code>, except that it's only called when TTD selects this industry for a random production change.
 
| Works exactly the same as <code style="color:darkgreen">monthly_prod_change</code>, except that it's only called when TTD selects this industry for a random production change.
  +
|-
  +
| build_prod_change
  +
| Value in range 4-128
  +
| {{ottd|1.3|r24186}} Called when an industry is constructed. Return value is production level (default 16). Can also be used to initialise permanent storage when an industry is constructed.
 
|-
 
|-
 
| cargo_subtype_display
 
| cargo_subtype_display
  +
| String, CB_RESULT_NO_TEXT or CB_RESULT_IND_NO_TEXT_NO_AMOUNT
| String or 0xFF
 
  +
| This callback allows displaying some text after a cargo name. Returning
| This callback allows displaying some text after a cargo name. Returning 0xFF displays nothing. The lowest byte of <code style="color:darkgreen">extra_callback_info2</code> contains 0 .. 2 to get texts for the first .. third accepted cargo type, and 3 .. 4 for the first ... second produced cargo type. The second byte contains 0 when getting a string for the buy menu (no industry variables available!), 1 when for the industry window and 2 for the industry directory window.
 
  +
* CB_RESULT_NO_TEXT displays only waiting amount of cargo,
  +
* CB_RESULT_IND_NO_TEXT_NO_AMOUNT displays only the cargotype.
  +
  +
Note: To remove cargo waiting text, return <code style="color:darkgreen">0x3800 + string(STR_EMPTY)</code> where STR_EMPTY is an empty string in your lang file.
  +
  +
If IND_FLAG_LONG_CARGO_TYPE_LISTS is not set:
  +
* <code style="color:darkgreen">getbits(extra_callback_info2, 0, 8)</code>: 0 .. 2 to get texts for the first .. third accepted cargo type, and 3 .. 4 for the first ... second produced cargo type.
  +
* <code style="color:darkgreen">getbits(extra_callback_info2, 8, 8)</code>: 0 when getting a string for the buy menu (no industry variables available!), 1 when for the industry window and 2 for the industry directory window.
  +
  +
If IND_FLAG_LONG_CARGO_TYPE_LISTS is set:
  +
* <code style="color:darkgreen">getbits(extra_callback_info2, 0, 8)</code>: 0 for output cargos, 1 for input cargos.
  +
* <code style="color:darkgreen">getbits(extra_callback_info2, 8, 8)</code>: 0 when getting a string for the buy menu (no industry variables available!), 1 when for the industry window and 2 for the industry directory window.
  +
* <code style="color:darkgreen">getbits(extra_callback_info2, 16, 8)</code>: Cargo type.
  +
 
|-
 
|-
 
| extra_text_industry
 
| extra_text_industry
Line 575: Line 539:
 
| control_special
 
| control_special
 
| 0 or 1
 
| 0 or 1
| Called to control various effects from the <code style="color:darkgreen">spec_flags</code> property. Currently only works for the first two (plant fields / cut trees). Return 1 to execute the action or 0 to not do so. The relevant flag is given in <code style="color:darkgreen">extra_callback_info2</code>. The default (if the flag is enabled, of course) is to plant fields with 1/8th chance every 256 ticks, and to cut trees every 512 ticks. Random bits are supplied in <code style="color:darkgreen">extra_callback_info1</code>.
+
| Called to control various effects from the <code style="color:darkgreen">spec_flags</code> property. Currently only works for the first two (plant fields / cut trees). Return 1 to execute the action or 0 to not do so.
  +
* <code style="color:darkgreen">extra_callback_info1</code>: 32 random bits.
  +
* <code style="color:darkgreen">getbits(extra_callback_info2, 0, 8)</code>: Queried effect.
  +
The default (if the flag is enabled, of course) is to plant fields with 1/8th chance every 256 ticks, and to cut trees every 512 ticks.
 
|-
 
|-
 
| stop_accept_cargo
 
| stop_accept_cargo
 
| 0 or 1
 
| 0 or 1
| With this callback, you can temporarily refuse accepting a certain cargo, for example because the stockpile is full. Return 1 to accept or 0 to refuse. Make sure to synchronize this callback with the <code style="color:darkgreen">cargo_amount_accept</code> callback for industry tiles. <code style="color:darkgreen">extra_callback_info2</code> contains the cargo type to accept or not.
+
| With this callback, you can temporarily refuse accepting a certain cargo, for example because the stockpile is full. Return 1 to accept or 0 to refuse. Make sure to synchronize this callback with the <code style="color:darkgreen">cargo_amount_accept</code> callback for industry tiles.
  +
* <code style="color:darkgreen">getbits(extra_callback_info2, 0, 8)</code> The cargo type to accept or not.
 
|-
 
|-
 
| colour
 
| colour
Line 587: Line 555:
 
| cargo_input
 
| cargo_input
 
| Cargo type, or 0xFF
 
| Cargo type, or 0xFF
| Decide the input cargo types. Called repeatedly until 0xFF is returned, although currently not more than three times. Do not rely on this limitation, though. <code style="color:darkgreen">extra_callback_info1</code> starts at 0 and is incremented for every iteration. Return a cargo type (from the table) or 0xFF to stop.
+
| Decide the input cargo types, called when the industry is built. Called repeatedly until 0xFF is returned, although currently not more than three times. Do not rely on this limitation, though.
  +
* <code style="color:darkgreen">getbits(extra_callback_info1, 0, 8)</code>: Starts at 0 and is incremented for every iteration.
  +
Return a cargo type (from the table) or 0xFF to stop.
 
|-
 
|-
 
| cargo_output
 
| cargo_output
Line 594: Line 564:
 
|}
 
|}
   
  +
{{NML:LocationCheckResults}}
===Location check results===
 
 
{| class="t"
 
! return value
 
! meaning
 
|-
 
| String
 
| Industry can't be built, show the string as error message.
 
|-
 
| CB_RESULT_IND_ALLOW_LOCATION
 
| Industry can be built.
 
|-
 
| CB_RESULT_IND_DISALLOW_UNSUITABLE
 
| Industry can't be built, display the default "site unsuitable" error message.
 
|-
 
| CB_RESULT_IND_DISALLOW_ONLY_RAINFOREST
 
| Industry can't be built, display the "...can only be built in rainforest areas" error message.
 
|-
 
| CB_RESULT_IND_DISALLOW_ONLY_DESERT
 
| Industry can't be built, display the "...can only be built in desert areas" error message.
 
|-
 
| CB_RESULT_IND_DISALLOW_ONLY_ABOVE_SNOWLINE
 
| Industry can't be built, display the "...can only be built above the snow-line" error message.
 
|-
 
| CB_RESULT_IND_DISALLOW_ONLY_BELOW_SNOWLINE
 
| Industry can't be built, display the "...can only be built below the snow-line" error message.
 
|-
 
| CB_RESULT_IND_DISALLOW_NOT_ON_OPEN_SEA
 
| Industry can't be built, display the "...can't build on open sea" error message.
 
|-
 
| CB_RESULT_IND_DISALLOW_NOT_ON_CANAL
 
| Industry can't be built, display the "...can't build on canal" error message
 
|-
 
| CB_RESULT_IND_DISALLOW_NOT_ON_RIVER
 
| Industry can't be built, display the "...can't build on river" error message.
 
|}
 
   
 
===Production change callback results===
 
===Production change callback results===
   
{| class="t"
+
{| class="wikitable sortable"
 
! value
 
! value
 
! meaning
 
! meaning
Line 647: Line 582:
 
|-
 
|-
 
| CB_RESULT_IND_PROD_CLOSE
 
| CB_RESULT_IND_PROD_CLOSE
| Announce closoure and remove the industry next month.
+
| Announce closure and remove the industry next month.
 
|-
 
|-
 
| CB_RESULT_IND_PROD_RANDOM
 
| CB_RESULT_IND_PROD_RANDOM
Line 686: Line 621:
 
|}
 
|}
   
Setting bit 7 of the result disables the associated news message.<br /> Setting bit 8 replaces the news message with a custom message, read from register 0x100 bits 0 .. 15.
+
Setting bit 7 of the result disables the associated news message.<br /> Setting bit 8 replaces the news message with a custom message, read from register 0x100 bits 0 .. 15.<br />
  +
  +
You can set specific bits in the return value by using a <code>bitmask</code>:
  +
  +
switch(FEAT_INDUSTRIES, SELF, upscale_production, [
  +
STORE_TEMP(STR_NEWS_INDUSTRY_PRODUCTION_INCREASE_CUSTOM, 0x100)
  +
]) {
  +
return CB_RESULT_IND_PROD_DOUBLE | bitmask(8);
  +
}
   
 
===Industry creation types===
 
===Industry creation types===
   
{| class="t"
+
{| class="wikitable sortable"
 
! value
 
! value
 
! meaning
 
! meaning
Line 705: Line 648:
 
| IND_CREATION_PROSPECT
 
| IND_CREATION_PROSPECT
 
| Industry is prospected by the player
 
| Industry is prospected by the player
|}
 
 
==Industry tile callbacks==
 
 
{| class="t"
 
! callback
 
! return value
 
! comment
 
|-
 
| default
 
| Sprite layout
 
| Graphics for the industry tile
 
|-
 
| random_trigger
 
| N/A
 
|
 
See [[NML:Random switch|random switch]] for more information.
 
|-
 
| anim_next_frame
 
| Next animation frame or CB_RESULT_XXX
 
| Called for every animation frame, returns the next frame to display. Alternatively, return CB_RESULT_NEXT_FRAME or CB_RESULT_STOP_ANIMATION to show the next frame or stop animation, respectively. <code style="color:darkgreen">extra_callback_info1</code> contains random bits, if enabled in the <code style="color:darkgreen">special_flags</code> property. Returning a sound effect in the high byte will cause that sound effect to be played.
 
|-
 
| anim_control
 
| Next animation frame or CB_RESULT_XXX
 
|
 
Called whenever an animation trigger happens. Return the animation frame to show, or CB_RESULT_XXX with XXX = [CB_RESULT_START_ANIMATION | STOP_ANIMATION | DO_NOTHING] to respectively start the animation in its current frame, stop the animation or do nothing. <code style="color:darkgreen">extra_callback_info1</code> contains random bits, if enabled in the <code style="color:darkgreen">special_flags</code> property. Returning a sound effect in the high byte will cause that sound effect to be played. <code style="color:darkgreen">extra_callback_info2</code> contains the reason to trigger the animation, see the [[#Animation triggers|table]] below. Note that you need to enable the wanted triggers in the <code style="color:darkgreen">animation_triggers</code> property.
 
|-
 
| anim_speed
 
| 0 .. 16
 
| Decide the time an animation frame should last. Return value is interpreted as (num_ticks = 2^anim_speed), which each tick lasting 30 ms. Avoid using this callback if possible, since it has to be called each tick for every animated tile. This can be used to create animation frames that last between 30 ms and 33 minutes.
 
|-
 
| cargo_type_accept
 
| type1 + (type2 &lt;&lt; 5) + (type3 &lt;&lt; 10)
 
| Decide the cargo types that this tile accepts. If this callback is not implemented or fails, the values from <code style="color:darkgreen">accepted_cargos</code> are used instead. Bits 0..4: First cargo type. Bits 5..9: Second cargo type. Bits 10..14: Third cargo type.
 
|-
 
| cargo_amount_accept
 
| amt1 + (amt2 &lt;&lt; 4) + (amt3 &lt;&lt; 8)
 
| Acceptance for each cargo amount in 1/8th. If this callback is not implemented or fails, the values from <code style="color:darkgreen">accepted_cargos</code> are used instead. Cargo types are from the <code style="color:darkgreen">cargo_type_accept</code> callback, or the <code style="color:darkgreen">accepted_cargos</code> property if that callback failed. Bits 0..3: Acceptance of first cargo type. Bits 4..7: Acceptance of second cargo type. Bits 8..11: Acceptance of third cargo type.
 
|-
 
| tile_check
 
|
 
Same as for the [[#Location check results|location_check]] industry callback
 
|
 
Called before constructing the industry, so nothing exists on the map yet. Since the industry isn't built yet, so you can't access industry variables. From the tile variables, relative x/y/position, town zone are available, as well as the class, height, slope, terrain type and water status of nearby tiles. <code style="color:darkgreen">extra_callback_info2</code> contains the industry layout number in the lowest (first) byte and the [[#Industry creation types|creation type]] in the second byte.
 
|-
 
| foundations
 
| CB_RESULT[_NO]_FOUNDATIONS
 
| Return CB_RESULT_FOUNDATIONS to draw standard foundations (default) or CB_RESULT_NO_FOUNDATIONS to not draw them.
 
|-
 
| autoslope
 
| CB_RESULT[_NO]_AUTOSLOPE
 
| Return CB_RESULT_AUTOSLOPE to allow autoslope (altering the ground below a tile) or CB_RESULT_NO_AUTOSLOPE to disallow it.
 
|}
 
 
===Animation triggers===
 
 
{| class="t"
 
! Trigger
 
! Meaning
 
|-
 
| ANIM_TRIGGER_INDTILE_CONSTRUCTION_STATE
 
| the construction state changes
 
|-
 
| ANIM_TRIGGER_INDTILE_TILE_LOOP
 
| the tile is processed in the periodic processing loop
 
|-
 
| ANIM_TRIGGER_INDTILE_INDUSTRY_LOOP
 
| the industry of the tile is processed in the periodic processing loop (synchronized for all tiles)
 
|-
 
| ANIM_TRIGGER_INDTILE_RECEIVED_CARGO
 
| the industry of the tile receives input cargo from a station (synchronized for all tiles)
 
|-
 
| ANIM_TRIGGER_INDTILE_DISTRIBUTES_CARGO
 
| the industry distributes its output cargo to one of the stations nearby (synchronized for all tiles)
 
 
|}
 
|}

Latest revision as of 08:12, 26 October 2024

Props, Vars and CBs

This page contains information on industry properties, variables and callbacks. Industry tiles are closely related.

Industry ID allocation

Industry IDs are local to the NewGRF, you are free to choose any ID in the 0..127-range. You should start your item definition with the 'substitute'-property, which allocates a new industry. The value of this property should be the ID of a default industry, which will be used instead of your item if it is not available for whatever reason (for example, missing NewGRF).

Furthermore, you can set the 'override'-property, which will cause the existing industry to be replaced with your item. You should use this if you are for example defining a coal mine which changes production more dynamically. If your type is not a direct replacement of an existing item, don't set this property.

Industry properties

Industry properties. Default industry type numbers can be found at default industries.

property value range comment
substitute industry type Number of the original industry type that replaces this one, should it not be available for some reason (e.g. missing NewGRF). This property must be set first, before any other properties or graphics. All properties of the old type are copied to your new industry.
override industry type Number of the original industry type overridden. This will cause other grfs / industries to consider your industry type the same as the old type. Only set this property if your type is (more or less) the same as the old type.
layouts Array of tilelayouts

See Tilelayout syntax.

life_type One of IND_LIFE_TYPE_XXX, XXX = BLACK_HOLE | EXTRACTIVE | ORGANIC | PROCESSING The generic type of industry. This determines the production changes that occur by default (when not using the callback). Examples are respectively power plants, coal mines, forests en steel mills.
closure_msg string

Message displayed when the industry announces closure. Use a custom string or one of the default TTD strings.

prod_increase_msg string

Message displayed when industry increases production. Use a custom string or one of the default TTD strings.

prod_decrease_msg string

Message displayed when industry decreases production. Use a custom string or one of the default TTD strings.

fund_cost_multiplier 0..255 Fund cost multiplier. Note that in OpenTTD the unmodified base cost is 8x higher for building (not prospecting) raw (=extractive / organic, see life_type) industries.
cargo_types array of accept_cargo(input, outputs...) and produce_cargo(output, level) expressions NML 0.5 Supported by OpenTTD 1.91.9 Types of cargo accepted and produced by the industry, and their production levels and production multipliers. See cargo types array below.
prod_cargo_types array of up to 2 ints NML 0.4 Types of cargo produced. Use the cargotype(<label>) built-in function to specify a label from the cargotable. NML 0.5 Removed, use cargo_types instead.
accept_cargo_types array of up to 3 ints NML 0.4 Types of cargo accepted. Use the cargotype(<label>) built-in function to specify a label from the cargotable. NML 0.5 Removed, use cargo_types instead.
prod_multiplier array of up to 2 ints (0..255) NML 0.4 Amount of each output cargo to produce every 256 ticks (8 or 9 times a month) NML 0.5 Removed, use cargo_types instead.
min_cargo_distr 0..255 Minimal amount of cargo before transporting to stations.
random_sound_effects array of ints Sound effect numbers that are played some times.
conflicting_ind_types array of up to 3x industry_type(IND_TYPE_OLD | IND_TYPE_NEW, id)

Three industry types that should not be nearby. Use the builtin function industry_type(..) to define either an old industry (using the global ID) or a new industry from your grf (using the grf-local ID).

prob_random 0..255 (up to NML v5796-418, use prob_map_gen otherwise) Probability of occurring while generating initial industries. If the random game probability value is nonzero and IND_FLAG_DO_NOT_FORCE_INSTANCE_AT_MAP_GENERATION is not set, at least one instance of this type is guaranteed to appear on the map.
prob_map_gen 0..255 (NML v5796-418 or newer) Probability of occurring while generating initial industries. If the random game probability value is nonzero and IND_FLAG_DO_NOT_FORCE_INSTANCE_AT_MAP_GENERATION is not set, at least one instance of this type is guaranteed to appear on the map.
prob_in_game 0..255 Probability of occurring while creating industries during the game.
map_colour 0..255

Colour index from the DOS palette to use on the minimap for this industry.

spec_flags bitmask(flags)

for flag values see Industry special flags

new_ind_msg string Message displayed when industry gets built during game play.
input_multiplier_1 array of up to 2 floats (0..255) NML 0.4 Output cargo multiplication factors for getting a unit of the first accepted cargo. NML 0.5 Removed, use cargo_types instead.
input_multiplier_2 array of up to 2 floats (0..255) NML 0.4 Output cargo multiplication factors for getting a unit of the second accepted cargo. NML 0.5 Removed, use cargo_types instead.
input_multiplier_3 array of up to 2 floats (0..255) NML 0.4 Output cargo multiplication factors for getting a unit of the third accepted cargo. NML 0.5 Removed, use cargo_types instead.
name string

Name of the industry, use a custom string or one of the default TTD strings.

prospect_chance 0 .. 1 (float) Chance of successful prospecting.
callback_flags bitmask(flags)

Do not set this, unless you use old-style callbacks.

remove_cost_multiplier int Cost multiplier for removing the industry (currently only possible with magic bulldozer).
nearby_station_name string Default name for a nearby station.

To follow the "<Town Name> <Industry Name>" convention, the string should include a "{STRING}" at the position the town name shall be inserted. For example:

STR_HARBOR_NEARBY_NAME   :{STRING} water side

Cargo types array

The cargo_types property takes an array of accept_cargo and produce_cargo expressions. This array is used to define which cargo types the industry accepts, which it produces, and how much cargo is produced on production ticks and on delivery. All cargo types the industry handles must be mentioned in its cargo_types property even when they are handled by production callbacks.

The following is an example of a cargo_types property:

cargo_types: [
  produce_cargo("GOOD", 4),
  accept_cargo("PASS"),
  produce_cargo("PASS", 0),
  accept_cargo("IORE", produce_cargo("STEL", 1), produce_cargo("SLAG", 0.25))
]

The above example has four items in its cargo_types array, two produce_cargo expressions and two accept_cargo expressions.

  1. produce_cargo("GOOD", 4) specifies the industry produces GOOD at a rate of 4 every production tick (256 game ticks), this production rate is scaled by the industry's production level.
  2. accept_cargo("PASS") specifies the industry accepts PASS as a "black hole", that is no cargo is produced when PASS is delivered. If you have a production callback that consumes a cargo you will also need to specify that cargo in this way.
  3. produce_cargo("PASS", 0) specifies the industry produces PASS but not on the production ticks as usual. Specifying a production rate of zero is only useful for cargo types you produce via a production callback.
  4. accept_cargo("IORE", produce_cargo(...), ...) specifies the industry produces the listed cargo types every time IORE is delivered. In the example above, delivering one IORE will result in one STEL produced and no SLAG produced (because 1*0.25 is zero after rounding down), and delivering 4 IORE will result in 4 STEL and 1 SLAG produced.

At most 16 different cargo labels may appear in accept_cargo and at most 16 different cargo labels in produce_cargo, for a single industry. The same cargo label can be used in as many accept_cargo or produce_cargo as necessary.

More complex production rules can be set up via the production callbacks, see callbacks below.

Industry special flags

flag meaning
IND_FLAG_PLANT_FIELDS_PERIODICALLY The industry periodically plants fields around itself (temperate and arctic farms)
IND_FLAG_CUT_TREES The industry cuts trees around itself and produces its first output cargo from them (lumber mill)
IND_FLAG_BUILT_ON_WATER The industry is built on water (oil rig)
IND_FLAG_ONLY_IN_LARGE_TOWNS The industry can only be built in towns (i.e. it has to replace houses) with population larger than 1200 (temperate bank)
IND_FLAG_ONLY_IN_TOWNS The industry can only be built in towns (i.e. it has to replace houses) (arctic and tropic banks, water tower)
IND_FLAG_BUILT_NEAR_TOWN The industry is always built near towns (i.e. near town sign; additionally the industry is allowed to replace houses) (toy shop)
IND_FLAG_PLANT_FIELDS_WHEN_BUILT Fields are planted around the industry when it's built (all farms)
IND_FLAG_NO_PRODUCTION_INCREASE The industry cannot increase its production on the temperate climate (oil wells)
IND_FLAG_BUILT_ONLY_BEFORE_1950 The industry is built only before 1950 (oil wells)
IND_FLAG_BUILT_ONLY_AFTER_1960 The industry is built only after 1960 (oil rig)
IND_FLAG_AI_CREATES_AIR_AND_SHIP_ROUTES AI players will attempt to establish air and ship routes going to this industry (oil rig)
IND_FLAG_MILITARY_AIRPLANE_CAN_EXPLODE The industry can be exploded by a military airplane (oil refinery)
IND_FLAG_MILITARY_HELICOPTER_CAN_EXPLODE The industry can be exploded by a military helicopter (factory)
IND_FLAG_CAN_CAUSE_SUBSIDENCE The industry can cause a subsidence (coal mine)
IND_FLAG_AUTOMATIC_PRODUCTION_MULTIPLIER Automatic production multiplier handing (No industry has this bit set by default.).
IND_FLAG_RANDOM_BITS_IN_PRODUCTION_CALLBACK The production callback needs random bits in var. 10 (No industry has this bit set by default.)
IND_FLAG_DO_NOT_FORCE_INSTANCE_AT_MAP_GENERATION Do not force one instance of this type to appear during initial map generation (No industry has this bit set by default.)
IND_FLAG_ALLOW_CLOSING_LAST_INSTANCE Allow closing down the last instance of this type (No industry has this bit set by default.)
IND_FLAG_LONG_CARGO_TYPE_LISTS New format for callbacks callbacks cargo_subtype_display, cargo_input, cargo_output to support more input/output cargos. See the callbacks for details.
IND_FLAG_DO_NOT_CLAMP_PASSENGER_PRODUCTION NML 0.7 Supported by OpenTTD 1.111.11 By default OpenTTD's smooth economy clamps the production of passenger (like for oil rigs). This flag disables the clamping.

Common variables

The following variables are available to both industries and industry tiles. All of them require an x, y offset. For industries, this offset is unsigned and relative to the northernmost tile. For industry tiles, it is signed and relative to the current tile.

name value range comment
nearby_tile_slope SLOPE_XXX

See tile slopes for an overview of possible values

nearby_tile_is_water 1 if the tile is water, 0 otherwise
nearby_tile_terrain_type TILETYPE_XX TILETYPE_NORMAL, TILETYPE_DESERT, TILETYPE_RAIN_FOREST, TILETYPE_SNOW
nearby_tile_water_class WATER_CLASS_XXX XXX = [NONE | SEA | CANAL | RIVER] Note that tiles for which nearby_tile_is_water is 0 may still have a water class, e.g. industry tiles with water beneath them.
nearby_tile_height 0..120 The height of the lowest corner of the given tile.
nearby_tile_class

Tile class

nearby_tile_animation_frame 0..255 Animation frame of the given tile
nearby_tile_industrytile_id 0x00aa, 0xFFbb, 0xFFFE or 0xFFFF 0x00aa: The tile is an industry tile defined in this GRF with tile id aa.
0xFFbb: The tile is an original industry tile with id bb.
0xFFFE: The tile is an industry tile defined in another GRF.
0xFFFF: The tile is not an industry tile or it belongs to another industry.

Industry variables

name value range comment
production_level 0, or 4 .. 128 Current production level of the industry. Usually in range 4 .. 128, default starting level is 16. A level of 0 indicates imminent closure.
waiting_cargo_1 0..65535 If any of the production callbacks is enabled, this variable will contain the amount of the first cargo type awaiting to be processed. NML 0.5 Removed. Use incoming_cargo_waiting instead.
waiting_cargo_2 0..65535 If any of the production callbacks is enabled, this variable will contain the amount of the second cargo type awaiting to be processed. NML 0.5 Removed. Use incoming_cargo_waiting instead.
waiting_cargo_3 0..65535 If any of the production callbacks is enabled, this variable will contain the amount of the third cargo type awaiting to be processed. NML 0.5 Removed. Use incoming_cargo_waiting instead.
produced_cargo_waiting_1 0..65535 The amount of produced 'output cargo type 1' that this waiting to be transported. NML 0.5 Removed. Use produced_cargo_waiting instead.
produced_cargo_waiting_2 0..65535 The amount of produced 'output cargo type 2' that this waiting to be transported. NML 0.5 Removed. Use produced_cargo_waiting instead.
produced_this_month_1 0..65535 The amount of 'output cargo type 1' that was produced this month. NML 0.5 Removed. Use this_month_production instead.
produced_this_month_2 0..65535 The amount of 'output cargo type 2' that was produced this month. NML 0.5 Removed. Use this_month_production instead.
produced_last_month_1 0..65535 The amount of 'output cargo type 1' that was produced last month. NML 0.5 Removed. Use last_month_production instead.
produced_last_month_2 0..65535 The amount of 'output cargo type 2' that was produced last month. NML 0.5 Removed. Use last_month_production instead.
transported_this_month_1 0..65535 The amount of 'output cargo type 1' that was transported this month. NML 0.5 Removed. Use this_month_transported instead.
transported_this_month_2 0..65535 The amount of 'output cargo type 2' that was transported this month. NML 0.5 Removed. Use this_month_transported instead.
transported_last_month_1 0..65535 The amount of 'output cargo type 1' that was produced last month. NML 0.5 Removed. Use last_month_transported instead.
transported_last_month_2 0..65535 The amount of 'output cargo type 2' that was produced last month. NML 0.5 Removed. Use last_month_transported instead.
transported_last_month_pct_1 0..100 Percentage of produced 'output cargo type 1' that was transported last month. NML 0.5 Removed. Use transported_last_month_pct instead.
transported_last_month_pct_2 0..100 Percentage of produced 'output cargo type 2' that was transported last month. NML 0.5 Removed. Use transported_last_month_pct instead.
production_rate_1 0..255 NML 0.3 Amount of 'output cargo type 1' that is produced every 256 ticks. Initial value from the prod_multiplier-property, but it will change accordingly when the production level changes. NML 0.5 Removed. Use production_rate instead.
production_rate_2 0..255 NML 0.3 Amount of 'output cargo type 2' that is produced every 256 ticks. Initial value from the prod_multiplier-property, but it will change accordingly when the production level changes. NML 0.5 Removed. Use production_rate instead.
water_distance Distance to the tile If the industry is built on water, this variable gives the distance of the closest dry land tile, otherwise it gives the distance of the closest water tile.
layout_num 1..255 Number of the layout being used by the industry.
founder 0..16 Company number of the industry founder. It will be FOUNDER_GAME (=16) if the industry was generated randomly. TTDPatch only supports up to 8 companies (0..7).
founder_type PLAYERTYPE_XX PLAYERTYPE_HUMAN, PLAYERTYPE_AI, PLAYERTYPE_HUMAN_IN_AI (human managing AI company) or PLAYERTYPE_AI_IN_HUMAN (AI managing human company). OpenTTD only uses PLAYERTYPE_HUMAN and PLAYERTYPE_AI. If you cheat yourself to be part of an AI company OpenTTD will still report PLAYERTYPE_AI for the company with yourself and the AI and it'll report PLAYERTYPE_HUMAN for the now uncontrolled company.
founder_colour1 COLOUR_XXX

Index of founding company's first colour. 0 if not founded by a company. Refer to the table here for possible values.

founder_colour2 COLOUR_XXX

Index of founding company's second colour. It's the same as company_colour1, if no second company colour is chosen. 0 if not founded by a company. Refer to the table here for possible values.

colour COLOUR_XXX

Random colour for this industry. Refer to the table here for possible values.

build_date 0..1826212865 Date of the industry foundation in days since year 0.
build_type BUILDTYPE_XX BUILDTYPE_UNKNOWN (if created in an old version or with newindustries disabled), BUILDTYPE_GAMEPLAY (if founded or created by the in-game random industry generator), BUILDTYPE_GENERATION (if created during random map generation) or BUILDTYPE_EDITOR (if created with the scenario editor).
counter 0..65535 Decremented every tick, used to time primary industry production in TTD.
last_accept_date date(year, month, day) Date when cargo was accepted for the last time. Not valid before 1920 and after 2090.
random_bits 0 ... 65535 Random data that can be used to randomize certain descisions. (see Random switch) (NML r1666)
gs_disallows_prod_decrease [0 | 1] NML 0.7Supported by OpenTTD 1.111.11 GameScript can optionally set a property that to indicate that production should not decrease at this industry. This will be automatically applied for organic and extractive industries, *if* the NewGRF industry production callback is *not* used *and* smooth economy is enabled. In other cases, NewGRF industries can provide behaviour as requested by the GameScript by reading this variable during production callbacks.
gs_disallows_prod_increase [0 | 1] NML 0.7Supported by OpenTTD 1.111.11 GameScript can optionally set a property that to indicate that production should not increase at this industry. This will be automatically applied for organic and extractive industries, *if* the NewGRF industry production callback is *not* used *and* smooth economy is enabled. In other cases, NewGRF industries can provide behaviour as requested by the GameScript by reading this variable during production callbacks.
gs_disallows_closure [0 | 1] NML 0.7Supported by OpenTTD 1.111.11 GameScript can optionally set a property that to indicate that this industry should not close. NewGRF industries can use this variable to read the property set by GameScript and provide the appropriate closure behaviour. Any closure already scheduled will still take place.


Variables that require some parameters.

name arguments comment
industry_count industry_type, grfid = -1

The value of this variable is the number of industries of a given type that are currently on the map. industry_type is either the ID of an industry. GRFid is the grf in which the industry was defined. The default value is -1, which means current newgrf. A grfid of 0 lets you check the number of default industries of a given type. Use the builtin function str2number() to convert a grfid to its numeric representation.
Warning: using this variable trashes the contents of temporary storage register 0x100

industry_distance industry_type, grfid = -1 The value of this variable is the manhattan distance the closest instance of the given industry or 0xFFFF if not applicable. See industry_count for a description of the parameters.
Warning: using this variable trashes the contents of temporary storage register 0x100.
industry_layout_count / industry_layout_distance industry_type, layout, grfid = -1. See industry_count / industry_distance for description of industry_type, grfid and return value. The results are filtered to industries that have the given layout number.
Warning: using this variable trashes the contents of temporary storage registers 0x100 and 0x101.
industry_town_count industry_type, grfid = -1. See industry_count / industry_distance for description of industry_type, grfid and return value. The results are filtered to industries that have the same town than the current industry.
Warning: using this variable trashes the contents of temporary storage registers 0x100 and 0x101.
town_manhattan_dist x, y Parameters indicate a signed offset relative to the northern tile. Returns the Manhattan distance (dx + dy) from the selected tile to the closest town
town_euclidean_dist x, y Parameters indicate a signed offset relative to the northern tile. Returns the squared Eucleidean distance (dx^2 + dy^2) from the selected tile to the closest town.
town_zone x, y

Parameters indicate a signed offset relative to the northern tile. Returns the town zone that the selected tile is in.

nearby_tile_random_bits x, y Parameters indicate an unsigned offset relative to the northern tile. Returns the random bits of the selected industry tile, or 0 if it is not an industry tile that's part of this industry.
incoming_cargo_waiting cargo label from the cargotable NML 0.5 If any of the production callbacks is enabled, this variable will contain the amount of the cargo type waiting to be processed. Returns 0..65535. Example: incoming_cargo_waiting("FOOD").
produced_cargo_waiting cargo label from the cargotable NML 0.5 For the given cargo label, the amount of produced cargo that this waiting to be transported. Returns 0..65535. Example: produced_cargo_waiting("GOOD").
this_month_production cargo label from the cargotable NML 0.5 For the given cargo label, amount of cargo that was produced this month. Returns 0..65535. Example: this_month_production("COAL").
last_month_production cargo label from the cargotable NML 0.5 For the given cargo label, amount of cargo that was produced last month. Returns 0..65535. Example: last_month_production("WOOD").
this_month_transported cargo label from the cargotable NML 0.5 For the given cargo label, amount of produced cargo that was transported this month. Returns 0..65535. Example: this_month_transported("IORE").
last_month_transported cargo label from the cargotable NML 0.5 For the given cargo label, amount of produced cargo that was transported last month. Returns 0..65535. Example: last_month_transported("PAPR").
transported_last_month_pct cargo label from the cargotable NML 0.5 For the given cargo label, percentage of produced cargo that was transported last month. Returns 0..100. Example: transported_last_month_pct("BATT").
production_rate cargo label from the cargotable NML 0.5 For the given cargo label, amount of output cargo that is produced every 256 ticks. Initial value from the cargo_types property, but it will change accordingly when the production level changes. Returns 0..255. Example: production_rate("SUGR").

Industry callbacks

callback return value comment
default varies Any unhandled callbacks. Generally this doesn't need to be used, except for old-style callbacks.
produce_cargo_arrival Produce-block Called to produce cargo when it arrives.
produce_256_ticks Produce-block Called to produce cargo every 256 ticks.
availability CB_RESULT_IND_ALLOW or CB_RESULT_IND_DISALLOW

NML 0.2 Only available in NML 0.2 or earlier. Called when the game needs to know if the industry type is available. It is limited to the type as a whole, so you can't access industry-specific variables. extra_callback_info2 contains the creation type.

construction_probability CB_RESULT_IND_NO_CONSTRUCTION, CB_RESULT_IND_PROBABILITY_FROM_PROPERTY or a relative probability 0..255

NML 0.3. Called when the game needs to know if the industry type is available. It is limited to the type as a whole, so you can't access industry-specific variables.

If you return CB_RESULT_IND_NO_CONSTRUCTION or 0 the industry won't be build. If you return CB_RESULT_IND_PROBABILITY_FROM_PROPERTY it'll be build according to the relative probability as defined in the prob_random or prob_in_game properties, otherwise it'll use the value as returned as relative probability.

location_check

See the table below.

Called to check if a location is suitable.

Since the industry isn't built yet, industry variables aren't available. If this callback is not implemented or fails, constructing the industry will be allowed. Construction might also be prevented via the tile_check industry tile callback, though.

monthly_prod_change

See below

Called each month to (possibly) change the industry production.
  • extra_callback_info2: 32 random bits.
random_prod_change

See below

Works exactly the same as monthly_prod_change, except that it's only called when TTD selects this industry for a random production change.
build_prod_change Value in range 4-128 Supported by OpenTTD 1.3 (r24186)1.3 Called when an industry is constructed. Return value is production level (default 16). Can also be used to initialise permanent storage when an industry is constructed.
cargo_subtype_display String, CB_RESULT_NO_TEXT or CB_RESULT_IND_NO_TEXT_NO_AMOUNT This callback allows displaying some text after a cargo name. Returning
  • CB_RESULT_NO_TEXT displays only waiting amount of cargo,
  • CB_RESULT_IND_NO_TEXT_NO_AMOUNT displays only the cargotype.

Note: To remove cargo waiting text, return 0x3800 + string(STR_EMPTY) where STR_EMPTY is an empty string in your lang file.

If IND_FLAG_LONG_CARGO_TYPE_LISTS is not set:

  • getbits(extra_callback_info2, 0, 8): 0 .. 2 to get texts for the first .. third accepted cargo type, and 3 .. 4 for the first ... second produced cargo type.
  • getbits(extra_callback_info2, 8, 8): 0 when getting a string for the buy menu (no industry variables available!), 1 when for the industry window and 2 for the industry directory window.

If IND_FLAG_LONG_CARGO_TYPE_LISTS is set:

  • getbits(extra_callback_info2, 0, 8): 0 for output cargos, 1 for input cargos.
  • getbits(extra_callback_info2, 8, 8): 0 when getting a string for the buy menu (no industry variables available!), 1 when for the industry window and 2 for the industry directory window.
  • getbits(extra_callback_info2, 16, 8): Cargo type.
extra_text_industry String Show extra text in the industry window.
extra_text_fund String Show extra text in the fund window. Since the industry isn't built, no industry variables are available.
control_special 0 or 1 Called to control various effects from the spec_flags property. Currently only works for the first two (plant fields / cut trees). Return 1 to execute the action or 0 to not do so.
  • extra_callback_info1: 32 random bits.
  • getbits(extra_callback_info2, 0, 8): Queried effect.

The default (if the flag is enabled, of course) is to plant fields with 1/8th chance every 256 ticks, and to cut trees every 512 ticks.

stop_accept_cargo 0 or 1 With this callback, you can temporarily refuse accepting a certain cargo, for example because the stockpile is full. Return 1 to accept or 0 to refuse. Make sure to synchronize this callback with the cargo_amount_accept callback for industry tiles.
  • getbits(extra_callback_info2, 0, 8) The cargo type to accept or not.
colour COLOUR_XXX Called after constructing the industry. The colour variable is set to a random value at this point, you can use this callback to change this.
cargo_input Cargo type, or 0xFF Decide the input cargo types, called when the industry is built. Called repeatedly until 0xFF is returned, although currently not more than three times. Do not rely on this limitation, though.
  • getbits(extra_callback_info1, 0, 8): Starts at 0 and is incremented for every iteration.

Return a cargo type (from the table) or 0xFF to stop.

cargo_output Cargo type, or 0xFF Same as cargo_input above, except that it is applied to the output cargo types and currently not called more than twice.

Location check results

The following values can be used as return values for the location_check callback for industries and the tile_check callback for industry tiles and objects.

return value meaning
string(..) Item can't be built, show the string as error message.
CB_RESULT_LOCATION_ALLOW Item can be built.
CB_RESULT_LOCATION_DISALLOW Item can't be built, display the default error message. This is "site unsuitable" for industries and industry tiles, and "land sloped in wrong direction" for objects.
CB_RESULT_LOCATION_DISALLOW_ONLY_RAINFOREST Item can't be built, display the "...can only be built in rainforest areas" error message.
CB_RESULT_LOCATION_DISALLOW_ONLY_DESERT Item can't be built, display the "...can only be built in desert areas" error message.
CB_RESULT_LOCATION_DISALLOW_ONLY_ABOVE_SNOWLINE Item can't be built, display the "...can only be built above the snow-line" error message.
CB_RESULT_LOCATION_DISALLOW_ONLY_BELOW_SNOWLINE Item can't be built, display the "...can only be built below the snow-line" error message.
CB_RESULT_LOCATION_DISALLOW_NOT_ON_OPEN_SEA Item can't be built, display the "...can't build on open sea" error message.
CB_RESULT_LOCATION_DISALLOW_NOT_ON_CANAL Item can't be built, display the "...can't build on canal" error message
CB_RESULT_LOCATION_DISALLOW_NOT_ON_RIVER Item can't be built, display the "...can't build on river" error message.

Production change callback results

value meaning
CB_RESULT_IND_PROD_NO_CHANGE Do not change industry production
CB_RESULT_IND_PROD_HALF Half industry production. If production goes below a quarter of default, the industry closes.
CB_RESULT_IND_PROD_DOUBLE Double production if it's not 8x default yet.
CB_RESULT_IND_PROD_CLOSE Announce closure and remove the industry next month.
CB_RESULT_IND_PROD_RANDOM Do a random production change, as if the industry is a primary one.
CB_RESULT_IND_PROD_DIVIDE_BY_4 Divide production by 4
CB_RESULT_IND_PROD_DIVIDE_BY_8 Divide production by 8
CB_RESULT_IND_PROD_DIVIDE_BY_16 Divide production by 16
CB_RESULT_IND_PROD_DIVIDE_BY_32 Divide production by 32
CB_RESULT_IND_PROD_MULTIPLY_BY_4 Multiply production by 4
CB_RESULT_IND_PROD_MULTIPLY_BY_8 Multiply production by 8
CB_RESULT_IND_PROD_MULTIPLY_BY_16 Multiply production by 16
CB_RESULT_IND_PROD_MULTIPLY_BY_32 Multiply production by 32
CB_RESULT_IND_PROD_DECREMENT_BY_1 Decrement production by 1
CB_RESULT_IND_PROD_INCREMENT_BY_1 Increment production by 1
CB_RESULT_IND_PROD_SET_BY_0x100 Set the production level to the value in bits 16 .. 23 of register 0x100.

Setting bit 7 of the result disables the associated news message.
Setting bit 8 replaces the news message with a custom message, read from register 0x100 bits 0 .. 15.

You can set specific bits in the return value by using a bitmask:

switch(FEAT_INDUSTRIES, SELF, upscale_production, [
    STORE_TEMP(STR_NEWS_INDUSTRY_PRODUCTION_INCREASE_CUSTOM, 0x100)
]) {
    return CB_RESULT_IND_PROD_DOUBLE | bitmask(8);
}

Industry creation types

value meaning
IND_CREATION_GENERATION Industry is created during map generation, or when building 'many random industries' in the scenario editor.
IND_CREATION_RANDOM Industry is randomly generated during gameplay
IND_CREATION_FUND Industry is funded by the player (in game or scenario editor)
IND_CREATION_PROSPECT Industry is prospected by the player