Difference between revisions of "NMLTutorial/Cargotable"

From TTWiki
Jump to navigationJump to search
(some words on the cargotable)
 
(you can have only one cargotable)
Line 6: Line 6:
 
== Cargotable ==
 
== Cargotable ==
   
The cargotable is the means to let NML know about the cargo labels you want to use in your NML file. Every NewGRF can have exactly one cargotable (but you may select from several using if/else statements). The cargotable needs to be defined before you reference a cargo label in your NML code.
+
The cargotable is the means to let NML know about the cargo labels you want to use in your NML file. An NML file can have exactly one cargotable. The cargotable needs to be defined before you reference a cargo label in your NML code.
   
 
The cargotable itself is no more than a list of cargo labels. You need to [http://newgrf-specs.tt-wiki.net/wiki/CargoTypes#Cargo_Labels look the cargo labels up] for the cargos you want to do special things with. This is what the general syntax looks like:
 
The cargotable itself is no more than a list of cargo labels. You need to [http://newgrf-specs.tt-wiki.net/wiki/CargoTypes#Cargo_Labels look the cargo labels up] for the cargos you want to do special things with. This is what the general syntax looks like:

Revision as of 22:12, 23 August 2011

Whenever you want to work with specific cargos, you need to teach NML about those cargos. The reason for this is that new cargos can be invented at will, so NML doesn't keep a list of existing cargo labels and therefore you have to provide this list yourself.


Cargotable

The cargotable is the means to let NML know about the cargo labels you want to use in your NML file. An NML file can have exactly one cargotable. The cargotable needs to be defined before you reference a cargo label in your NML code.

The cargotable itself is no more than a list of cargo labels. You need to look the cargo labels up for the cargos you want to do special things with. This is what the general syntax looks like:

cargotable {
	<cargo_label1> [, <cargo_label2> [, <cargo_label3> ... ]]
}

You can add as many cargo labels to the cargotable as you want/need.

First 32 cargo labels

The first 32 cargo labels however should be selected with care, if you're making a vehicle set. The reasons for this is that only the first 32 cargos can be used in the refittable_cargo_types property for vehicles. So stick cargo labels you use in that property into the cargotable first and add other cargo labels at the end.


Cargo labels or cargo classes?

When it comes to allowing cargos in a vehicle, you should always use cargo classes and not only cargo labels. That way your vehicle set will be compatible with cargos that don't even exist yet. Use cargo labels only to deny specific cargos in your vehicles or to provide specific graphics for a specific cargo.

Furthermore, industries and houses don't work with cargo classes, so there you can only use the cargo labels.


Now that you know about the cargotable, let's add some cargo specific graphics to our example road vehicle.


NML Tutorial: Cargotable