Difference between revisions of "NML:If"

From GRFSpecs
Jump to navigationJump to search
(add nav template)
(Add hint for ternary operator)
 
Line 15: Line 15:
 
param[2] = 5
 
param[2] = 5
 
}
 
}
  +
</pre>
  +
  +
For a single variable or property assignment the ternary operator might be shorter:
  +
  +
result = boolean_value ? if_true : if_false;
  +
  +
e.g.
  +
  +
<pre style=example>
  +
ground_sprite = (nearby_tile_type(0,0) == TILETYPE_DESERT) ? GROUNDSPRITE_DESERT : GROUNDSPRITE_NORMAL;
 
</pre>
 
</pre>

Latest revision as of 23:58, 3 September 2011