Difference between revisions of "NML:GRF parameters"

From GRFSpecs
Jump to navigationJump to search
(add nav template)
(redirect to GRF block page)
 
Line 1: Line 1:
  +
#REDIRECT [[NML:GRF]]
{{NMLNavBlocksyntax}}
 
 
As part of the grf block you can specify some parameter settings that the user will be able to change as part of the newgrf configuration. These can for example be used to disable parts of your NewGRF or to change between multiple graphics in case that's not possible at runtime. In general the settings (sub-)block looks like
 
 
param {
 
<name> {
 
type: <type>;
 
name: <string>;
 
desc: <string>;
 
min_value: <expression>;
 
max_value: <expression>;
 
def_value: <expression>;
 
names: {
 
0: <string>;
 
1: <string>;
 
.
 
.
 
.
 
};
 
}
 
}
 
 
Looking at the single entries:
 
 
type
 
 
This defines the parameter type. Possible values are <code style="color:darkgreen">bool</code> for on/off statements or <code style="color:darkgreen">int</code> for positive integer values
 
 
name
 
 
This gives the parameter name as shown in the parameter configuration dialogue of OpenTTD.
 
 
desc
 
 
This gives the description which is displayed when the parameter is selected. Here you can explain the meaning and impact it will have
 
 
min_value
 
 
The minimum acceptable value for the parameter (makes only sense for type int)
 
 
max_value
 
 
The maximum acceptable value for the parameter (makes only sense for type int)
 
 
def_value
 
 
This sets the default value for this parameter. If left out, the default value of 0 will be used.
 
 
names
 
 
If you chose type <code style="color:darkgreen">int</code> and the numbers themselves are only used internally, have no direct numerical meaning and are better explained in words, you can use this to associate the single numbers with a string which describes it and is shown to the user instead of the value. A simple example:
 
 
<pre style="color:blue">
 
param {
 
param_provide {
 
type: int;
 
name: string(STR_PARAM_PROVIDE);
 
desc: string(STR_PARAM_PROVIDE_DESC);
 
min_value: 0;
 
max_value: 1;
 
def_value: 0;
 
names: {
 
0: string(STR_PARAM_PROVIDE_ENGINES_AND_WAGONS);
 
1: string(STR_PARAM_PROVIDE_WAGONS_ONLY);
 
};
 
}
 
</pre>
 

Latest revision as of 00:39, 9 September 2011

Redirect to: