NML/NFO to GRF Related problem......

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

User avatar
FooBar
Tycoon
Tycoon
Posts: 6553
Joined: 21 May 2007 11:47
Location: The Netherlands
Contact:

Re: NML to GRF Related problem......

Post by FooBar »

Try encoding either as "Unicode without BOM" or as "ANSI". The latter should be fine for NML code, as that generally doesn't contain any special characters. Myself I use unicode (without BOM) only for language files.

Other than that I don't see anything particularly wrong that could cause this.
User avatar
YNM
Tycoon
Tycoon
Posts: 3574
Joined: 22 Mar 2012 11:10
Location: West Java

Re: NML to GRF Related problem......

Post by YNM »

Silly. I was encoding using ANSI when the templates going fixed, it says to use UTF-8 instead.
Now I should use ANSI again ? Heck.
FooBar wrote: unicode (without BOM)
UTF-8 (without BOM), maybe.

And some seconds after... it repeated with ANSI. trying with UTF-8 (Without BOM)...

And it repeated again.
YNM = yoursNotMine - Don't get it ?
「ヨーッスノットマイン」もと申します。
Eddi
Tycoon
Tycoon
Posts: 8289
Joined: 17 Jan 2007 00:14

Re: NML to GRF Related problem......

Post by Eddi »

you have the command line the wrong way around, you need

Code: Select all

nmlc --grf <grf-file> <nml-file>
User avatar
YNM
Tycoon
Tycoon
Posts: 3574
Joined: 22 Mar 2012 11:10
Location: West Java

Re: NML to GRF Related problem......

Post by YNM »

Eddi wrote:you have the command line the wrong way around, you need

Code: Select all

nmlc --grf <grf-file> <nml-file>
the -c surely not needed again ? (as stated on the tutorial to better show them up ?)
Anyway, still trying.....

....

Damn, get the same result. How about your compiling ? Is it the same too ?
YNM = yoursNotMine - Don't get it ?
「ヨーッスノットマイン」もと申します。
Eddi
Tycoon
Tycoon
Posts: 8289
Joined: 17 Jan 2007 00:14

Re: NML to GRF Related problem......

Post by Eddi »

Yoursnotmine wrote:the -c surely not needed again ?
the -c is optional, you can use it, or not, it's not relevant to your problem. the point was you have to exchange the .grf and .nml files.
Damn, get the same result. How about your compiling ? Is it the same too ?
the GRF cannot be compiled without the english.lng file.
User avatar
FooBar
Tycoon
Tycoon
Posts: 6553
Joined: 21 May 2007 11:47
Location: The Netherlands
Contact:

Re: NML to GRF Related problem......

Post by FooBar »

Yoursnotmine wrote:UTF-8 (without BOM), maybe.
Sorry for the confusion. UTF-8 and unicode are for this purpose the same thing.

But Eddi's suggestion is more likely the cause of the problems you're having, I didn't notice that before :)
User avatar
YNM
Tycoon
Tycoon
Posts: 3574
Joined: 22 Mar 2012 11:10
Location: West Java

Re: NML to GRF Related problem......

Post by YNM »

FooBar wrote:
Yoursnotmine wrote:UTF-8 (without BOM), maybe.
Sorry for the confusion. UTF-8 and unicode are for this purpose the same thing.

