How to make a NewGRF properly ?

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

Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: How to make a NewGRF properly ?

Post by Alberth »

Please post your nml code, s people can point out your errors instead of having to dig in nmlc compiler sources
Being a retired OpenTTD developer does not mean I know what I am doing.
User avatar
acs121
Tycoon
Tycoon
Posts: 1957
Joined: 03 Nov 2017 18:57
Location: Courbevoie, near Paris, France

Re: How to make a NewGRF properly ?

Post by acs121 »

Hey,

How do i make cars change liveries if they are attached to a certains locomotive in NML ?
To explain, i want to do the same thing as the Generic MU cars go in 2cc TrainsInNML.
User avatar
Gwyd
Chief Executive
Chief Executive
Posts: 721
Joined: 17 Apr 2017 16:52
Location: Western Ile-de-France Region

Re: How to make a NewGRF properly ?

Post by Gwyd »

Livery override. It works in a similar way to the graphics block, but you need to define the carriage that is accepted and changed when coupled (by number or vehicle ID)
User avatar
acs121
Tycoon
Tycoon
Posts: 1957
Joined: 03 Nov 2017 18:57
Location: Courbevoie, near Paris, France

Re: How to make a NewGRF properly ?

Post by acs121 »

Gwyd wrote:Livery override. It works in a similar way to the graphics block, but you need to define the carriage that is accepted and changed when coupled (by number or vehicle ID)
How do i insert it as NML code ?
User avatar
acs121
Tycoon
Tycoon
Posts: 1957
Joined: 03 Nov 2017 18:57
Location: Courbevoie, near Paris, France

Re: How to make a NewGRF properly ?

Post by acs121 »

Livery override is solved, now i just need to know about this error :

Code: Select all

