Difference between revisions of "Callback: Custom shape check"

From GRFSpecs
Jump to navigationJump to search
(→‎Custom shape check (2F): GRF version tag)
(use new grf templates)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
== Custom shape check (2F) ==
 
== Custom shape check (2F) ==
   
This callback is called when TTD checks if a given tile is suitable for the industry tile. Since the tile isn't built yet, you can
+
This callback is called when TTD checks if a given tile is suitable for the industry tile. The callback should return zero if the tile isn't suitable, or any other value if it is suitable.
use variables 41, 42, 43, and 60 only, and you can't access any industry variables, either. Since OpenTTD r19744 however, you can
 
access the random bits of the industry (it would get after construction) via industry variable 5F resp. [[RandomAction2]] type 83.
 
Var. 60 is the most useful here, since you can check the slope of the tile, or even the nearby tiles. This callback is the only way
 
to allow your tile to be built on steep slopes. The callback should return zero if the tile isn't suitable, or any other value if it is suitable.
 
   
  +
{{grfFrom|7}} The meaning of the returned value is different in GRF version 7; it works the same way as [[Callbacks#Industry location permissibility (28) |callback 28]]. {{ottdp| |2.6|ttdprev=r1755}} Also, since TTDPatch r1755, you can use the text reference stack for your error messages, similarly to [[#Show_additional_text_in_industry_window_.283A.29 |callback 3A]]. The only difference is that only 4 registers are copied instead of 6.
Since TTDPatch 2.6 r1728, the lowest byte of variable 18 contains the layout number selected for the industry. The other bits of
 
variable 18 remain undefined for now.
 
   
 
Since the tile isn't built yet, you can use variables 41, 42, 43, and 60 only, and you can't access any industry variables, either. Variable 60 is the most useful here, since you can check the slope of the tile, or even the nearby tiles. This callback is the only way to allow your tile to be built on steep slopes.
Since OpenTTD r20942, the second lowest byte of variable 18 contains the trigger event of the industry construction. The values
 
are the same as the lowest byte of variable 18 of callback 28.
 
   
 
{{ottdp|1.1|no|ottdrev=r19744}} Since OpenTTD r19744, you can access the random bits of the industry (it would get after construction) via industry variable 5F resp. [[RandomAction2]] type 83.
{{grf|7}}The meaning of the returned value is different in GRF version 7; it works the same way as [[Callbacks#Industry location permissibility (28) |callback 28]].
 
  +
Also, since TTDPatch r1755, you can use the text reference stack for your error messages, similarly to callback 3A. The only difference is that
 
 
{{ottdp| |2.6|ttdprev=r1728}} Since TTDPatch 2.6 r1728, the lowest byte of variable 18 contains the layout number selected for the industry. The other bits of variable 18 remain undefined for now.
only 4 registers are copied instead of 6.
 
  +
 
{{ottdp|1.1|no|ottdrev=r20942}} Since OpenTTD r20942, the second lowest byte of variable 18 contains the trigger event of the industry construction. The values
 
are the same as the lowest byte of variable 18 of callback 28.
   
'''PLEASE NOTE:''' When this callback is called, TTD is just checking, and hasn't placed any industry tiles yet. Therefore, bit 8 (tile
+
'''PLEASE NOTE:''' When this callback is called, TTD is just checking, and hasn't placed any industry tiles yet. Therefore, bit 8 (tile belongs to the same industry as current) of variable 60 will always be clear, even for the current tile.
belongs to the same industry as current) of variable 60 will always be clear, even for the current tile.
 
 
[[Category:Callbacks]]
 
[[Category:Callbacks]]

Latest revision as of 13:28, 1 April 2012

Custom shape check (2F)

This callback is called when TTD checks if a given tile is suitable for the industry tile. The callback should return zero if the tile isn't suitable, or any other value if it is suitable.

GRFv≥7 The meaning of the returned value is different in GRF version 7; it works the same way as callback 28. Supported by OpenTTD Supported by TTDPatch 2.6 (r1755)2.6 Also, since TTDPatch r1755, you can use the text reference stack for your error messages, similarly to callback 3A. The only difference is that only 4 registers are copied instead of 6.

Since the tile isn't built yet, you can use variables 41, 42, 43, and 60 only, and you can't access any industry variables, either. Variable 60 is the most useful here, since you can check the slope of the tile, or even the nearby tiles. This callback is the only way to allow your tile to be built on steep slopes.

Supported by OpenTTD 1.1 (r19744)1.1 Not supported by TTDPatch Since OpenTTD r19744, you can access the random bits of the industry (it would get after construction) via industry variable 5F resp. RandomAction2 type 83.

Supported by OpenTTD Supported by TTDPatch 2.6 (r1728)2.6 Since TTDPatch 2.6 r1728, the lowest byte of variable 18 contains the layout number selected for the industry. The other bits of variable 18 remain undefined for now.

Supported by OpenTTD 1.1 (r20942)1.1 Not supported by TTDPatch Since OpenTTD r20942, the second lowest byte of variable 18 contains the trigger event of the industry construction. The values are the same as the lowest byte of variable 18 of callback 28.

PLEASE NOTE: When this callback is called, TTD is just checking, and hasn't placed any industry tiles yet. Therefore, bit 8 (tile belongs to the same industry as current) of variable 60 will always be clear, even for the current tile.