Page 1 of 1
Editing GRF
Posted: 17 Jan 2007 00:54
by wozzar
How can i edit GRF files to change the parameter of some vehicles like speed and capacity.
Posted: 17 Jan 2007 03:56
by DaleStan
By following
the directions.
Re: Editing GRF
Posted: 16 Aug 2007 15:59
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
Re: Editing GRF
Posted: 16 Aug 2007 16:14
by DaleStan
Did you read the tutorial?
If not, do so.
If so, which is the first sentence that you did not understand?
Re: Editing GRF
Posted: 16 Aug 2007 16:24
by mr.kreezie
I got stuck at adding the psuedo things...
It doenst quite say how just to replace an existing tile easily
Re: Editing GRF
Posted: 16 Aug 2007 16:35
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.
Re: Editing GRF
Posted: 16 Aug 2007 16:52
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)
Re: Editing GRF
Posted: 16 Aug 2007 16:58
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.
Re: Editing GRF
Posted: 16 Aug 2007 17:01
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)
Re: Editing GRF
Posted: 16 Aug 2007 17:07
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.
Re: Editing GRF
Posted: 16 Aug 2007 17:11
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
Re: Editing GRF
Posted: 16 Aug 2007 17:56
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
Re: Editing GRF
Posted: 16 Aug 2007 18:07
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

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

Re: Editing GRF
Posted: 16 Aug 2007 18:50
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!
Re: Editing GRF
Posted: 16 Aug 2007 20:43
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.