Editing GRF

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
wozzar
Transport Coordinator
Transport Coordinator
Posts: 330
Joined: 27 Dec 2002 09:25

Editing GRF

Post by wozzar »

How can i edit GRF files to change the parameter of some vehicles like speed and capacity.
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Post by DaleStan »

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
mr.kreezie
Engineer
Engineer
Posts: 22
Joined: 08 Aug 2007 15:35

Re: Editing GRF

Post by mr.kreezie »

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

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
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
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Re: Editing GRF

Post by DaleStan »

Did you read the tutorial?
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
mr.kreezie
Engineer
Engineer
Posts: 22
Joined: 08 Aug 2007 15:35

Re: Editing GRF

Post by mr.kreezie »

I got stuck at adding the psuedo things...
It doenst quite say how just to replace an existing tile easily
User avatar
FooBar
Tycoon
Tycoon
Posts: 6553
Joined: 21 May 2007 11:47
Location: The Netherlands
Contact:

Re: Editing GRF

Post by FooBar »

mr.kreezie wrote:It doenst quite say how just to replace an existing tile easily
Actually, it does. The thing your looking for is called an Action A.

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.
mr.kreezie
Engineer
Engineer
Posts: 22
Joined: 08 Aug 2007 15:35

Re: Editing GRF

Post by mr.kreezie »

Ok added the first sprites which tells to replace somewhat..
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
what am i doing wrong?

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.
User avatar
Maedhros
OpenTTD Developer
OpenTTD Developer
Posts: 603
Joined: 30 Mar 2006 18:24
Location: Durham, UK

Re: Editing GRF

Post by Maedhros »

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:

Code: Select all

// Header
1 * 1   08 06 <grfid> "<name>" 00 "<description>" 00
1 * 1   0A 01 01 2A 10
1 * <real sprite>
You'll either need to run that through nforenum, or work out the sprite numbers and lengths manually.
No-one's more important than the earthworm.
mr.kreezie
Engineer
Engineer
Posts: 22
Joined: 08 Aug 2007 15:35

Re: Editing GRF

Post by mr.kreezie »

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:

Code: Select all

// Header
1 * 1   08 06 <grfid> "<name>" 00 "<description>" 00
1 * 1   0A 01 01 2A 10
1 * <real sprite>
You'll either need to run that through nforenum, or work out the sprite numbers and lengths manually.
Can you give me like an example of how the NFO should look like (with some info what the numbers mean a bit)
and the number of the sprite is eighter 4183 or 4184 (different in PCX and WinGRF)
User avatar
Maedhros
OpenTTD Developer
OpenTTD Developer
Posts: 603
Joined: 30 Mar 2006 18:24
Location: Durham, UK

Re: Editing GRF

Post by Maedhros »

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.
mr.kreezie
Engineer
Engineer
Posts: 22
Joined: 08 Aug 2007 15:35

Re: Editing GRF

Post by mr.kreezie »

this is what i have but cant encode this can i?

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
EDIT:

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
But still doesnt work
User avatar
FooBar
Tycoon
Tycoon
Posts: 6553
Joined: 21 May 2007 11:47
Location: The Netherlands
Contact:

Re: Editing GRF

Post by FooBar »

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:

Code: Select all

-1 * 0    08 06 01 01 01 01 "name" 00 "description" 00
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:

Code: Select all

-1 sprites/grass.pcx 18 8 09 31 64 -31 0
Now let's put everything together. After the default comments, we add a special sprite (sprite 0) to indicate the GRF's length:

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
mr.kreezie
Engineer
Engineer
Posts: 22
Joined: 08 Aug 2007 15:35

Re: Editing GRF

Post by mr.kreezie »

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 :P
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 :P
User avatar
FooBar
Tycoon
Tycoon
Posts: 6553
Joined: 21 May 2007 11:47
Location: The Netherlands
Contact:

Re: Editing GRF

Post by FooBar »

mr.kreezie wrote:The HEX was 1057 but need to change that to 57 10
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.

Don't forget to share your graphics with us when they're done!
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Re: Editing GRF

Post by DaleStan »

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 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
Post Reply

Return to “Graphics Development”

Who is online

Users browsing this forum: Google [Bot], Semrush [Bot] and 19 guests