And now we come to what is the tricky part, the coding
You can find more elaborate info about NFO coding here:
http://newgrf-specs.tt-wiki.net/wiki/Main_PageHere you can find loads more info about what attributes you can give to your GRF, but right now we focus on just a simple stationtile.
This is the code I used to create the stationtiles in the pictures above:
Code:
// 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 * 38 08 07 "PJ" 00 00 "Tutorial version 0.0" 00
"By Quast65" 00
2 * 6 01 04 01 FF 04 00
3 c:\grfmaken\grfcodecwin\tutorial\tutorial.pcx 8 7 01 122 64 -31 -91
4 c:\grfmaken\grfcodecwin\tutorial\tutorial.pcx 88 7 01 122 64 -31 -91
5 c:\grfmaken\grfcodecwin\tutorial\tutorial.pcx 168 7 01 122 64 -31 -91
6 c:\grfmaken\grfcodecwin\tutorial\tutorial.pcx 248 7 01 122 64 -31 -91
7 * 62 00 04 02 01 00 08 "TUT0" 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 * 25 04 48 FF 01 00 "ÅBasic station tile" 00
12 * 15 04 48 FF 01 00 "ÄTutorial" 00
Yep, it looks like a lot of numbers and letters that look like a lot of gibberish, but I will explain it so it will make more sense so you can make your own code.
First of all you need a text programme to write this all in, notepad will do. Open notepad and save it as a .nfo file. In this case I named it tutorial.nfo, but you can name it as you want. Normally you give it your projectname and also include a versionnumber so that you know what is what when you have made loads more of these
Just make sure that you don't have any spaces in the name! GRFcodec (the programme that you will use to eventually make the GRF) will not work with spaces in the name, just use _ in stead of a space.
Right, lets explain that code a bit:
Code:
// Automatically generated by GRFCODEC. Do not modify!
// (Info version 7)
// Format: spritenum pcxfile xpos ypos compression ysize xsize xrel yrel
This is a standard text that has to be at the start of every .nfo, GRFcodec will not work without this!
Just copy paste this to every new .nfo
Now we get to the actual code part:
Code:
0 * 4 0C 00 00 00
You always start with spritenumber 0 and on that line you give the information about how many lines of code are in the .nfo. In this case there are 12 lines of code, which you have to give as a hexadecimal number, 12 is 0C in hexadecimal. This online converter is what I usually use:
http://www.statman.info/conversions/hexadecimal.htmlBut basically this is how you count in hexadecimal: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0A, 0B, 0C, 0D, 0E, 0F, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1A, 1B and so on.
So what does this line say:
0 = pseudospritenumber
4 = how many bytes there are in this line. Right now they are easy to count, this will get trickier later on. But have no fear, GRFcodec will give a warning when this number is incorrect and will tell you the right number. So just change the number then and let GRFcodec run again until you don't have any warnings any more. So you don't have to count long lines yourself
0C 00 00 00 = how many lines of code there are in this .nfo
This is not that difficult right? You only have to change the byte with the number of lines of code as you make your .nfo larger. Up to 255 lines it is not that difficult, after that it gets a bit trickier, because you will have to change 2 bytes then. But you will have drawn a lot of stationtiles before you get to that
I'll explain how that works with the hexadecimal converter later in this thread. It is not that important right now.
Righto, next line of code:
Code:
1 * 38 08 07 "PJ" 00 00 "Tutorial Version 0.0" 00 "By Quast65" 00
In this line you'll provide the information about your GRF, the GRF-ID, Name and Description
1 = pseudospritenumber
38 = how many bytes there are in this line
08 = action 8
07 = NFO versionnumber, has to be the same number as the one you gave at the standard text at the top of your NFO. Basically this number gives information about which version of Openttd it is compatible with. Make sure to set a version number no lower than the minimum version that supports all features which are used by your file. Right now version 7 is the most modern one.
"PJ" 00 00 = the GRF-ID, This is a series of 4 bytes. It's a convention to use the first two bytes for the creator's initials (in my case PJ). The last two
bytes should be numbers, typically the first number identifying which of the author's sets this is, and the second number being a version number.
In principle, you are free what to use for the GRF ID as long as you are sure it is unique, but generally it is best to follow the above guidelines. However if you release new versions of your GRF it is best to keep the same GRF-ID and just change the name of the GRF. This is better if anyone wants to update your GRF in a running game. So to make a long story short, choose a GRF-ID and stick to that
"Tutorial Version 0.0" = A short text containing the name of this set, this is the name that you will see in the new-GRF menu. If you update your GRF (for instance you have added more stationtiles), change the versionnumber.
"By Quast65" = A longer description of this set. This will show up on the right of the new-GRF menu if you select this GRF. You can provide an elaborate description of what this GRF is about here.
Woohoo, 2 lines down, 10 to go
Code:
2 * 6 01 04 01 FF 04 00
This line defines a set of new sprites, it is not really necessary to go deep into what this all means (basically the first 04 means that it is a station and the second 04 that it has 4 views), if you want to read more about it just look for action1 in the NFO reference of which I gave the URL earlier. When you add more stationtiles you'll have to repeat this line, but you don't have to change anything in it.
Next!
Code:
3 c:\grfmaken\grfcodecwin\tutorial\tutorial.pcx 8 7 01 122 64 -31 -91
Now it is getting interesting, this is where you define where the NFO can find the pretty graphics you have drawn
3 = pseudospritenumber
c:\grfmaken\grfcodecwin\tutorial\tutorial.pcx = the location of your graphics file. You will need to change this to where your file is located, again make sure there are no spaces in the foldernames and the filename!!
8 7 = the X and Y position of the upperleft corner of the sprite in your graphicsfile. I usually use Photoshop to make my graphics and I can find that
information by placing my pointer on the upperleft corner:
Attachment:
position.png [ 38.13 KiB | Viewed 11323 times ]
You will have to change that information for every single sprite you have drawn.
01 = compression, don't worry about this, just set it to 01, you don't have to change this for other graphics.
122 64 = The Y and X size of the sprite. This is one of the reasons I use base sprites for my graphics, so I don't have to change those sizes all the time. In my case my sprite is 122 pixels high and 64 pixels wide.
-31 -91 = The X and Y positions of the upper-left corner of the sprite, relative to the "center" (usually negative). I think it is easier to explain this
with a picture:
Attachment:
relativeposition.png [ 21.2 KiB | Viewed 11323 times ]
This is also why I use base sprites, that way I also don't have to change that information. But if you have stationtiles with sizes that won't fit into your base sprites, this will give you an idea how to find that information.
And well, with the first line set I can repeat that for the other 3 sprites and i only have to change the X and Y positions of the upperleft corner, like
this:
Code:
4 c:\grfmaken\grfcodecwin\tutorial\tutorial.pcx 88 7 01 122 64 -31 -91
5 c:\grfmaken\grfcodecwin\tutorial\tutorial.pcx 168 7 01 122 64 -31 -91
6 c:\grfmaken\grfcodecwin\tutorial\tutorial.pcx 248 7 01 122 64 -31 -91
Allrighty, we are halfway!!
Code:
7 * 62 00 04 02 01 00 08 "TUT0" 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
This is a very important line, It will define all kinds of properties to your station. There are loads of properties, which you can find at the NFO reference of which I gave the URL, but these are the basics for a stationtile that can be entered and driven through by trains (so for example you have to set different properties for buffers or stationtiles with no rails)
here we go:
7 * 62 = pseudospritenumber and how many bytes
00 = Action type. In this case, Action0
04 = Which type of feature you would like to change, 04 is station
02 = How many properties you would like to change per vehicle or station, in this case two. We are going to set the Class ID and the Spritelayout.I'll come back to that later. If you want to add more properties, don't forget to change this number accordingly!!
01 = How many vehicles/stations you would like to change. Just this one.
00 = The station-ID, this is an important number! You will have to change this number when you add more stationtiles. As this is the first it's number is 00, all next numbers are in hexadecimal! So for example your eleventh station doesn't have number 10 but 0A and so on.
08 "TUT0" = Class ID, the TUT0 refers to the action4 in line 12. This 4 letter and/or number combination has to be unique, just like your GRF-ID! By setting this property your stationset will show up in the stationmenu ingame. This is also useful if you want to have different types of stations in one set. So for example TUT0 has normal stations with no roof, TUT1 has stations with roofs, TUT2 has stations designed for cargo, whatever your imagination can think of
It is just useful so that you can have different classes in your set and not everything under one name in the station menu.
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 = Sprite layout, this will need a bit more explaining.
09 = property number 09, refers to sprite layout
F4 03 = groundsprite. This is a hexadecimal number that refers to the sprite in the OpenGFX baseset, in decimals it's number 1012, which is a grasstile with a diagonal rail in East-West direction. This sprite can change accordingly to the railtype you use, so that is why you didn't have to bother with drawing tracks in your stationgraphics. Furthermore, you can change this basetile to another tile if you want. So for example you have a stationbuilding with no rails, you could use a concrete slab from the baseset as a groundtile and so don't need to draw that.
00 00 00 00 00 10 05 03 2D 84 = spritedata of the backgroundsprite in the E-W direction. Well, this I dont really get myself
Only thing I do know is that 10 05 03 refers to the boundingbox size in hexadecimal. I usually use these numbers for my background boundingbox, so 16 pixels long, 5 wide, 3 high.
00 00 00 00 00 10 10 7A 2E 84 = the same, but for the foreground sprite. For the boundingbox of the foregroundsprite I usually set it to the same size as the basesprite I used, so that I don't have to change these numbers anymore if I use the same basesprites, so in this case 16 pixels long, 5 wide, 122 high.
00 00 80 = a literal 80 ends the list of sprites for this tile
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 = Same as above, but for the South-West direction. F3 03 is spritenumber 1011 in the base set, a grasstile with diagonal rails in S-W direction.
Don't worry too much about all these settings, If you have set the boundingboxes to the size you want, you only have to change the station-ID if you add more stations and maybe the class-ID if you want to add a new stationclass in the menu.
Pfew, done the big one! Let's do the rest.
Code:
8 * 7 02 04 00 00 01 00 00
I'm not exactly sure what this does
My knowledge of the code is a bit limited. I only think that it has something to do with the way the graphics show up in the menu, just insert this line in your code and don't worry too much about it. You don't have to change anything here if you add another stationtile.
Code:
9 * 7 02 04 01 00 01 00 00
See above
Code:
10 * 10 03 04 01 00 01 FE 01 00 00 00
10 * 10 = pseudospritenumber and how many bytes
03 = Action 3, assigns graphics sets to feature IDs
04 = What type of feature the IDs refer to, 04 is station
01 = Number of IDs this action 3 associates graphics with, just the one
00 = The station-ID, the same number as the one stated in pseudosprite 7, just before the 08. As with that number, you will have to change this number everytime you add a new station.
01 FE 01 00 00 00 = All this has something to do with cargospecific graphics, what exactly I don't know.
Code:
11 * 25 04 48 FF 01 00 "ÅBasic station tile" 00
This line of code will provide the name of the stationtile that you can see in the menu under the graphics and also as a description if you use the ?-tool, the stationtype so to say.
11 * 25 = pseudospritenumber and how many bytes
04 = Action4, Defines station name
48 = What type of feature the IDs refer to, 48 is original strings.
FF = Languagefile, FF is default
01 = Number of consecutive strings to change, just the one
00 = The station-ID, the same number as the one stated in pseudosprite 7, just before the 08. As with that number, you will have to change this number everytime you add a new station.
"ÅBasic station tile" = The actual name that you will see in the menu under the graphics. I'm not entirely sure what the Å does, but I have seen it in many GRF's and I think it is to distinguish station type names from stationclass names, but I'm not sure
But do use this symbol before the actual name!
00 = a final 00 to indicate the end of the string
And woohoo, the final one!!
Code:
12 * 15 04 48 FF 01 00 "ÄTutorial" 00
This line of code will provide the name of the stationclass that you can see in the menu and also as a description if you use the ?-tool. This also has a connection to the "TUT0" that was entered in line 7. This is useful because you only have to set this name once and for other stations that also have "TUT0", you don't have to repeat this line!
12 * 15 = pseudospritenumber and how many bytes
04 = Action4, Defines station name
48 = What type of feature the IDs refer to, 48 is original strings.
FF = Languagefile, FF is default
01 = Number of consecutive strings to change, just the one
00 = The station-ID, the same number as the one stated in pseudosprite 7, just before the 08. As with that number, you will have to change this number everytime you add a new station.
"ÄTutorial" = The actual name that you will see in the menu. I'm not entirely sure what the Ä does, but I have seen it in many GRF's and I think it is to distinguish stationclass names from station types names, but I'm not sure
But do use this symbol before the actual name!
00 = a final 00 to indicate the end of the string
And that's it! Pretty easy hey, NOT!
But I will make it easy now, if you use my graphic basetiles you don't have to worry about a lot of settings, Ive done that all for you now
Basically the only things you have to change are:
- line 0, the total number of lines you have in your code
- line 1, the GRF-ID, the name and the description
- lines 3 to 6, only the location of the graphics on your computer and the the X and Y position of the upperleft corner of the sprite in your graphicsfile.
- line 7, the station-ID and the class ID
- line 10, the station-ID
- line 11, the station-ID and the station type name
- line 12, the station-ID and the station class name
And here are some example codes if you add more stationtiles. As you can see it is just easy copypaste work with some small (but very important) changes,
I'll highlight the changes I made.
Example 1: Just one stationclass, with 3 different stationtypes. Adding more is simple copypaste work, you only have to change the
Station-ID's, the
stationtype names, the
X and Y positions, the
number of bytes in the lines with the names, the linenumbers and the
total number of lines in line 0:
// Automatically generated by GRFCODEC. Do not modify!
// (Info version 7)
// Format: spritenum pcxfile xpos ypos compression ysize xsize xrel yrel
0 * 4
20 00 00 00
1 * 38 08 07 "PJ" 00 00 "Tutorial version 0.0" 00
"By Quast65" 00
2 * 6 01 04 01 FF 04 00
3 c:\grfmaken\grfcodecwin\tutorial\tutorial.pcx
8 7 01 122 64 -31 -91
4 c:\grfmaken\grfcodecwin\tutorial\tutorial.pcx
88 7 01 122 64 -31 -91
5 c:\grfmaken\grfcodecwin\tutorial\tutorial.pcx
168 7 01 122 64 -31 -91
6 c:\grfmaken\grfcodecwin\tutorial\tutorial.pcx
248 7 01 122 64 -31 -91
7 * 62 00 04 02 01
00 08 "TUT0" 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 *
25 04 48 FF 01
00 "
ÅBasic station tile" 00
12 * 15 04 48 FF 01
00 "ÄTutorial" 00
13 * 6 01 04 01 FF 04 00
14 c:\grfmaken\grfcodecwin\tutorial\tutorial.pcx
328 7 01 122 64 -31 -91
15 c:\grfmaken\grfcodecwin\tutorial\tutorial.pcx
408 7 01 122 64 -31 -91
16 c:\grfmaken\grfcodecwin\tutorial\tutorial.pcx
488 7 01 122 64 -31 -91
17 c:\grfmaken\grfcodecwin\tutorial\tutorial.pcx
568 7 01 122 64 -31 -91
18 * 62 00 04 02 01
01 08 "TUT0" 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
19 * 7 02 04 00 00 01 00 00
20 * 7 02 04 01 00 01 00 00
21 * 10 03 04 01
01 01 FE 01 00 00 00
22 *
38 04 48 FF 01
01 "
ÅBasic station tile with benches" 00
23 * 6 01 04 01 FF 04 00
24 c:\grfmaken\grfcodecwin\tutorial\tutorial.pcx
648 7 01 122 64 -31 -91
25 c:\grfmaken\grfcodecwin\tutorial\tutorial.pcx
728 7 01 122 64 -31 -91
26 c:\grfmaken\grfcodecwin\tutorial\tutorial.pcx
808 7 01 122 64 -31 -91
27 c:\grfmaken\grfcodecwin\tutorial\tutorial.pcx
888 7 01 122 64 -31 -91
28 * 62 00 04 02 01
02 08 "TUT0" 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
29 * 7 02 04 00 00 01 00 00
30 * 7 02 04 01 00 01 00 00
31 * 10 03 04 01
02 01 FE 01 00 00 00
32 *
40 04 48 FF 01
02 "
ÅBasic station tile with lampposts" 00
Example 2: Let's add another stationclass to the previous code. This time you also have to change the
stationclass ID and it's
description.
// Automatically generated by GRFCODEC. Do not modify!
// (Info version 7)
// Format: spritenum pcxfile xpos ypos compression ysize xsize xrel yrel
0 * 4 2B 00 00 00
1 * 38 08 07 "PJ" 00 00 "Tutorial version 0.0" 00
"By Quast65" 00
2 * 6 01 04 01 FF 04 00
3 c:\grfmaken\grfcodecwin\tutorial\tutorial.pcx 8 7 01 122 64 -31 -91
4 c:\grfmaken\grfcodecwin\tutorial\tutorial.pcx 88 7 01 122 64 -31 -91
5 c:\grfmaken\grfcodecwin\tutorial\tutorial.pcx 168 7 01 122 64 -31 -91
6 c:\grfmaken\grfcodecwin\tutorial\tutorial.pcx 248 7 01 122 64 -31 -91
7 * 62 00 04 02 01 00 08 "TUT0" 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 * 25 04 48 FF 01 00 "ÅBasic station tile" 00
12 * 15 04 48 FF 01 00 "ÄTutorial" 00
13 * 6 01 04 01 FF 04 00
14 c:\grfmaken\grfcodecwin\tutorial\tutorial.pcx 328 7 01 122 64 -31 -91
15 c:\grfmaken\grfcodecwin\tutorial\tutorial.pcx 408 7 01 122 64 -31 -91
16 c:\grfmaken\grfcodecwin\tutorial\tutorial.pcx 488 7 01 122 64 -31 -91
17 c:\grfmaken\grfcodecwin\tutorial\tutorial.pcx 568 7 01 122 64 -31 -91
18 * 62 00 04 02 01 01 08 "TUT0" 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
19 * 7 02 04 00 00 01 00 00
20 * 7 02 04 01 00 01 00 00
21 * 10 03 04 01 01 01 FE 01 00 00 00
22 * 38 04 48 FF 01 01 "ÅBasic station tile with benches" 00
23 * 6 01 04 01 FF 04 00
24 c:\grfmaken\grfcodecwin\tutorial\tutorial.pcx 648 7 01 122 64 -31 -91
25 c:\grfmaken\grfcodecwin\tutorial\tutorial.pcx 728 7 01 122 64 -31 -91
26 c:\grfmaken\grfcodecwin\tutorial\tutorial.pcx 808 7 01 122 64 -31 -91
27 c:\grfmaken\grfcodecwin\tutorial\tutorial.pcx 888 7 01 122 64 -31 -91
28 * 62 00 04 02 01 02 08 "TUT0" 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
29 * 7 02 04 00 00 01 00 00
30 * 7 02 04 01 00 01 00 00
31 * 10 03 04 01 02 01 FE 01 00 00 00
32 * 40 04 48 FF 01 02 "ÅBasic station tile with lampposts" 00
33 * 6 01 04 01 FF 04 00
34 c:\grfmaken\grfcodecwin\tutorial\tutorial.pcx 968 7 01 122 64 -31 -91
35 c:\grfmaken\grfcodecwin\tutorial\tutorial.pcx 1048 7 01 122 64 -31 -91
36 c:\grfmaken\grfcodecwin\tutorial\tutorial.pcx 1128 7 01 122 64 -31 -91
37 c:\grfmaken\grfcodecwin\tutorial\tutorial.pcx 1208 7 01 122 64 -31 -91
38 * 62 00 04 02 01 05 08 "
TUT1" 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
39 * 7 02 04 00 00 01 00 00
40 * 7 02 04 01 00 01 00 00
41 * 10 03 04 01 05 01 FE 01 00 00 00
42 * 35 04 48 FF 01 05 "ÅBasic station tile for cargo" 00
43 * 23 04 48 FF 01 05 "
ÄTutorial extra's" 00
Please note that you can still add stations that are of the first class that we have defined, you can mix them up, that should cause no troubles.
Well that's it, start making graphics and .nfo's!!
And if you want to code them, use GRFcodec. It can be found here:
http://www.openttd.org/en/download-grfcodec Next is how to use GRFcodec