Town Names nml, if then question

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

Post Reply
User avatar
paulcobbaut
Engineer
Engineer
Posts: 10
Joined: 20 Apr 2017 08:19

Town Names nml, if then question

Post by paulcobbaut »

I created a newgrf with custom town names, it works.
The code ends like this:

Code: Select all

town_names {
	styles : string(STR_STYLES);
	{
	 	town_names(one,3)
	}
	{
	 	town_names(two,3)
	}
	{
	 	town_names(three,3)
	}
}
How do I add an if statement here so that if townname(one) equals "saint-" then it picks town_names(four) instead of two and three?

When ending the code like this:

Code: Select all

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

town_names {
	styles : string(STR_STYLES);
	{
	 town_names(holyone,3)
	}
	{
 	 town_names(holytwo,3)
	}
}
then it never generates the holy towns.
When commenting out the first town_names block, it generates only holy towns.

I'm struggling to write an if statement, anything I have tried when looking at the tutorials or other code results in a syntax error. Ideally it generates 75 percent normal town names and 25 percent holy town names.
--
Sent from Debian Linux
User avatar
paulcobbaut
Engineer
Engineer
Posts: 10
Joined: 20 Apr 2017 08:19

Re: Town Names nml, if then question

Post by paulcobbaut »

Found it.

Code: Select all

town_names(normal) {
	{
	 town_names(one,3)
	}
	{
 	 town_names(two,3)
	}
	{
 	 town_names(three,3)
	}
}

town_names(holy) {
	{
	 town_names(holyone,3)
	}
	{
 	 town_names(holytwo,3)
	}
}

town_names {
	styles : string(STR_STYLES);
	{
	 town_names(normal,5),
	 town_names(holy,1)
	}
}
--
Sent from Debian Linux
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: Baidu [Spider] and 2 guests