Difference between revisions of "Callback: Decide input and output cargo types"

From GRFSpecs
Jump to navigationJump to search
(use proper version template)
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
== Decide input and output cargo types (14B,14C) ==
 
== Decide input and output cargo types (14B,14C) ==
  +
{{ottdp|0.6|2.6|ottdrev=r11177|ttdprev=r1718}}
   
  +
These callbacks are called when the industry is built, and allow customizing the input and output cargo types dynamically.
These callbacks are called when the industry is built, and allow customizing the input and output cargo types dynamically. Both callbacks are called repeatedly, with the lowest byte of variable 10 starting from zero and increasing after every call; you should return a cargo type each time, or FFh to terminate the list. (A failed callback terminates the list, too.) The same limitations apply as for callback 14A: industry tiles aren't yet placed, and some industry variables contain junk. You can use random action2s, however. The interpretation of the returned value depends on two factors: the current GRF version number and the presence of a cargo translation table:
 
  +
However, you are only allowed to reduce the number of accepted/produced cargos. Industry properties 25 and 26 should always be a superset of the returned cargotypes.
  +
 
Both callbacks are called repeatedly, with the lowest byte of variable 10 starting from zero and increasing after every call; you should return a cargo type each time, or FFh to terminate the list. (A failed callback terminates the list, too.) The same limitations apply as for callback 14A: industry tiles aren't yet placed, and some industry variables contain junk. You can use random action2s, however. The interpretation of the returned value depends on two factors: the current GRF version number and the presence of a cargo translation table:
   
 
{| |-
 
{| |-
Line 13: Line 17:
 
|}
 
|}
   
  +
The callback results replace the content of properties 25 and 26.
Although currently [[Callbacks#Decide input and output cargo types (14B,14C) |callback 14B]] is called no more than three times, and [[Callbacks#Decide input and output cargo types (14B,14C) |callback 14C]] no more than twice, this may change between versions/implementations, to allow more input/output types. To be safe, you should return FFh as the last element even when you use all three input types or both output types.
 
  +
If you use these callbacks, it is recommended to not use industry properties 12..13, 1C..1E and 27..28, which depend on the order of cargotypes, but instead use production callback version 2.
  +
  +
{{ottdp|1.9|no|ottdrev=e66cec8f}} If industry property 1A flag 18 is clear, these callbacks are called at most for 3 input and 2 output cargos.
  +
If flag 18 is set, this compatibility restriction is removed and the callbacks are called more often.
   
  +
In both cases return FFh as the last element to terminate the lists.
These callbacks are available from {{ttdp|2.6}} TTDPatch 2.6 r1718 and above
 
   
 
[[Category:Callbacks]]
 
[[Category:Callbacks]]

Latest revision as of 12:09, 4 November 2018

Decide input and output cargo types (14B,14C)

Supported by OpenTTD 0.6 (r11177)0.6 Supported by TTDPatch 2.6 (r1718)2.6

These callbacks are called when the industry is built, and allow customizing the input and output cargo types dynamically. However, you are only allowed to reduce the number of accepted/produced cargos. Industry properties 25 and 26 should always be a superset of the returned cargotypes.

Both callbacks are called repeatedly, with the lowest byte of variable 10 starting from zero and increasing after every call; you should return a cargo type each time, or FFh to terminate the list. (A failed callback terminates the list, too.) The same limitations apply as for callback 14A: industry tiles aren't yet placed, and some industry variables contain junk. You can use random action2s, however. The interpretation of the returned value depends on two factors: the current GRF version number and the presence of a cargo translation table:

GRF version Has cargo translation table Interpretation
6 or below Climate-dependent cargo slot number
7 or above No Cargo bit
7 or above Yes Index in the translation table

The callback results replace the content of properties 25 and 26. If you use these callbacks, it is recommended to not use industry properties 12..13, 1C..1E and 27..28, which depend on the order of cargotypes, but instead use production callback version 2.

Supported by OpenTTD 1.9 (e66cec8f)1.9 Not supported by TTDPatch If industry property 1A flag 18 is clear, these callbacks are called at most for 3 input and 2 output cargos. If flag 18 is set, this compatibility restriction is removed and the callbacks are called more often.

In both cases return FFh as the last element to terminate the lists.