NewGRF help!

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
UltimateSephiroth
Engineer
Engineer
Posts: 5
Joined: 29 Jan 2008 17:53

NewGRF help!

Post 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.
User avatar
mph
Engineer
Engineer
Posts: 124
Joined: 24 Aug 2007 20:47

Re: NewGRF help!

Post 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.
previously known as daylight
User avatar
DeletedUser5
Transport Coordinator
Transport Coordinator
Posts: 277
Joined: 07 Oct 2007 15:10

Re: NewGRF help!

Post 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
UltimateSephiroth
Engineer
Engineer
Posts: 5
Joined: 29 Jan 2008 17:53

Re: NewGRF help!

Post 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.
Attachments
weirdscreen.png
(320.85 KiB) Downloaded 93 times
myfirstgrf.pcx
(6.77 KiB) Downloaded 138 times
LordAzamath
Tycoon
Tycoon
Posts: 1656
Joined: 08 Jun 2007 08:00

Re: NewGRF help!

Post 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 :)
PS: And I stopped the propaganda to support Dave Worley since he got a nice new red hat now.[/color]
I know I have a BBCode error in my signature but I really cba to fix it.
User avatar
DeletedUser5
Transport Coordinator
Transport Coordinator
Posts: 277
Joined: 07 Oct 2007 15:10

Re: NewGRF help!

Post 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.
UltimateSephiroth
Engineer
Engineer
Posts: 5
Joined: 29 Jan 2008 17:53

Re: NewGRF help!

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

Return to “Graphics Development”

Who is online

Users browsing this forum: Ahrefs [Bot], Amazon [Bot] and 16 guests