Town names NML question(s)...

Discussions about the technical aspects of graphics development, including NewGRF tools and utilities.

Moderator: Graphics Moderators

Post Reply
Trond
Tycoon
Tycoon
Posts: 973
Joined: 25 Jan 2008 07:32
Location: Gamle Ørnenuten

Town names NML question(s)...

Post by Trond »

Is it possible to have an if/else or something block to check random generated town names?

Something like this:

If the townname part 2 ends with 'SS'
and the townname part 3 starts with 'S'
then remove one 'S' so we dont get names with 'SSS' in them?
..: Trond :.. because you deserve it! Image

The whole problem with the world is that fools and fanatics are always so certain of themselves,
and wiser people so full of doubts.
Bertrand Russell

MyGRFs: Norwegian Funny Town Names 4 | LOTR & WoW Town Names 2 | Islandic Town Names 1 | Random Norwegian Town Names
Favorites: GRFCrawler | ISR | WIKI | Now Playing: OpenTTD 1.3.2 w/YAPP 3.0-RC3.9ish
Eddi
Tycoon
Tycoon
Posts: 8289
Joined: 17 Jan 2007 00:14

Re: Town names NML question(s)...

Post by Eddi »

no. but you can work around that by separating the sets of prefixes that end with 's' from the ones that end differently, and provide different sets of suffixes for each set of prefixes
Trond
Tycoon
Tycoon
Posts: 973
Joined: 25 Jan 2008 07:32
Location: Gamle Ørnenuten

Re: Town names NML question(s)...

Post by Trond »

Thanks for the answer Eddi!
Thats what I was thinking about doing if there wasnt a way to achieve it with if/then... So I guess its back to work(around) then :)

One more question: the probabilities... never mind, I cant even formulate the question so that I understand it myself :/
..: Trond :.. because you deserve it! Image

The whole problem with the world is that fools and fanatics are always so certain of themselves,
and wiser people so full of doubts.
Bertrand Russell

MyGRFs: Norwegian Funny Town Names 4 | LOTR & WoW Town Names 2 | Islandic Town Names 1 | Random Norwegian Town Names
Favorites: GRFCrawler | ISR | WIKI | Now Playing: OpenTTD 1.3.2 w/YAPP 3.0-RC3.9ish
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Town names NML question(s)...

Post by planetmaker »

Trond wrote:Is it possible to have an if/else or something block to check random generated town names?

Something like this:

If the townname part 2 ends with 'SS'
and the townname part 3 starts with 'S'
then remove one 'S' so we dont get names with 'SSS' in them?
No, not directly. You need to tailor the composition rules such that it doesn't happen.
EDIT: yes, and Eddi was much faster
leifbk
Chairman
Chairman
Posts: 821
Joined: 23 Dec 2013 16:33
Location: Bærum, Norway

Re: Town names NML question(s)...

Post by leifbk »

I'm just starting with NewGRFs, and thought that it would be nice to create my own Town name generator. I have read most of the documentation on the wiki, and have created a project directory called "My_Norwegian_TownNames" with the following contents:

Code: Select all

leif@balapapa ~/projects/openttd/My_Norwegian_TownNames $ tree
.
├── custom_tags.txt
├── lang
│   └── english.lng
└── sprites
    └── My_Norwegian_TownNames.nfo

2 directories, 3 files
When I try to run grfcodec, this is what I get:

Code: Select all

leif@balapapa ~/projects/openttd/My_Norwegian_TownNames $ grfcodec -e My_Norwegian_TownNames.grf
Encoding in temporary file My_Norwegian_TownNames.new
NFO file missing header lines and version info
Here is the start of my .nfo file. I've tried to follow the "Town Names" example of the wiki:

Code: Select all

//
// Alternate Norwegian Town Names for OpenTTD
// Leifbk 2014
// Version 1, 2014-06-12
//

grf {
    grfid: "LK\01\01";
    name: string(STR_GRF_NAME);
    desc: string(STR_GRF_DESCRIPTION);
    version: 1;
    min_compatible_version: 1;
}

town_names(one) {
    {
        text("Alme", 1),
        text("Alve", 1),
What am I missing?
Transportman
Tycoon
Tycoon
Posts: 2792
Joined: 22 Feb 2011 18:34

Re: Town names NML question(s)...

Post by Transportman »

You are coding in NML, not in NFO. You need the purl=http://bundles.openttdcoop.org/nml/]nmlc[/url] program to compile them.
Coder of the Dutch Trackset | Development support for the Dutch Trainset | Coder of the 2cc TrainsInNML
leifbk
Chairman
Chairman
Posts: 821
Joined: 23 Dec 2013 16:33
Location: Bærum, Norway

Re: Town names NML question(s)...

Post by leifbk »

Transportman wrote:You are coding in NML, not in NFO. You need the nmlc program to compile them.
Great! I had nmlc installed already on my Gentoo Linux system. After a quick bug squash (a semicolon in an inappropriate place), I was able to successfully compile the .nfo. I've put the .grf file in the .openttd/content_download/newgrf folder, activated it in the NewGRF Settings, and started a new game, but my names don't show up. Is there a way to disable the original town names?
Transportman
Tycoon
Tycoon
Posts: 2792
Joined: 22 Feb 2011 18:34

Re: Town names NML question(s)...

Post by Transportman »

leifbk wrote:
Transportman wrote:You are coding in NML, not in NFO. You need the nmlc program to compile them.
Great! I had nmlc installed already on my Gentoo Linux system. After a quick bug squash (a semicolon in an inappropriate place), I was able to successfully compile the .nfo. I've put the .grf file in the .openttd/content_download/newgrf folder, activated it in the NewGRF Settings, and started a new game, but my names don't show up. Is there a way to disable the original town names?
To activate a Town name NewGRF, you also have to set the town names in the Game Options window to use your town names.

Another small remark, if you download/compile a NewGRF, you should place it in your .openttd/newgrf folder, not in the content_download folder.
Coder of the Dutch Trackset | Development support for the Dutch Trainset | Coder of the 2cc TrainsInNML
leifbk
Chairman
Chairman
Posts: 821
Joined: 23 Dec 2013 16:33
Location: Bærum, Norway

Re: Town names NML question(s)...

Post by leifbk »

Transportman wrote:To activate a Town name NewGRF, you also have to set the town names in the Game Options window to use your town names.
Right, I understand what you mean. But when I look at that list, I can't find it. How do I set the label?
Transportman wrote:Another small remark, if you download/compile a NewGRF, you should place it in your .openttd/newgrf folder, not in the content_download folder.
Thanks for the hint. I've done that now.
leifbk
Chairman
Chairman
Posts: 821
Joined: 23 Dec 2013 16:33
Location: Bærum, Norway

Re: Town names NML question(s)...

Post by leifbk »

leifbk wrote:
Transportman wrote:To activate a Town name NewGRF, you also have to set the town names in the Game Options window to use your town names.
Right, I understand what you mean. But when I look at that list, I can't find it. How do I set the label?
I found it myself - I had to provide the "styles : string(STR_STYLES);" with a meaningful text. And now I'm in a game with my very own town names, which feels good. The list needs a little tweaking though :)

A lot of thanks for your quick and very helpful hints :bow:

Edit: In case anybody finds this topic, the following may be helpful:

Code: Select all

$ nmlc --grf=mytownnames.grf sprites/My_Norwegian_TownNames.nml
$ cp mytownnames.grf ~/.openttd/newgrf/
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 23 guests