Difference between revisions of "NML:Town names"

From GRFSpecs
Jump to navigationJump to search
(add nav template)
(Added an example.)
Line 13: Line 13:
   
 
The optional <code style="color:darkgreen">&lt;string&gt;</code> defines how the town names are called in the menu. It may only be defined in a top-names block. To make the name available in all languages, it is probably a good idea to at least define a menu name for the generic language.
 
The optional <code style="color:darkgreen">&lt;string&gt;</code> defines how the town names are called in the menu. It may only be defined in a top-names block. To make the name available in all languages, it is probably a good idea to at least define a menu name for the generic language.
  +
  +
== Example ==
  +
  +
In this example, town names are randomly constructed from two parts. Note that the top-level block is on the bottom; this is necessary so it can reference the other two blocks. Have a look at the [[NML:Town_names_parts]] section for more info on the syntax used in this example.
  +
  +
town_names(one) {
  +
{
  +
text("Avon", 31),
  +
text("Black", 10),
  +
...
  +
}
  +
}
  +
  +
town_names(two) {
  +
{
  +
text(" Bridge", 1),
  +
text("ton", 1),
  +
...
  +
}
  +
}
  +
  +
town_names {
  +
styles : string(STR_STYLES);
  +
{
  +
town_names(one,3)
  +
}
  +
{
  +
town_names(two,1)
  +
}
  +
}
  +
  +
This will generate:
  +
  +
Avon Bridge
  +
Avonton
  +
Black Bridge
  +
Blackton

Revision as of 07:58, 24 April 2013

Block Syntax

To define randomly generated town names, the town_names block should be used. Such blocks can be used in two ways, as generator of (partial) town names for another block, or as top-level town names block, a starting point of town names in the grf file. You must have at least one starting point, but you can have more than one.

The general syntax of a town names block is:

town_names[(<name>)] {
	[styles : <string>]
	<part> <part> ....
}

The optional <name> defines the name of the block. Such a name is used to refer to this block from another town names block. For top-level town names blocks, it is often left out. Note that in that case, you must also leave out the parentheses.

The optional <string> defines how the town names are called in the menu. It may only be defined in a top-names block. To make the name available in all languages, it is probably a good idea to at least define a menu name for the generic language.

Example

In this example, town names are randomly constructed from two parts. Note that the top-level block is on the bottom; this is necessary so it can reference the other two blocks. Have a look at the NML:Town_names_parts section for more info on the syntax used in this example.

town_names(one) {
	{
	 	text("Avon", 31),
	 	text("Black", 10),
	 	...
	}
}

town_names(two) {
	{
	 	text(" Bridge", 1),
	 	text("ton", 1),
	 	...
	}
}

town_names {
	styles : string(STR_STYLES);
	{
	 	town_names(one,3)
	}
	{
	 	town_names(two,1)
	}
}

This will generate:

Avon Bridge
Avonton
Black Bridge
Blackton