But Eddi's suggestion is more likely the cause of the problems you're having, I didn't notice that before :)
Well, now it works, but seriously the problem is with the templates. I already understand about (x,y) coordinates, also trying to change some other thing that is supposed to be a number, but the templates - do I need to change the templates right before the item (differentiating them so it won't be wrong), and also I still don't understand about the 8 vehicle views.

Half O/T : Really, coding makes my eye sick :( (Black on White, nothing else to be seen in the middle)

About testing to compile, I'll add the .lang later so you can check the code.
YNM = yoursNotMine - Don't get it ?
「ヨーッスノットマイン」もと申します。
User avatar
FooBar
Tycoon
Tycoon
Posts: 6553
Joined: 21 May 2007 11:47
Location: The Netherlands
Contact:

Re: NML to GRF Related problem......

Post by FooBar »

Yoursnotmine wrote:(differentiating them so it won't be wrong)
If you're going to use different templates for each and every vehicle, you might as well not use templates. Templates are designed so that you can reuse one for multiple vehicles.

Anyways, the eight views are actually quite simple. Ingame a vehicle can drive in 8 different directions, for each direction there is a separate view. You need to provide these 8 views in a specific order: towards top, towards top right, towards right, towards bottom right, towards bottom, towards bottom left, towards left, towards top left. The game assumes the sprites to be in this order, so you have to provide them in this order. So a template will always[0] have 8 lines, one for each sprite for the 8 views.

For each sprite you have to provide a set of numbers: x and y coordinates of the top left corner of the sprite (blue box) in the png file, width and height of the sprite in the png file, and the x and y offsets for the sprites to be applied ingame. The first four numbers you can simply look up. The last is a bit of guessing. There are rules for this, but in general you need to do manual adjustments anyways using the ingame sprite aligner, so you might as well guess.

A template just makes some of these numbers variable, generally the top left corner.

Lastly "something" (for instance a template) needs to exist in your code before you can use it. So if you want to use a template for a vehicle, the template definition needs to be somewhere before the vehicle definition. I generally put the templates all behind one another somewhere near the top of the nml file (yes, multiple, but that's due to different vehicle lengths, not due to different templates for each vehicle; in the Dutch Trainset there are nine templates for hundreds of vehicles).

Hope that helps!


[0] There are different possibilities, but let's not go into detail too much, as that will make things only more confusing. Maybe one exception is justified here: the purchase menu only needs one sprite, not eight.
User avatar
YNM
Tycoon
Tycoon
Posts: 3574
Joined: 22 Mar 2012 11:10
Location: West Java

Re: NML to GRF Related problem......

Post by YNM »

Oh, so that's the kob of a template? Oh, really I don't want a single engine with only 8 views (no on/off lights) packed each in a different file. Could it be something other ? Look at my old sprite (page 2 in this topic), actually the 3 vehicles (only 2 completed) is all different. (Except the unfinished, really it have the same shape with the lower one IRL)

If I choosing to use that, how's the way out ? Really, it sucks if a single .png file only filled with 8 drawings. Then it would be a huge folder for my GRF to build.

Anyway, if there's no other way, still better I start to place each of them in a single file.
YNM = yoursNotMine - Don't get it ?
「ヨーッスノットマイン」もと申します。
User avatar
FooBar
Tycoon
Tycoon
Posts: 6553
Joined: 21 May 2007 11:47
Location: The Netherlands
Contact:

Re: NML to GRF Related problem......

Post by FooBar »

You can have as many or as little png files as you want. You can put all vehicles in one file, one file per vehicle, multiple files per vehicle, or any other combination. Have a look at the source of the Dutch Trainset for instance, to see how that is ordered: http://dev.openttdcoop.org/projects/dut ... repository. And how it uses its templates, and how those come together for a vehicle with multiple liveries.
User avatar
YNM
Tycoon
Tycoon
Posts: 3574
Joined: 22 Mar 2012 11:10
Location: West Java

Re: NML to GRF Related problem......

Post by YNM »

I see that the name of the templates are changed, the name is template_2cc_n8.
Maybe usefull for mine, or is that a sort of other things ? I don't know.

About the template form, likely is it following the one from the NML template tutorial rather than the NML Train tutorial ?
Also the n8, what is their usage ?

Also, I still don't understand about the last template / thing before the item. What are their usage and how free are we can modify them ? (the only thing I start to understand about them is to apply the template)
YNM = yoursNotMine - Don't get it ?
「ヨーッスノットマイン」もと申します。
User avatar
FooBar
Tycoon
Tycoon
Posts: 6553
Joined: 21 May 2007 11:47
Location: The Netherlands
Contact:

Re: NML to GRF Related problem......

Post by FooBar »

Yes, one template for each possible vehicle length. template_2cc_88 for an 8/8 vehicle length all the way down to template_2cc_18 for a 1/8 vehicle length. They don't follow any tutorial per se, but I suppose they are indeed similar to the template tutorial. The train tutorial shows you some advanced tricks of templating, it's up to you if you want to use those or if you want to stick to an easier format.
Yoursnotmine wrote:Also, I still don't understand about the last template / thing before the item. What are their usage and how free are we can modify them ? (the only thing I start to understand about them is to apply the template)
I'm not sure what "thing" you mean, but I'm guessing spritesets? See http://www.tt-wiki.net/wiki/NMLTutorial ... pritegroup

If you don't understand certain parts of the NML tutorial, please let us know what that is, so that we can improve those sections.
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: NML to GRF Related problem......

Post by planetmaker »

Yoursnotmine wrote: Also, I still don't understand about the last template / thing before the item. What are their usage and how free are we can modify them ? (the only thing I start to understand about them is to apply the template)
You should also risk a look at the documentation. Not just the examples.
User avatar
YNM
Tycoon
Tycoon
Posts: 3574
Joined: 22 Mar 2012 11:10
Location: West Java

Re: NML to GRF Related problem......

Post by YNM »

FooBar wrote:Yes, one template for each possible vehicle length. template_2cc_88 for an 8/8 vehicle length all the way down to template_2cc_18 for a 1/8 vehicle length. They don't follow any tutorial per se, but I suppose they are indeed similar to the template tutorial. The train tutorial shows you some advanced tricks of templating, it's up to you if you want to use those or if you want to stick to an easier format.
Yoursnotmine wrote:Also, I still don't understand about the last template / thing before the item. What are their usage and how free are we can modify them ? (the only thing I start to understand about them is to apply the template)
I'm not sure what "thing" you mean, but I'm guessing spritesets? See http://www.tt-wiki.net/wiki/NMLTutorial ... pritegroup

If you don't understand certain parts of the NML tutorial, please let us know what that is, so that we can improve those sections.
About the "thing" , It's something look like a template right before the item (but not template). Maybe that is it.

Indeed, maybe template_2cc_88 is likely a modidications to the usual template (tutorial template). About the trick it showed, likely more harder for me to use them, I will use something simmiliar to the 2cc template.
planetmaker wrote:
Yoursnotmine wrote: Also, I still don't understand about the last template / thing before the item. What are their usage and how free are we can modify them ? (the only thing I start to understand about them is to apply the template)
You should also risk a look at the documentation. Not just the examples.
Documentation ? Really, I'm not a coder at all, not even the so called "hello world" program in any language. Will try to read & understand it as much as I can.
YNM = yoursNotMine - Don't get it ?
「ヨーッスノットマイン」もと申します。
User avatar
YNM
Tycoon
Tycoon
Posts: 3574
Joined: 22 Mar 2012 11:10
Location: West Java

Re: NML to GRF Related problem......

Post by YNM »

Aah.. finished it ! only offset are still needed to be fixed, but others are OK (now I also know that the name of the template lookalike is spriteset & how to modify them)

Here's all :
ITP_try.nml
The NML file
(7.1 KiB) Downloaded 138 times
ITP_try.grf
the GRF file
(3.36 KiB) Downloaded 205 times
english.lng
The .lng file
(607 Bytes) Downloaded 128 times
Maybe this can be said as a way to an beta or alpha... Just wait !

Anyway, just need to ask, what are the palette used in the Purno's Drawing Tutorial ?
Also, does anyone knows the location or have the windows palette for GIMP?


Half O/T : Really, I want to release a GRF for Indonesian or Southeast Asian trains... As many of the older trains and newer EMU's/DMU's are using other nations engine / set that actually is already available as a GRF now, can I have the sprite for them ?
Eg. for Indonesia, many old steamers are Dutch and many of the new EMU's are Japanese.
YNM = yoursNotMine - Don't get it ?
「ヨーッスノットマイン」もと申します。
User avatar
FooBar
Tycoon
Tycoon
Posts: 6553
Joined: 21 May 2007 11:47
Location: The Netherlands
Contact:

Re: NML to GRF Related problem......

Post by FooBar »

Yoursnotmine wrote:maybe template_2cc_88 is likely a modidications to the usual template (tutorial template)
I can assure you that it isn't a modification, both were written from scratch without considering the other ;)
Yoursnotmine wrote:Aah.. finished it !
Glad you got it sorted! :)
Yoursnotmine wrote:Anyway, just need to ask, what are the palette used in the Purno's Drawing Tutorial ?
Also, does anyone knows the location or have the windows palette for GIMP?
That would be the Windows palette. However, for NewGRFs created in NML the DOS palette is recommended, as there really is no point any more to use the Windows palette.
Here are instructions for GIMP, together with a link to the DOS palette: http://www.tt-wiki.net/wiki/Save_palett ... files#GIMP. Other palettes are available through a link at the top of the page, in case you need one.
Yoursnotmine wrote:As many of the older trains and newer EMU's/DMU's are using other nations engine / set that actually is already available as a GRF now, can I have the sprite for them ?
In that case you need to check the license of the projects you want to use parts of, to see if you're allowed to do so and under what conditions. If the license doesn't allow that you use parts of the previous work, then you can contact the author(s) to see if you can get permission.

In case of the Dutch trains I happen to know that they're licensed GPLv2. This means that you may reuse them, provided that your work (when released) is also released under this license, keeping all copyright notices intact and all the other things the license tells you to do (which isn't hard, but I recommend you to read the license to see if you agree with it). It also means that all sprite from other sources need to be (re)-released under the GPL license. Either way, always ask the authors if you're not sure if you're allowed or not.
User avatar
YNM
Tycoon
Tycoon
Posts: 3574
Joined: 22 Mar 2012 11:10
Location: West Java

Re: NML to GRF Related problem......

Post by YNM »

Likely now I have to learn about livery refitting... Many of trains here have gone through 3 era, first being the green - yellow livery (also occasionally yellow - cream), second the red - blue livery, and the last is the white with blue stripes.

I know that this livery refit is also used on the Dutch trainset. The refit options in the tutorial indeed showing how to refit a 3 car set into a four car set.

Also, how is the way to make carriage livery-refitted by itself when attached to a particular engine ? i saw them used in many trainset.
YNM = yoursNotMine - Don't get it ?
「ヨーッスノットマイン」もと申します。
User avatar
YNM
Tycoon
Tycoon
Posts: 3574
Joined: 22 Mar 2012 11:10
Location: West Java

Re: NML to GRF Related problem......

Post by YNM »

EDIT : sorry if this look like a doublepost


After take a look on the tutorial and a topic here that match, really I'm confused now...

The tutorial makes many switch and callbacks, which I not understand what they are used on... (likely "switch" is intended for changing graphics, while "callbacks" is used to change the manner)

The topic is likely made by someone who have (at least) a medium knowledge over coding... and so unable to speak from the begining.....


And one more thing, is drawing by DOS palette and Windows palette is different ? For you who have downloaded the GRF, you must be see it.
YNM = yoursNotMine - Don't get it ?
「ヨーッスノットマイン」もと申します。
User avatar
FooBar
Tycoon
Tycoon
Posts: 6553
Joined: 21 May 2007 11:47
Location: The Netherlands
Contact:

Re: NML to GRF Related problem......

Post by FooBar »

You need to be more specific on what you don't understand, I have no idea how I can help you further now.
Yoursnotmine wrote:And one more thing, is drawing by DOS palette and Windows palette is different ?
The DOS palette has 6 extra colours.
OpenTTD internally also uses the DOS palette, so there's no reason any more to use the Windows palette if you're coding in NML.
User avatar
YNM
Tycoon
Tycoon
Posts: 3574
Joined: 22 Mar 2012 11:10
Location: West Java

Re: NML/NFO to GRF Related problem......

Post by YNM »

Well, I came back to the world of coding again... tried code a station. The problem is that the graphics got drawn wrong in-game...
Station problem.png
Station problem.png (30.75 KiB) Viewed 2742 times
the station should be have the concrete over the platform...

To make it easier, here's the code :

Code: Select all

// Automatically generated by GRFCODEC. Do not modify!
// (Info version 7)
// Format: spritenum pcxfile xpos ypos compression ysize xsize xrel yrel    
    0 * 4    0C 00 00 00
    1 * 51    08 07 "PJ" 00 00 "Underground Metro Station version 0.0" 00
    "By YNM" 00
    2 * 6    01 04 01 FF 04 00
    3 C:\Users\THINKCENTRE\Pictures\Projects\Metro_Station\metroRET_blue.pcx 9 268 01 122 64 -31 -89
    4 C:\Users\THINKCENTRE\Pictures\Projects\Metro_Station\metroRET_blue.pcx 89 268 01 122 64 -31 -83
    5 C:\Users\THINKCENTRE\Pictures\Projects\Metro_Station\metroRET_blue.pcx 169 268 01 122 64 -31 -83
    6 C:\Users\THINKCENTRE\Pictures\Projects\Metro_Station\metroRET_blue.pcx 249 268 01 122 64 -31 -89
    7 * 62    00 04 02 01 00 08 "UDBL" 09 02 F4 03 00 00 00 00 00 10 05 03 2D 84 00 00 00 00 00 10 10 7A 2E 84 00 00 80 F3 03 00 00 00 00 00
 05 10 03 2F 84 00 00 00 00 00 10 10 7A 30 84 00 00 80
    8 * 7    02 04 00 00 01 00 00
    9 * 7    02 04 01 00 01 00 00
   10 * 10    03 04 01 00 01 FE 01 00 00 00
   11 * 29    04 48 FF 01 00 "┼Underground Metro Tile" 00
   12 * 32    04 48 FF 01 00 "─Underground Metro Station" 00
Also here's the image file : (in .png due to me working using MSPaint)
metroRET_blue.png
(42.7 KiB) Downloaded 1 time
Could you spot the problem ? I suspect its due to the boundingboxes and wrong sprite placing, but I don't know how and where to change it...
YNM = yoursNotMine - Don't get it ?
「ヨーッスノットマイン」もと申します。
Post Reply

Return to “Graphics Development”

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 22 guests