Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Wed Jan 16, 2019 11:25 am

All times are UTC




Post new topic  Reply to topic  [ 19 posts ] 
Author Message
 Post subject: New town names
PostPosted: Fri Dec 28, 2018 8:02 am 
Offline
Engineer
Engineer

Joined: Sun Dec 02, 2018 5:50 am
Posts: 25
So I downloaded Erato's DPRK Town Names file (https://www.tt-forums.net/download/file.php?id=203852) and I edited the names.nml file to expand it. However, I've been searching for a couple days now but I can't for the life of me figure out how to compile it to make a grf... can someone please help? Thanks! :)


Top
   
 Post subject: Re: New town names
PostPosted: Fri Dec 28, 2018 8:23 am 
Offline
Tycoon
Tycoon
User avatar

Joined: Sat Jan 22, 2005 7:31 pm
Posts: 6382
Location: Wakefield, West Yorkshire
Have you looked on OpenTTD wiki?
One of these pages may have what you're searching for;

https://dev.openttdcoop.org/projects/nml - NML is I beleive what most people use for GRFs these days.
https://wiki.openttd.org/NewGRF_development_tools

_________________
Image
Worst Behaved IRC Member of 2008, 2009 & 2010 - Go Me!


Top
   
 Post subject: Re: New town names
PostPosted: Fri Dec 28, 2018 10:02 pm 
Offline
Engineer
Engineer

Joined: Sun Dec 02, 2018 5:50 am
Posts: 25
Redirect Left wrote:
Have you looked on OpenTTD wiki?
One of these pages may have what you're searching for;

https://dev.openttdcoop.org/projects/nml - NML is I beleive what most people use for GRFs these days.
https://wiki.openttd.org/NewGRF_development_tools


I've downloaded the NML but the documentation is kinda opaque (or I'm just dense?)... when I try to run (Windows) it a command line window comes up, there's some writing for an instant that I then can't see because it closes at once...

I've also looked around on the wiki but I couldn't find anything obvious about how to compile NML source into a usable GRF...


Top
   
 Post subject: Re: New town names
PostPosted: Fri Dec 28, 2018 10:13 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Fri Oct 17, 2008 12:17 pm
Posts: 2430
Location: Virgo Supercluster
This should help: https://www.tt-wiki.net/wiki/NMLTutorial

Quickest way for one time use (imo) is shove everything in appropriate NML folder; navigate there with CMD, type in nml command; done. Tutorial should explain the details ;)


Top
   
 Post subject: Re: New town names
PostPosted: Fri Dec 28, 2018 10:59 pm 
Offline
Moderator
Moderator
User avatar

Joined: Mon Sep 28, 2009 5:15 pm
Posts: 6401
Location: Eastern KY
kokutetsu wrote:
... when I try to run (Windows) it a command line window comes up...


NML is not a Windows GUI executable, it is a command line executable.

_________________
Do you like drones, quadcopters & flying toys? Check out Drone Strike Force!
Image

Base Music Sets: OpenMSX | Scott Joplin Anthology | Traditional Winter Holiday Music | Modern Motion Music
Other Projects: 2CC Trams | Modern Waypoints | Sprite Sandbox & NewGRF Releases | Ideabox | Town Names | Isle of Sodor Scenario | Random Sprite Repository
Misc Topics: My Screenshots | Forgotten NewGRFs | Unfinished Graphics Sets | Stats Shack | RoadTypes?


Top
   
 Post subject: Re: New town names
PostPosted: Sat Dec 29, 2018 6:17 am 
Offline
Engineer
Engineer

Joined: Sun Dec 02, 2018 5:50 am
Posts: 25
Thanks for the replies! They've been a help - I've got NML installed.

But when I tried to run

Quote:
nmlc -c --grf dprknames2.grf dprknames.pnml


It returned

Quote:
Illegal character '#' (character code 0x23) at "dprknames.pnml", line 2, column 1


The entire body of said pnml file is

Quote:
// Define GRF
#include "src/header.pnml"
#include "src/names.pnml"

//cd /mnt/c/Temp/MMT
//make -B


