[Solved + free GRF to try!] Struggling with creating NewGRF for Town Names - help please?

Discuss, get help with, or post new graphics for TTDPatch and OpenTTD, using the NewGRF system, here. Graphics for plain TTD also acceptable here.

Moderator: Graphics Moderators

Post Reply
LabUser
Engineer
Engineer
Posts: 38
Joined: 21 Feb 2016 12:10

[Solved + free GRF to try!] Struggling with creating NewGRF for Town Names - help please?

Post by LabUser »

I've been playing OpenTTD (1.5.3) since New Year's Eve, and it is devouring my soul. I'm sure you all know that feeling. I've also pored through a bunch of this forum and some of the OpenTTD Coop stuff as well. I'm planning on starting a screenshot thread in this forum soon :D

After downloading a bunch of NewGRFs and cycling through about six different Town Name packs for the games I've been playing, I was interested in compiling a NewGRF of my very own to experiment with combining different language roots into a single naming pack. This is where I quickly get out of my depth.

So I've been trying to follow this tutorial on how to write the NML script. I downloaded the NML for Windows .zip file from here. Do I need any of the .tar.gz files?

After searching around I also came across this reddit thread of someone wanting help with this same topic, and the creator of the Random English Town Names NewGRF linking to his GitHub page. Being further confused after reading the README.md, I installed Python 2.7.11 as well. But do I need to install it to the same directory as I'm using the NML executable?

So far in my journey, I have created a folder to work out of, a "lang" folder inside of it, and the required english.lng, custom_tags.txt and <name>.nml files as called for by the tutorial. The tutorial then suggest converting those into a NewGRF file and testing that it is recognised by the game client. I open command prompt to that folder to run the NMLC executable, and it obediently spits out a <name>.grf file. But when I put that grf file into my OpenTTD newgrf directory and load the game, it doesn't appear in the NewGRF Settings menu. Is this because I'm not running the Nightly version of OpenTTD?

This is really doing my head in, and the tutorial seems to intuit a lot more prior knowledge than what I have. The actual writing of the .nml file I think I'll cope with, particularly with the example to work from that I linked. I'd appreciate any pointers more experienced people may have relating to getting a NewGRF file to be actually recognised by the game.

Thanks in advance!
Last edited by LabUser on 22 Feb 2016 07:03, edited 1 time in total.
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: Struggling with creating NewGRF for Town Names - help please?

Post by Alberth »

What is the nml file that you used to create the .grf file? Could you post that here?
Being a retired OpenTTD developer does not mean I know what I am doing.
LabUser
Engineer
Engineer
Posts: 38
Joined: 21 Feb 2016 12:10

Re: Struggling with creating NewGRF for Town Names - help please?

Post by LabUser »

These are the files I created following the tutorial. There's no actual coding besides the grf block header, but the tutorial implies that it should still spit out a grf file that the client will recognise, even though it does nothing.
Attachments
GJTown.nml
(137 Bytes) Downloaded 108 times
english.lng
(110 Bytes) Downloaded 97 times
custom_tags.txt
(25 Bytes) Downloaded 106 times
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: Struggling with creating NewGRF for Town Names - help please?

Post by Alberth »

Like this?
Attachments
gjtown1.png
gjtown1.png (22.78 KiB) Viewed 4687 times
Being a retired OpenTTD developer does not mean I know what I am doing.
LabUser
Engineer
Engineer
Posts: 38
Joined: 21 Feb 2016 12:10

Re: Struggling with creating NewGRF for Town Names - help please?

Post by LabUser »

That's exactly what I was expecting to see, yes. But I'm assuming I'm not compiling it correctly, one way or another.

Does the NML windows executable require Python to be pre-installed on the computer? Does it need to be in the same folder as the compiler?
I have no idea what I'm doing wrong at this stage, lol.
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Struggling with creating NewGRF for Town Names - help please?

Post by planetmaker »

How do you try to compile the grf? It's not a windows application which you can double-click and then does magically the right thing. You need to call it from command line with the appropriate parameters.

http://newgrf-specs.tt-wiki.net/wiki/NM ... stallation
LabUser
Engineer
Engineer
Posts: 38
Joined: 21 Feb 2016 12:10

Re: Struggling with creating NewGRF for Town Names - help please?

Post by LabUser »

Yes, I've read through that page until I was going cross-eyed.