[Knmlc ERROR: nmlc: An internal error has occurred:
nmlc-version: v6379:afad0c76c40b from 2017-06-19
Error:    (ValueError) "Unknown format code 'r' for object of type 'str'".
Command:  ['nmlc', '-c', '--grf', 'randstadrail.grf', 'randstadrail.nml']
Location: File "nml\grfstrings.py", line 971, in handle_grflangid
I attached everything if anyone wants to point out my errors.
Attachments
randstadrail.rar
(3.87 MiB) Downloaded 63 times
User avatar
acs121
Tycoon
Tycoon
Posts: 1957
Joined: 03 Nov 2017 18:57
Location: Courbevoie, near Paris, France

Re: How to make a NewGRF properly ?

Post by acs121 »

acs121 wrote:Livery override is solved, now i just need to know about this error :

Code: Select all

[Knmlc ERROR: nmlc: An internal error has occurred:
nmlc-version: v6379:afad0c76c40b from 2017-06-19
Error:    (ValueError) "Unknown format code 'r' for object of type 'str'".
Command:  ['nmlc', '-c', '--grf', 'randstadrail.grf', 'randstadrail.nml']
Location: File "nml\grfstrings.py", line 971, in handle_grflangid
I attached everything if anyone wants to point out my errors.
So no one wants to look into my code ?
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: How to make a NewGRF properly ?

Post by Alberth »

I fixed nmlc, and now it says

Code: Select all

nmlc ERROR: "lang/english.lng", line 1: Invalid grflangid '0x01 :'
Not sure why you add a colon to a number
Being a retired OpenTTD developer does not mean I know what I am doing.
User avatar
acs121
Tycoon
Tycoon
Posts: 1957
Joined: 03 Nov 2017 18:57
Location: Courbevoie, near Paris, France

Re: How to make a NewGRF properly ?

Post by acs121 »

Alberth wrote:I fixed nmlc, and now it says

Code: Select all

nmlc ERROR: "lang/english.lng", line 1: Invalid grflangid '0x01 :'
Not sure why you add a colon to a number
Okay, thanks. Now it works with this part. Now it's telling me :

Code: Select all

[Knmlc ERROR: "randstadrail.nml", line 84: Syntax error, unexpected token ":"
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: How to make a NewGRF properly ?

Post by Alberth »

It means "I found a ':' and I have run out of ideas what you're trying to tell me."

In other words, the computer needs better directions from you. Computers are very fast but also very stupid. You cannot make typos, or add or omit random symbols, they immediately get stuck.

The ':' is the point where it gave up all hope of understanding you, often the real cause is a bit before that point.

Carefully check the line, and the line above! Verify that what you are trying to do is allowed at this point. Verify that you closed enough parentheses and square or curly brackets on the construct above.

Oh, and by "carefully", I mean very very very very carefully, not just glance over it, scrutinize each letter, digit, and symbol. Computers are fast but very stupid!
Being a retired OpenTTD developer does not mean I know what I am doing.
User avatar
acs121
Tycoon
Tycoon
Posts: 1957
Joined: 03 Nov 2017 18:57
Location: Courbevoie, near Paris, France

Re: How to make a NewGRF properly ?

Post by acs121 »

Alberth wrote:It means "I found a ':' and I have run out of ideas what you're trying to tell me."

In other words, the computer needs better directions from you. Computers are very fast but also very stupid. You cannot make typos, or add or omit random symbols, they immediately get stuck.

The ':' is the point where it gave up all hope of understanding you, often the real cause is a bit before that point.

Carefully check the line, and the line above! Verify that what you are trying to do is allowed at this point. Verify that you closed enough parentheses and square or curly brackets on the construct above.

Oh, and by "carefully", I mean very very very very carefully, not just glance over it, scrutinize each letter, digit, and symbol. Computers are fast but very stupid!
Okay i found the error and now it finally is working. Now it's telling me the sprites i've attached below don't have a palette :
Attachments
htm_4001.png
htm_4001.png (8.71 KiB) Viewed 3153 times
User avatar
Andrew350
Chairman
Chairman
Posts: 768
Joined: 19 Dec 2011 07:54
Location: Washington State, USA
Contact:

Re: How to make a NewGRF properly ?

Post by Andrew350 »

See this page: https://www.tt-wiki.net/wiki/NMLTutorial/Graphic_files

It is the second page of the NML Tutorial, which I would highly suggest you read (and practice!) from start to finish to give you a solid understanding of some of the basics of NewGRF making. Mind you, it isn't something to be completed in 5 minutes; I spent close to a week going through it and it was still just enough to get going, but it's a good foundation to start from, and provides some good links to other resources as well :)
User avatar
acs121
Tycoon
Tycoon
Posts: 1957
Joined: 03 Nov 2017 18:57
Location: Courbevoie, near Paris, France

Re: How to make a NewGRF properly ?

Post by acs121 »

Andrew350 wrote:See this page: https://www.tt-wiki.net/wiki/NMLTutorial/Graphic_files

It is the second page of the NML Tutorial, which I would highly suggest you read (and practice!) from start to finish to give you a solid understanding of some of the basics of NewGRF making. Mind you, it isn't something to be completed in 5 minutes; I spent close to a week going through it and it was still just enough to get going, but it's a good foundation to start from, and provides some good links to other resources as well :)
Okay so...where must i put this palette file ? It's in th "gfx" folder, i tried with the four palettes and it didn't work.
User avatar
Quast65
Tycoon
Tycoon
Posts: 2661
Joined: 09 Oct 2011 13:51
Location: The Netherlands

Re: How to make a NewGRF properly ?

Post by Quast65 »

The palette has to be incorporated in your graphics file.
The easiest way to get a paletted graphicsfile is to decompile a GRF and just resize the graphicsfile that was in there to suit your graphics and then copy your graphics into that (and ofcourse then save it with the name you want to give it).
Projects: http://www.tt-forums.net/viewtopic.php?f=26&t=57266
Screenshots: http://www.tt-forums.net/viewtopic.php?f=47&t=56959
Scenario of The Netherlands: viewtopic.php?f=60&t=87604

Winner of the following screenshot competitions:
sep 2012, jan 2013, apr 2013, aug 2013, mar 2014, mar 2016, oct 2020
All my work is released under GPL-license (either V2 or V3), if not clearly stated otherwise.
User avatar
Pyoro
Tycoon
Tycoon
Posts: 2558
Joined: 17 Oct 2008 12:17
Location: Virgo Supercluster

Re: How to make a NewGRF properly ?

Post by Pyoro »

Quast65 wrote:The palette has to be incorporated in your graphics file.
The easiest way to get a paletted graphicsfile is to decompile a GRF and just resize the graphicsfile that was in there to suit your graphics and then copy your graphics into that (and ofcourse then save it with the name you want to give it).
That strikes me as an odd solution. And if you do it (if I understand what you describe right) using something like paint.net, the files will actually lose their palette the moment you save anything (same for everything else that doesn't support palettes).


That aside ... it's not like the tutorial which acs linked doesn't explain how to do it :roll:
https://www.tt-wiki.net/wiki/Save_paletted_image_files
(GIMP is free and useful to have in any case; but there's obviously plenty alternatives)
User avatar
Quast65
Tycoon
Tycoon
Posts: 2661
Joined: 09 Oct 2011 13:51
Location: The Netherlands

Re: How to make a NewGRF properly ?

Post by Quast65 »

And if you do it (if I understand what you describe right) using something like paint.net, the files will actually lose their palette the moment you save anything (same for everything else that doesn't support palettes).
Ahh, good point. I use Photoshop, so never had any problems with that ;-) But good to know.
Projects: http://www.tt-forums.net/viewtopic.php?f=26&t=57266
Screenshots: http://www.tt-forums.net/viewtopic.php?f=47&t=56959
Scenario of The Netherlands: viewtopic.php?f=60&t=87604

Winner of the following screenshot competitions:
sep 2012, jan 2013, apr 2013, aug 2013, mar 2014, mar 2016, oct 2020
All my work is released under GPL-license (either V2 or V3), if not clearly stated otherwise.
User avatar
acs121
Tycoon
Tycoon
Posts: 1957
Joined: 03 Nov 2017 18:57
Location: Courbevoie, near Paris, France

Re: How to make a NewGRF properly ?

Post by acs121 »

Quast65 wrote:The palette has to be incorporated in your graphics file.
The easiest way to get a paletted graphicsfile is to decompile a GRF and just resize the graphicsfile that was in there to suit your graphics and then copy your graphics into that (and ofcourse then save it with the name you want to give it).
That's with Photoshop, i'm talking about GIMP since i use GIMP. :D
Oh well, i solved my issue now. Thanks Pyoro too.
Post Reply

Return to “Graphics Development”

Who is online

Users browsing this forum: No registered users and 35 guests