Editing GRF
Moderator: Graphics Moderators
Editing GRF
How can i edit GRF files to change the parameter of some vehicles like speed and capacity.
By following the directions.
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
-
- Engineer
- Posts: 22
- Joined: 08 Aug 2007 15:35
Re: Editing GRF
Ok hi,
Since every is so busy making openTTD better, i was thinking of helping a little bit.
Im trying to replace a tile from openttd (a simple one (just testing) from a farm.
Now i've got it so far that i've actually got the pcx converted to grf
so... Ive got the nfo
Ive got the PCX and ive got the GRF
but i still dont understand how i can get it to work in openTTD.
I've looked at the site posted above, but dont understand the action things... A lot of numbers and text which dont quite tell me how to get it to work.
Any help is welcome
thanks
Since every is so busy making openTTD better, i was thinking of helping a little bit.
Im trying to replace a tile from openttd (a simple one (just testing) from a farm.
Now i've got it so far that i've actually got the pcx converted to grf
so... Ive got the nfo
Code: Select all
// Automatically generated by GRFCODEC. Do not modify!
// (Info version 7)
// Format: spritenum pcxfile xpos ypos compression ysize xsize xrel yrel
0 sprites/grass.pcx 18 8 09 31 64 -31 0
but i still dont understand how i can get it to work in openTTD.
I've looked at the site posted above, but dont understand the action things... A lot of numbers and text which dont quite tell me how to get it to work.
Any help is welcome

thanks
Re: Editing GRF
Did you read the tutorial?
If not, do so.
If so, which is the first sentence that you did not understand?
If not, do so.
If so, which is the first sentence that you did not understand?
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
-
- Engineer
- Posts: 22
- Joined: 08 Aug 2007 15:35
Re: Editing GRF
I got stuck at adding the psuedo things...
It doenst quite say how just to replace an existing tile easily
It doenst quite say how just to replace an existing tile easily
Re: Editing GRF
Actually, it does. The thing your looking for is called an Action A.mr.kreezie wrote:It doenst quite say how just to replace an existing tile easily
Also, have a look at this section to learn how to add the first special pseudosprite and a GRFID.
Furthermore, there are two types of sprites: real sprites and pseudosprites. Real sprites define an actual image and how it should be positioned in the game. Pseudosprites define what the game should do with a real sprite you provided, and set numerous other properties.
-
- Engineer
- Posts: 22
- Joined: 08 Aug 2007 15:35
Re: Editing GRF
Ok added the first sprites which tells to replace somewhat..
but now it doesnt show in my openTTD grf list
what am i doing wrong?
edit: The image Im trying to replace is #4183 in the trg1r.grf file (or #4184 in WinGRF)
but now it doesnt show in my openTTD grf list
Code: Select all
Like shown in WinGRF:
1 New GRF Header <automatically generated
2 Action7 54 65 73 74 69 6E 67 20 4D 72 2E 4B 72 65 65 5A 69 65
3 ActionA 01 01 34 31 38 33
4 The image
edit: The image Im trying to replace is #4183 in the trg1r.grf file (or #4184 in WinGRF)
Last edited by mr.kreezie on 16 Aug 2007 16:59, edited 1 time in total.
Re: Editing GRF
It's not showing up because you don't have an Action 8. You do have a very strange looking action 7 though, and your action A doesn't appear to refer to sprite #4138 at all. Try something like this:
You'll either need to run that through nforenum, or work out the sprite numbers and lengths manually.
Code: Select all
// Header
1 * 1 08 06 <grfid> "<name>" 00 "<description>" 00
1 * 1 0A 01 01 2A 10
1 * <real sprite>
No-one's more important than the earthworm.
-
- Engineer
- Posts: 22
- Joined: 08 Aug 2007 15:35
Re: Editing GRF
Can you give me like an example of how the NFO should look like (with some info what the numbers mean a bit)Maedhros wrote:It's not showing up because you don't have an Action 8. You do have a very strange looking action 7 though, and your action A doesn't appear to refer to sprite #4138 at all. Try something like this:
You'll either need to run that through nforenum, or work out the sprite numbers and lengths manually.Code: Select all
// Header 1 * 1 08 06 <grfid> "<name>" 00 "<description>" 00 1 * 1 0A 01 01 2A 10 1 * <real sprite>
and the number of the sprite is eighter 4183 or 4184 (different in PCX and WinGRF)
Re: Editing GRF
That is what the nfo should look like. Just replace the bits in angle brackets. 4138 becomes 0x102A in hexadecimal, or 2A 01 in little endian. I have no idea what WinGRF is, but the pcx file is far more likely to be right.
No-one's more important than the earthworm.
-
- Engineer
- Posts: 22
- Joined: 08 Aug 2007 15:35
Re: Editing GRF
this is what i have but cant encode this can i?
EDIT:
I've got this now:
But still doesnt work
Code: Select all
1 * 1 08 06 01 "test" 00 "just a test" 00
1 * 1 0A 01 01 2A 01
1 * sprites/grass.pcx
I've got this now:
Code: Select all
// Automatically generated by GRFCODEC. Do not modify!
// (Info version 7)
// Format: spritenum pcxfile xpos ypos compression ysize xsize xrel yrel
0 * 5 0A 01 0C 10 57
1 * 43 08 05 54 57 01 06 20 54 75 74 6F 72 69 61 6C 20 65 78 61 6D 70 6C 65 00 20 43 6F 70 79 72 69 67 68 74 3A 20 53 79 73 74 65 6D 00
2 sprites/grass.pcx 18 8 09 31 64 -31 0
Re: Editing GRF
Well, you probably can encode it, but I'm pretty sure it won't work.
First of all, the Action8. The GRFID is a four-byte value, not a single byte. You'll end up with something like this:
With 01 01 01 01 as the GRFID.
Your ActionA seems right, so don't bugger about with that.
After the ActionA a real sprite should follow. Something you put there, but it needs a bit more:
Now let's put everything together. After the default comments, we add a special sprite (sprite 0) to indicate the GRF's length:
First of all, the Action8. The GRFID is a four-byte value, not a single byte. You'll end up with something like this:
Code: Select all
-1 * 0 08 06 01 01 01 01 "name" 00 "description" 00
Your ActionA seems right, so don't bugger about with that.
After the ActionA a real sprite should follow. Something you put there, but it needs a bit more:
Code: Select all
-1 sprites/grass.pcx 18 8 09 31 64 -31 0
Code: Select all
// Automatically generated by GRFCODEC. Do not modify!
// (Info version 6)
// Format: spritenum pcxfile xpos ypos compression ysize xsize xrel yrel
0 * 4 03 00 00 00
1 * 16 08 06 01 01 01 01 "name" 00 "desc" 00
2 * 5 0A 01 01 2A 01
3 sprites/grass.pcx 18 8 09 31 64 -31 0
-
- Engineer
- Posts: 22
- Joined: 08 Aug 2007 15:35
Re: Editing GRF
Ok its working now.. but it doesnt seem to replace the right sprite...
The Sprite number is in the exported PCX number 4183.
Got it working now
The HEX was 1057 but need to change that to 57 10
Thnx for all the help guys!!!
now im gonna make some nice graphics 
The Sprite number is in the exported PCX number 4183.
Got it working now

The HEX was 1057 but need to change that to 57 10
Thnx for all the help guys!!!


Re: Editing GRF
That's called 'little-endian byte order'. Start getting used to it because it's required for all word and dword values. You can read more about it here.mr.kreezie wrote:The HEX was 1057 but need to change that to 57 10
Don't forget to share your graphics with us when they're done!
Re: Editing GRF
Or you can just type \w4183 and let grfcodec do the grunt work.
\ to indicate something that isn't bog-standard hex bytes,
w because you need an arbitrary word-sized value, and
4183 because that's the decimal representation of the value you want.
\ to indicate something that isn't bog-standard hex bytes,
w because you need an arbitrary word-sized value, and
4183 because that's the decimal representation of the value you want.
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
Who is online
Users browsing this forum: No registered users and 20 guests