So I open the command prompt, navigate to the correct folder containing the nmlc.exe, and then use "nmlc --grf GJTown.grf GJTown.nml" as the next command line. It obediently spits out a brand new .grf file titled GJTown.grf, which when I paste into the NewGRF folder in OpenTTD isn't recognised when I boot the game and go into the NewGRF Settings menu. If it showed up in there like Alberth was clearly able to manage, I'd be hip-deep in experimental code writing by now.


[EDIT]
To enable more clarity.

I am using Windows 7. I am playing on OpenTTD 1.5.3, not the Nightly versions.

I downloaded nml-v5850-windows-win32.zip and extracted that to a folder.

I created a "lang" folder inside that directory, and wrote the english.lng file that I attached previously in Note++. The other two files I attached were also written in Note++, as seen attached.


Screenshots of before and after I run the command line:
Attachments
Step One.png
(178.76 KiB) Not downloaded yet
Step Two.png
(160.69 KiB) Not downloaded yet
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: Struggling with creating NewGRF for Town Names - help please?

Post by Alberth »

Ok, the "grf" file here is 157 bytes.

Did you do a manual install? https://wiki.openttd.org/NewGRF#Manual_install
(the README file that came with your OpenTTD has more details perhaps)

Did you then activate the newgrf? (same wiki page, a bit further down).
Being a retired OpenTTD developer does not mean I know what I am doing.
LabUser
Engineer
Engineer
Posts: 38
Joined: 21 Feb 2016 12:10

Re: Struggling with creating NewGRF for Town Names - help please?

Post by LabUser »

The GJTown.grf file I generate is also 157 bytes.

Yes, I manually copy it into the My Documents/OpenTTD/newgrf folder that all the other NewGRFs that I use are stored.

Run OpenTTD, go to the NewGRF Settings menu, and it does not appear in the grf list for me to select it and see that it exists.



Did I need to do anything besides unzip the files from the nml pack into the folder, and run the command prompt inputs?


Edit: Screenshots of the NewGRF Folder, and the in-game NewGRF Menu
Attachments
GRF Directory.png
(181.79 KiB) Not downloaded yet
GRF Directory 2.png
(1.88 MiB) Not downloaded yet
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: Struggling with creating NewGRF for Town Names - help please?

Post by Alberth »

Hmm, no idea why it fails, I have run out of ideas.

we're talking a recent OpenTTD version?
there is an openttd.cfg file next to the program ?

Since you have a .grf file, I would expect nml to work properly. Attached the grf, although I expect it to be exactly the same as yours
Attachments
GJTown.grf
(157 Bytes) Downloaded 91 times
Being a retired OpenTTD developer does not mean I know what I am doing.
LabUser
Engineer
Engineer
Posts: 38
Joined: 21 Feb 2016 12:10

Re: Struggling with creating NewGRF for Town Names - help please?

Post by LabUser »

OK, so at least we know it isn't a problem with it compiling.

We now know this because the grf file you attached doesn't show up in my menus either. I also just went and downloaded the r27510 Nightly, and it doesn't show up in THAT either. So the files are formatted correctly, they're compiling correctly, its just a problem where the game(s) just don't want to read them for some reason...

At least we've narrowed it down a bit?

Heh.

Just to be completely thorough, I'll attach the output GRF file I create, and if you wouldn't mind checking if it reads?
Attachments
GJTown.grf
(157 Bytes) Downloaded 85 times
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: Struggling with creating NewGRF for Town Names - help please?

Post by Alberth »

grf file is identical to mine.

Maybe you can run OpenTTD in debug mode...
Start it from the command-line with a "-d grf=9" option. You likely want to catch output into a file, as it's going to spam a zillion lines output, so something like

Code: Select all

openttd -d grf=9 > output.txt
Ymmv, last time I used Windows was 20 years ago :p