I didn't write this part, this was part of the original source I downloaded that (I imagine) works properly... the only thing I changed anywhere was the stuff in the names.pnml file.


Top
   
 Post subject: Re: New town names
PostPosted: Sat Dec 29, 2018 8:15 am 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Wed Nov 07, 2007 10:44 pm
Posts: 9102
Location: Sol d
Quote:
nmlc -c --grf dprknames2.grf dprknames.pnml


That is the correct way to call it - on an nml file.

The filename already gives it away, it ends with pnml:

Quote:
// Define GRF
#include "src/header.pnml"
#include "src/names.pnml"

//cd /mnt/c/Temp/MMT
//make -B


the "p" indicates that the file still needs pre-processing. The #include statements and similar are not part of the nml syntax itself. That file still needs pre-processing so that the files mentioned there are included at the given point, in this case by the cpp pre-processor (that is of the gcc). Maybe you can get away with simply copy & pasting the mentioned files in place of the #include "filename".

Usually such filenames are used to easier separate different parts of projects and then they are built using make and cpp as suggested by the last commented line in your quote. Those commands could be available also on windows when you install them in the linux subsystem.

_________________
Image
OpenTTD: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML


Top
   
 Post subject: Re: New town names
PostPosted: Sat Dec 29, 2018 10:29 am 
Offline
Engineer
Engineer

Joined: Sun Dec 02, 2018 5:50 am
Posts: 25
planetmaker wrote:
Maybe you can get away with simply copy & pasting the mentioned files in place of the #include "filename".


I'm not sure I get what you mean - do you mean to copy & paste the actual contents of the two .pnml files in place of the #include lines?

Quote:
Usually such filenames are used to easier separate different parts of projects and then they are built using make and cpp as suggested by the last commented line in your quote. Those commands could be available also on windows when you install them in the linux subsystem.


Hmm, that sounds like a lot of reading and learning for me before I dare take a stab at that... I'm not even entirely sure I understood it right, so for now I'll just give your first suggestion a try and hope for the best.


Top
   
 Post subject: Re: New town names
PostPosted: Sat Dec 29, 2018 10:47 am 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Wed Nov 07, 2007 10:44 pm
Posts: 9102
Location: Sol d
You could simply start with something where it is already in one file (+ lang files):
https://dev.openttdcoop.org/projects/du ... tnames.nml

_________________
Image
OpenTTD: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML


Top
   
 Post subject: Re: New town names
PostPosted: Sat Dec 29, 2018 11:05 am 
Offline
Engineer
Engineer

Joined: Sun Dec 02, 2018 5:50 am
Posts: 25
planetmaker wrote:
You could simply start with something where it is already in one file (+ lang files):
https://dev.openttdcoop.org/projects/du ... tnames.nml


Oh, well that's an idea too! I think I'll do that for now with real town names, and then save the thing I've written with pre and post sections for generating fake town names, for later...


Top
   
 Post subject: Re: New town names
PostPosted: Sat Dec 29, 2018 11:06 am 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Wed Nov 07, 2007 10:44 pm
Posts: 9102
Location: Sol d
http://bundles.openttdcoop.org/german-t ... es/LATEST/ is a more complex example, including real and fantasy names composed from parts. Its original is also in a format which needs a pre-compiler, but for convenience there's the pre-compiled NML as well on the build artefacts server.

_________________
Image
OpenTTD: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML


Top
   
 Post subject: Re: New town names
PostPosted: Sat Dec 29, 2018 6:17 pm 
Offline
Engineer
Engineer

Joined: Sun Dec 02, 2018 5:50 am
Posts: 25
I'm going ahead with doing just a simple grf with real place names for the moment, so I tried to test-compile that dtnames.nml file, but when I tried to run the nmlc etc command, it returned this:

Quote:
nmlc ERROR: "dtnames.nml", line 16: Unknown string "STR_GRF_DESCRIPTION"


I made no changes at all to the file, just tried to compile it as I got it from the link...

To take a little step back, I decided to do this test-compile of the original dtnames.nml because when I tried compiling the .nml file I made based on it, I got a return of:

Quote:
nmlc ERROR: "dprknames2.nml", line 1: Syntax error, unexpected token "{"


This surprised me, because the first line of the file contains only

Quote:
//


Top
   
 Post subject: Re: New town names
PostPosted: Sat Dec 29, 2018 8:25 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Fri Oct 17, 2008 12:17 pm
Posts: 2430
Location: Virgo Supercluster
You need the lang folder of the project too.

The tutorial explains this, but GRFs are basically made of
a) a .nml file where all the code goes
b) a lang folder where all the strings are defined for different game languages (like STR_GRF_DESCRIPTION)
c) a grf folder where all the graphics go; typically not needed for town names


Top
   
 Post subject: Re: New town names
PostPosted: Sat Dec 29, 2018 9:31 pm 
Offline
OpenTTD Developer
OpenTTD Developer

Joined: Sun Sep 09, 2007 5:03 am
Posts: 4688
Location: home
just grab the source archive from the nightlies (german-townnames-nightly-r35-source.tar.gz)
simplest is to drop the nml file in the 'german-townnames-nightly-r35-source' directory, change the directory of the shell to it ('cd german-townnames-nightly-r35-source') and run nmlc.

Otherwise, you need the 'lang' directory next to the nml file. The language files contain the texts describing the content of the grf, and setting parameters. (they are utf-8 text files, you can open them with a somewhat sane text editor.)


