Page 1 of 1
NewGRF help!
Posted: 24 Feb 2008 16:06
by UltimateSephiroth
Hi!
I'm just plunging myself into the world of NewGRFs. However, it doesn't go well. I made the tutorial NewGRF which is in TTDPatch Wiki, but I have problems with my first own project. I wanted to replace the Battery Farm sprite with a recolored one and tried to compile it using the following NFO content:
Code: Select all
// Au c:\grfcodec\sprites\myfirstgrf.pcx 324 12 09 31 64 -31 0
// (Info version 7)
// Format: spritenum pcxfile xpos ypos compression ysize xsize xrel yrel
0 * 4 09 00 00 00
1 * 8 08 06 "TM" 03 05 00 00
2 * 4 01 09 01 04
3 c:\grfcodec\sprites\myfirstgrf.pcx 4 12 09 31 64 -31 0
4 c:\grfcodec\sprites\myfirstgrf.pcx 84 12 09 31 64 -31 0
5 c:\grfcodec\sprites\myfirstgrf.pcx 164 12 09 34 64 -31 -3
6 c:\grfcodec\sprites\myfirstgrf.pcx 244 12 09 38 64 -31 -7
7 * 4 01 09 01 01
8 c:\grfcodec\sprites\myfirstgrf.pcx 324 12 09 31 64 -31 0
9 * 7 00 09 01 01 16 09 87
The compiled GRF does show up in the NewGRF list, but once I start up a new toyland game and try to use it, it only says "Ei käytössä" (Finnish) which translates to something like "Not in use".
Would somebody please help me and point me what I've done wrong.
And if somebody had a link to a good NewGRF tutorial I would gladly like to check it out. I'd say the TTDPatchWiki one is way too small because it explains only that train replacement stuff.
EDIT: Yeah, and move this thread to another forum if it belongs to other one. Please keep it however on the OpenTTD section since it's the only one I'm reading.
Re: NewGRF help!
Posted: 24 Feb 2008 16:13
by mph
not really looked properly but at a glance- you need to use action A instead of action 1 if you are replacing existing sprites rather than making new ones.
Re: NewGRF help!
Posted: 24 Feb 2008 16:18
by DeletedUser5
I can code it. However for battery farm you just need action A. Nfo code should look like that ( just cutted from my grf and editted with your offsets and other things ):
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 06 00 00 00
1 * 45 08 02 "TM" 01 01 "MyFirstGRF v0.1" 00
"MyFirstGRF version 0.1 " 00
2 * 5 0A 01 05 4E 12
3 sprites/myfirstgrf.pcx 4 12 09 31 64 -31 0
4 sprites/myfirstgrf.pcx 84 12 09 31 64 -31 0
5 sprites/myfirstgrf.pcx 164 12 09 34 64 -31 -3
6 sprites/myfirstgrf.pcx 244 12 09 38 64 -31 -7
7 sprites/myfirstgrf.pcx 324 12 09 31 64 -31 0
Re: NewGRF help!
Posted: 24 Feb 2008 16:31
by UltimateSephiroth
Soeb wrote:I can code it. However for battery farm you just need action A. Nfo code should look like that ( just cutted from my grf and editted with your offsets and other things ):
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 06 00 00 00
1 * 45 08 02 "TM" 01 01 "MyFirstGRF v0.1" 00
"MyFirstGRF version 0.1 " 00
2 * 5 0A 01 05 4E 12
3 sprites/myfirstgrf.pcx 4 12 09 31 64 -31 0
4 sprites/myfirstgrf.pcx 84 12 09 31 64 -31 0
5 sprites/myfirstgrf.pcx 164 12 09 34 64 -31 -3
6 sprites/myfirstgrf.pcx 244 12 09 38 64 -31 -7
7 sprites/myfirstgrf.pcx 324 12 09 31 64 -31 0
Hmm... Now it works, but in a REALLY weird manner... Check the attached files.
And the output of the compiler doesn't look good either.
Code: Select all
C:\grfcodec>grfcodec -e myfirstgrf.grf
GRFCodec version 0.9.10 - Copyright (C) 2000-2005 by Josef Drexler
Encoding in temporary file myfirstgrf.new
Warning: Sprite 1 reports 45 bytes, but I found 46.
Warning: Found 1 more sprites than sprite 0 reports.y:100%, Redundancy:100%)
Loading sprites/myfirstgrf.pcxssed:100% (Transparency:100%, Redundancy:100%)
Sprite 7 Done: 87% Compressed: 31% (Transparency: 69%, Redundancy: 44%)
Deleting myfirstgrf.grf
Replacing myfirstgrf.grf with myfirstgrf.new
Done!
Also, could you explain a bit more what these rows exactly mean so I'd understand the system better.
Attachments: screen with the buggy NewGRF and the PCX file I'm using, if the problem is caused by it.
Re: NewGRF help!
Posted: 24 Feb 2008 16:37
by LordAzamath
There are total 7 sprites in the file so sprite 0 has to be 0 * 04 07 00 00 00
And there are total 46 bytes in sprite 1 not 45. 'To get the values correct automatically, use nforenum.
And for the weirdness.. the pcx dimensions should be multiple of 4s.. your's is 397*58, try 400*60

Re: NewGRF help!
Posted: 24 Feb 2008 16:49
by DeletedUser5
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 07 00 00 00 // you should know what first 2 sprites mean from tutorial on ttdpatch wiki
1 * 46 08 02 "TM" 01 01 "MyFirstGRF v0.1" 00
"MyFirstGRF version 0.1 " 00
2 * 5 0A 01 05 4E 12 //action A to replace existing sprites - more info on ttdpatch wiki
3 sprites/myfirstgrf.pcx 4 12 09 31 64 -31 0
4 sprites/myfirstgrf.pcx 84 12 09 31 64 -31 0
5 sprites/myfirstgrf.pcx 164 12 09 34 64 -31 -3
6 sprites/myfirstgrf.pcx 244 12 09 38 64 -31 -7
7 sprites/myfirstgrf.pcx 324 12 09 31 64 -31 0
You should understand everything. I'm not good in explaining so you should ask somebody else.
LordAzamath: My fault. I counted bytes wrong in sprite 1 and I copied beginning from other grf. But grfcodec corrects bytes in sprite 1, so it isn't any problem. And not 0 * 04 but 0 * 4.
Re: NewGRF help!
Posted: 24 Feb 2008 16:54
by UltimateSephiroth
Thank you to everyone, now it works perfectly. And now I understand the NFO file contents way better than before. It may be, though, that I'll keep just replacing sprites for now, but maybe I'll try to study the other Actions when I have more time