After getting the opening screen, you can close it (you could also open the newgrf window, but I think that won't do much).
Then open the file, and look for the GJTown name

EDIT:
Assuming it won't be there, check for the directory. It should tell you what directories it scans too.
The README file gives details what directories are checked in what situation, for your Windows system.
Being a retired OpenTTD developer does not mean I know what I am doing.
LabUser
Engineer
Engineer
Posts: 38
Joined: 21 Feb 2016 12:10

Re: Struggling with creating NewGRF for Town Names - help please?

Post by LabUser »

Now I'm just feeling like an absolute moron.

So I ran OpenTTD from the command prompt with the command line you quoted. It created an Output.txt which was completely blank.

Opening the openttd.cfg file and reading through it doesn't give any indications of which grf's it can see, only which ones are currently enabled or enabled with preset configurations.

The ReadMe.txt in the install directory for the game gives generalisations that aren't entirely accurate, and in some cases seems to be out of date itself.

...

I guess I can always write the scripts, post them here on the forum, and get someone to check if they've compiled and work properly. Maybe if/when I add some content to the grfs, the game will suddenly recognise that they're meant to do something?


I dunno. I'm getting frustrated at it, so I'm going to sleep.
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: Struggling with creating NewGRF for Town Names - help please?

Post by Alberth »

:(

Did you also type the "-d grf=9" part?
you should get loads of output.

maybe try without the "> Output.txt" part then?

Code: Select all

"c:\blah\blah2\openttd.exe" -d grf=9
Without the "> filename" part it should output all lines to the command window.

Maybe someone with more Windows experience can help you better :(
Being a retired OpenTTD developer does not mean I know what I am doing.
LabUser
Engineer
Engineer
Posts: 38
Joined: 21 Feb 2016 12:10

Re: Struggling with creating NewGRF for Town Names - help please?

Post by LabUser »

Yes, the text flashes up too quickly to see anything, and I can't scroll back through all of it. Example screen attached.


Aaaaaand progress!


I put the .grf on a usb stick and tried it on my house-mate's computer. Strangely enough, it showed up. So then I went back through the grf list on my install, checking the GRF ID for every single one. Turns out, there was another GRF already using the same GRF ID code.

Mine was generated using the tutorial's suggested guide of "your initials \01\01", and obviously someone else has the same initials as me. [Edit] Turns out it is Dave, one of the mods here. It was the Black Country Town Names set that had the same GRF ID.

Is there somewhere that I can run the GRF ID to check if someone else is already using it?
Attachments
Wall of Text.png
Like this?
(220.58 KiB) Not downloaded yet
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: Struggling with creating NewGRF for Town Names - help please?

Post by Alberth »

Code: Select all

\o/
Great that you found the problem!



There is an attempt to a registry in the newgrf specs http://newgrf-specs.tt-wiki.net/wiki/Action8 but that is likely incomplete, since it's fully voluntary.
Being a retired OpenTTD developer does not mean I know what I am doing.
LabUser
Engineer
Engineer
Posts: 38
Joined: 21 Feb 2016 12:10

Re: Struggling with creating NewGRF for Town Names - help please?

Post by LabUser »

Cheers for all your help Alberth. Feels good to have worked it out and gotten everything working.

Its not terribly high quality yet, but it works. If you want to amuse yourself with a random hack-job of names mixing German and Japanese, feel free to try it and let me know what you think :D

I'll also edit the thread title (if I can) to update the status of my issue.
Attachments
GJTown.grf
The last 24 hours of my life.
(5.59 KiB) Downloaded 97 times
User avatar
FLHerne
Tycoon
Tycoon
Posts: 1543
Joined: 12 Jul 2011 12:09
Location: St Ives, Cambs, UK

Re: Struggling with creating NewGRF for Town Names - help please?

Post by FLHerne »

LabUser wrote:Is there somewhere that I can run the GRF ID to check if someone else is already using it?
You can check the 'Grf Identifier' column on the content server to see if your chosen ID is used.

If you have letters (or other characters not entered directly in hexadecimal as \nn), you should convert them to hexadecimal first.

e.g. for DW\01\01
DW -> 0x44 0x57
\01 is 0x01

So you should search for 44570101.

Note that some grfs are not on the content server, because their authors disagree with the T&Cs. You won't find those this way. That said, anything you downloaded from 'get online content' within OTTD is on there by definition.


@whoever on IRC told me there was no reason to query GrfIDs on Bananas - this is why I want a way for my tool to do that without (a) screenscraping or (b) trying to upload a grf with that ID! :rolleyes:
Temporary Permanent signature filling text. Content coming soon delayed indefinitely! Oh, and I have had a screenshot thread.
Linux user (XMonad DWM/KDE, Arch), IRC obsessive and rail enthusiast. No longer building robots; now I ring church bells.
Author of an incredibly boring stickied post about NewGRFs.
Eddi
Tycoon
Tycoon
Posts: 8267
Joined: 17 Jan 2007 00:14

Re: [Solved + free GRF to try!] Struggling with creating NewGRF for Town Names - help please?

Post by Eddi »

there is also this list of all IDs that were ever used on a public multiplayer server (could really use a date on when it was last updated)
Post Reply

Return to “Graphics Development”

Who is online

Users browsing this forum: GarryG, Google [Bot] and 66 guests