Difference between revisions of "Callback: Can wagon be attached"

From GRFSpecs
Jump to navigationJump to search
m (Create a separate page for each callback)
 
(clarify Action 3 evaluation)
 
(4 intermediate revisions by 3 users not shown)
Line 3: Line 3:
 
This callback is called for the train engine (i.e. from the engine's action 3) when attaching a new vehicle to the current train and determines whether it may in fact be attached to the train. The callback is always used when defined, no bit in the action 0 property needs to be set to activate it.
 
This callback is called for the train engine (i.e. from the engine's action 3) when attaching a new vehicle to the current train and determines whether it may in fact be attached to the train. The callback is always used when defined, no bit in the action 0 property needs to be set to activate it.
   
You may use variational action 2s to check variables 40+x and 80+x. For var. action 2 type 81 (vehicle), they refer to variables of the wagon that is to be attached, not the engine it is being attached to, so you can check the wagon's properties like the cargo type to see whether it is appropriate for the given train engine.
+
You may use VarAction2s to check variables 40+x and 80+x. For var. action 2 type 81 (vehicle), they refer to variables of the wagon that is to be attached, not the engine it is being attached to, so you can check the wagon's properties like the cargo type to see whether it is appropriate for the given train engine.
   
Var. action 2 type 82 (engine) refers to the engine the wagon is being attached to, starting from version TTDPatch 2.0.1 alpha 46. This allows you to for example find out the length of the train it is being attached to. In earlier patch versions, it refers to the engine of the source consist (or the wagon if the wagon is not attached to anything else), which was not really helpful.
+
{{ottdp| |2.5|ttdprev=alpha 46}} Var. action 2 type 82 (engine) refers to the engine the wagon is being attached to, starting from version TTDPatch 2.0.1 alpha 46. This allows you to for example find out the length of the train it is being attached to. In earlier patch versions, it refers to the engine of the source consist (or the wagon if the wagon is not attached to anything else), which was not really helpful.
   
  +
So, overall the callback is evaluated this way:
Return values:
 
  +
* The Action 3 is used from the regular engine (livery overrides have no influence).
  +
* The cargotype to use in Action 3 is taken from the wagon.
  +
* VarAction2 types 81, 85, 89 refer to the wagon.
  +
* VarAction2 types 82, 85, 8A refer to the engine.
   
  +
{{grfTill|7}} For GRF version 7 and below the valid return values are:
 
{| |-
 
{| |-
 
!Return!!Meaning
 
!Return!!Meaning
 
|-
 
|-
|xx||Disallow attaching and use the D0xx text ID as second line of an error message,
+
|00..FC||Disallow attaching and use the D0xx (D000..D0FC) text ID as second line of an error message,
 
|-
 
|-
 
|FD||Disallow attaching with the standard message (incompatible rail types)
 
|FD||Disallow attaching with the standard message (incompatible rail types)
 
|-
 
|-
 
|FE||Allow attaching<ref name="ignorerailtype">This mean you would allow attaching for example a monorail wagon to a regular rail vehicle.</ref>
|FE||Allow attaching
 
 
|-
 
|-
 
|FF||Allow attaching if the rail types match (default)
 
|FF||Allow attaching if the rail types match (default)
 
|}
 
|}
   
  +
{{grfFrom|8}} For GRF version 8 and above the valid return values are:
It you return FE, you would allow attaching for example a monorail wagon to a regular rail vehicle, so if that's not what you intend, return FF.
 
  +
{| |-
  +
!Return!!Meaning
  +
|-
  +
|00..3FF||Disallow attaching and use the D0xx (D000..D3FF) text ID as second line of an error message,
  +
|-
  +
|400||Allow attaching if the rail types match (default)
  +
|-
  +
|401||Allow attaching<ref name="ignorerailtype"/>
  +
|-
  +
|402||Disallow attaching with the standard message (incompatible rail types)
  +
|}
  +
  +
<references/>
  +
 
[[Category:Callbacks]]
 
[[Category:Callbacks]]

Latest revision as of 13:54, 19 January 2014

Can wagon be attached (1D)

This callback is called for the train engine (i.e. from the engine's action 3) when attaching a new vehicle to the current train and determines whether it may in fact be attached to the train. The callback is always used when defined, no bit in the action 0 property needs to be set to activate it.

You may use VarAction2s to check variables 40+x and 80+x. For var. action 2 type 81 (vehicle), they refer to variables of the wagon that is to be attached, not the engine it is being attached to, so you can check the wagon's properties like the cargo type to see whether it is appropriate for the given train engine.

Supported by OpenTTD Supported by TTDPatch 2.5 (alpha 46)2.5 Var. action 2 type 82 (engine) refers to the engine the wagon is being attached to, starting from version TTDPatch 2.0.1 alpha 46. This allows you to for example find out the length of the train it is being attached to. In earlier patch versions, it refers to the engine of the source consist (or the wagon if the wagon is not attached to anything else), which was not really helpful.

So, overall the callback is evaluated this way:

  • The Action 3 is used from the regular engine (livery overrides have no influence).
  • The cargotype to use in Action 3 is taken from the wagon.
  • VarAction2 types 81, 85, 89 refer to the wagon.
  • VarAction2 types 82, 85, 8A refer to the engine.

GRFv≤7 For GRF version 7 and below the valid return values are:

Return Meaning
00..FC Disallow attaching and use the D0xx (D000..D0FC) text ID as second line of an error message,
FD Disallow attaching with the standard message (incompatible rail types)
FE Allow attaching[1]
FF Allow attaching if the rail types match (default)

GRFv≥8 For GRF version 8 and above the valid return values are:

Return Meaning
00..3FF Disallow attaching and use the D0xx (D000..D3FF) text ID as second line of an error message,
400 Allow attaching if the rail types match (default)
401 Allow attaching[1]
402 Disallow attaching with the standard message (incompatible rail types)
  1. 1.0 1.1 This mean you would allow attaching for example a monorail wagon to a regular rail vehicle.