As for error messages, line numbers are not absolutely correct for several reasons. They do give a good rough indication of the point of where the compiler gives up though (which is not always the same as the point of the error), especially if your file is longer than about 5 lines. Off by 1 is quite comon, especially around white space (comment doesn't exist for the compiler, line 1 is "" to it rather than the "//" that you see.)

_________________
Being a OpenTTD developer does not mean I know what I am doing.
Also, other OpenTTD developers may have different opinions.


Top
   
 Post subject: Re: New town names
PostPosted: Sun Dec 30, 2018 2:24 am 
Offline
Engineer
Engineer

Joined: Sun Dec 02, 2018 5:50 am
Posts: 25
Well, progress - I figured out what the issue about the "token {" was... well now I've installed notepad++ and that issue is settled!

I've got my new grf successfully compiled, started a new game to test, and (naturally!) noticed an issue... as you can see in the picture, a town was generated with a blank name. If you look at the names in the town directory list, you'll see that all the UTF-8 characters show up just fine, so that's not the issue.

Image

I started three new games, and one blank-name town turned up in each of the three games... but in the nml body there isn't a line that's text(" ", 1), of course...


Attachments:
nameissue.png [680.3 KiB]
Not downloaded yet
Top
   
 Post subject: Re: New town names
PostPosted: Sun Dec 30, 2018 6:25 am 
Offline
OpenTTD Developer
OpenTTD Developer

Joined: Sun Sep 09, 2007 5:03 am
Posts: 4688
Location: home
Quote:
I started three new games, and one blank-name town turned up in each of the three games... but in the nml body there isn't a line that's text(" ", 1), of course...
First of all, congrats, you got stuff running, and it worked (mostly).

I fully agree with you that the name of the town is not visible. Having a name consisting of a single space is one form of an 'empty' name (technically it's not empty, it's a non-visible non-empty name, since the string has one space character in it). Other options are of course
Code:
text("", 1)
(0 spaces, ie the really empty string) or
Code:
text("  ", 1)
(with 2 spaces), etc.

Iirc, a town name may consist of several parts, where parts can be optional, so another way to construct an empty name, is to have all parts optional, so the computer can skip all parts, leaving you with 'nothing' as a name.

As for how to find what happens, you can debug it. Make a copy of the source code and store it somewhere out of the way. Then start hacking the source code. Make it smaller/simpler while you check if the problem continues to exist. If you have 15 choices somewhere, 2 are sufficient, etc. At some point the problem will go away. Then you know the crucial change was in the edits that you did since the last test. Eventually, you will find the edit that makes the problem disappear. At that point, try to understand why the behavior changes (computer use rules for deciding something, understand that rule).
Once you understand the rule, go back to your stored copy (and make a copy of your copy, just in case the fix doesn't work out as you expect), and fix the problem.

Another way is to get external help, like here at the forum, or at the #openttd IRC channel. You will need to supply the source code, so others can read it, look for errors, or even debug it like described above. Generally, you'll get pointed to the problem spot, so you can fix it.

_________________
Being a OpenTTD developer does not mean I know what I am doing.
Also, other OpenTTD developers may have different opinions.


Top
   
 Post subject: Re: New town names
PostPosted: Sun Dec 30, 2018 7:20 am 
Offline
Engineer
Engineer

Joined: Sun Dec 02, 2018 5:50 am
Posts: 25
Alberth wrote:
First of all, congrats, you got stuff running, and it worked (mostly).


Thanks! It's a small thing, to be sure, but it does boost one's confidence... :)

Quote:
I fully agree with you that the name of the town is not visible. Having a name consisting of a single space is one form of an 'empty' name (technically it's not empty, it's a non-visible non-empty name, since the string has one space character in it). Other options are of course
Code:
text("", 1)
(0 spaces, ie the really empty string) or
Code:
text("  ", 1)
(with 2 spaces), etc.

Iirc, a town name may consist of several parts, where parts can be optional, so another way to construct an empty name, is to have all parts optional, so the computer can skip all parts, leaving you with 'nothing' as a name.


Well, this one is using only a single group of names - so unlike the town name grfs that call a "prefix" and a "suffix" to create random names by combining two elements, this is just calling a single element, without making any combinations.

And in that single group, there are no elements like
Code:
text("", 1)
or
Code:
text("  ", 1)
- each one has an actual string of text (town name) within the double quotes.

Here is the entire nml: https://pastebin.com/vek7dx6a

In the meantime I'm going to go through the code chunk by chunk as you suggest.

Quote:
at the #openttd IRC channel


I've been connected there for a week now and have seen no activity at all apart from some automated (?) stuff from DevZone...


Top
   
 Post subject: Re: New town names
PostPosted: Sun Dec 30, 2018 9:34 am 
Offline
OpenTTD Developer
OpenTTD Developer

Joined: Sun Sep 09, 2007 5:03 am
Posts: 4688
Location: home
There are several #openttd channels, You're in #openttdcoop.devzone ?

Try the #openttd channel (without "coop" and without ".<something>")

EDIT: Ah, a pastebin, thanks.
So, what do you think
Code:
town_names {
    styles : string(STR_STYLES);
    {
        text("", 5),
        town_names(prefix, 1),
    }
}
does, in particular the 'text("", 5),' line ?

Just to be sure we're on the same page, I'll tell you any way :)
This is the main entry point. It makes a random selection between "", and a name in 'prefix' (the long list above), with a ratio 5:1. Since OpenTTD discards double names, you'll get only one "" name in the game.

The solution is to delete that line of course. But then this code makes a selection from 1 option only, which is a bit silly. Instead move the long list of names to here, and drop the 'prefix' block.

For more extensive documentation, see https://newgrf-specs.tt-wiki.net/wiki/NML:Town_names

_________________
Being a OpenTTD developer does not mean I know what I am doing.
Also, other OpenTTD developers may have different opinions.


Top
   
 Post subject: Re: New town names
PostPosted: Sun Dec 30, 2018 2:20 pm 
Offline
Engineer
Engineer

Joined: Sun Dec 02, 2018 5:50 am
Posts: 25
Ohhhhh well now I feel silly for not having thought of that!

I went ahead and changed it as you suggested, so that now it's like

Code:
town_names {
    styles : string(STR_STYLES);
    {
        text("foo", 5),
        text("bar", 5),
        text("baz", 5),
    }
}


and it's working just fine! Thank you!! :)

And yeah, I've now joined #openttdcoop... I've been sitting on #openttdcoop.devzone all this time...

Well, now time to start learning the less easy stuff! :)


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 19 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000-2019 phpBB Limited

Copyright © Owen Rudge/The Transport Tycoon Forums 2001-2019.
Hosted by Zernebok Hosting.