NMLTutorial/Road vehicle

From TTWiki
< NMLTutorial
Revision as of 21:43, 22 August 2011 by FooBar (talk | contribs) (initial version at 0)
Jump to navigationJump to search

The example used here is from the NML source. The code for this was originally written by Terkhen and planetmaker. The graphics used in the example are by DanMack and Zephyris. Code and graphics are both licensed according to the GPL v2 or later. The code has been modified for the purpose of this tutorial


Introduction

In this part of the tutorial we'll be making a road vehicle. The example spans a couple of pages and has some intermediate pages introducing new concepts. We'll be assuming that you already have the graphics and know how to create the language file(s).


Grf block

You already know how to make a grf block, so make one or copy the example below. This goes at the top of your NML file.

//define the grf
grf {
    grfid: "NML\03";
    name: string(STR_GRF_NAME);
    desc: string(STR_GRF_DESC);
    version: 0;
    min_compatible_version: 0;
}


Language file

In the grf block you just defined two strings. These of course should go into at least one language file and more than one if you want to provide translations. For this example, we'll limit ourselves to english.lng:

##grflangid 0x01

# GRF name and description
STR_GRF_NAME   :NML Example NewGRF: Road Vehicle
STR_GRF_DESC   :{ORANGE}NML Example NewGRF: Road Vehicle{}{BLACK}This NewGRF is intended to provide a coding example for the high-level NewGRF-coding language NML.{}Original graphics by {SILVER}DanMack, Zephyris, {BLACK}coding by {SILVER}Terkhen, planetmaker.{}{BLACK}This NewGRF defines first-generation flatbed truck.

With this you have the basics of the NML and language file. Continue to learn about the item block; after that you'll be using it to define a road vehicle.


NML Tutorial: Road vehicle