Difference between revisions of "ReadingOtherGRFParameters"

From GRFSpecs
Jump to navigationJump to search
m (3 revisions)
(Updated table syntax)
Line 2: Line 2:
 
'''''Reading another GRF file's parameters'''''
 
'''''Reading another GRF file's parameters'''''
   
 
==Introduction==
==Reading another GRF file's parameters==
 
 
-=Introduction=-
 
   
 
Since 2.0.1 alpha 16, it has been possible to use action D to read the parameters of other GRF files. With this, you can try to use the settings for another related GRF before falling back to a hard coded default.
 
Since 2.0.1 alpha 16, it has been possible to use action D to read the parameters of other GRF files. With this, you can try to use the settings for another related GRF before falling back to a hard coded default.
   
-=Format=-
+
==Format==
   
 
<pre> -+&lt;Sprite-number&gt; * &lt;Length&gt; 0D &lt;target&gt; &lt;operation&gt; &lt;param&gt; FE &lt;grfid&gt;+-</pre>
 
<pre> -+&lt;Sprite-number&gt; * &lt;Length&gt; 0D &lt;target&gt; &lt;operation&gt; &lt;param&gt; FE &lt;grfid&gt;+-</pre>
   
  +
{| class="wikitable"
||'''Element'''|[[GRFActionsDetailed|'''Size''']]|'''Description'''
 
  +
|-
 
  +
!'''Element'''
0D|B|Defines action 0D
 
 
![[GRFActionsDetailed|'''Size''']]
 
  +
!'''Description'''
&lt;target&gt;|B|Target parameter
 
  +
|-
 
  +
|0D
&lt;operation&gt;|B|As for [[ActionD#operation|action D]], but only assignment is valid.
 
  +
|B
 
 
|Defines action 0D
&lt;param&gt;|B|Parameter number of the other GRF file that you want to read
 
  +
|-
 
  +
|&lt;target&gt;
FE|B|Defines a special variable access
 
  +
|B
 
 
|Target parameter
&lt;grfid&gt;|D|The GRFID whose parameter you want to read||
 
  +
|-
  +
|&lt;operation&gt;
  +
|B
 
|As for [[ActionD#operation|action D]], but only assignment is valid.
  +
|-
  +
|&lt;param&gt;
  +
|B
 
|Parameter number of the other GRF file that you want to read
  +
|-
  +
|FE
  +
|B
 
|Defines a special variable access
  +
|-
  +
|&lt;grfid&gt;
  +
|D
 
|The GRFID whose parameter you want to read
  +
|}
   
 
This will store parameter &lt;param&gt; of the GRF file with grfid &lt;grfid&gt; into the &lt;target&gt;
 
This will store parameter &lt;param&gt; of the GRF file with grfid &lt;grfid&gt; into the &lt;target&gt;

Revision as of 11:53, 14 June 2011

Reading another GRF file's parameters

Introduction

Since 2.0.1 alpha 16, it has been possible to use action D to read the parameters of other GRF files. With this, you can try to use the settings for another related GRF before falling back to a hard coded default.

Format

 -+<Sprite-number> * <Length> 0D <target> <operation> <param> FE <grfid>+-
Element Size Description
0D B Defines action 0D
<target> B Target parameter
<operation> B As for action D, but only assignment is valid.
<param> B Parameter number of the other GRF file that you want to read
FE B Defines a special variable access
<grfid> D The GRFID whose parameter you want to read

This will store parameter <param> of the GRF file with grfid <grfid> into the <target>

With parameter FE you can read the action 14 NewGRF version of another NewGRF in OpenTTD. It returns 0 if no NewGRF version has been set by an action 14.

If the GRF ID cannot be found, or if the parameter is not defined, a value of 0 is used instead (no matter whether bit 7 of the operation is set or not).