My First Grf (Action 2/3 question)

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
User avatar
cornelius
Director
Director
Posts: 519
Joined: 04 Jan 2004 22:11

My First Grf (Action 2/3 question)

Post by cornelius » 07 Sep 2004 19:29

I've decided I want to "get" NFO coding, so I've started fiddling around with my first .grf. I followed the tutorial on the wiki and managed to replace the UU 37 with more real looking, green Class 37. I even extended that work a bit by specifying the real name for the engine and changing its stats around a bit. This all worked fine.

Now, I want to add a second livery (large logo blue) to appear later on in time. As I understand it, I need to declare:

1 x action 2 for each set of sprites (green and blue)
1 x action 2 for the years each set is valid

1 x action 3 to connect the new vehicle to an existing slot
1 x action 3 for each livery to connect the set IDs to the slot

Making a total of four action 2s and three action 3s. Am I barking up the right tree here, or have I written down a load of essentially random bytes in an attempt to make it look like I know what I'm doing? Any help much appreciated!

Code: Select all

// Automatically generated by GRFCODEC. Do not modify!
// (Info version 4)
// Format: spritenum pcxfile xpos ypos compression ysize xsize xrel yrel

// first pseudosprite
    0 * 4 0f 00 00 00
// action 8 - 20 bytes - sf 37 - Class 37
    1 * 15 08 06 73 66 03 07 43 6c 61 73 73 20 33 37 00
// action 1 - train - two sets of gfx - 4 views
    2 * 4 01 00 02 04
// the sprites - BR green
    3 C:\MPS\TTD alpha\newgrf\SPRITES\mytrain.pcx 66 8 01 18 8 -3 -10
    4 C:\MPS\TTD alpha\newgrf\SPRITES\mytrain.pcx 82 8 09 15 20 -14 -6
    5 C:\MPS\TTD alpha\newgrf\SPRITES\mytrain.pcx 114 8 01 12 28 -14 -6
    6 C:\MPS\TTD alpha\newgrf\SPRITES\mytrain.pcx 162 8 09 15 20 -4 -7
// the sprites - BR large logo blue
    7 C:\MPS\TTD alpha\newgrf\SPRITES\mytrain.pcx 193 8 01 18 8 -3 -10
    8 C:\MPS\TTD alpha\newgrf\SPRITES\mytrain.pcx 209 8 09 15 20 -14 -6
    9 C:\MPS\TTD alpha\newgrf\SPRITES\mytrain.pcx 241 8 01 12 28 -14 -6
   10 C:\MPS\TTD alpha\newgrf\SPRITES\mytrain.pcx 289 8 09 15 20 -4 -7
// 7 - action 2 - train - cargo 0 - one set for moving - one set for loading - use first in both cases
// 8 - action 2 - train - cargo 1 - one set for moving - one set for loading - use second in both cases
    7 * 9 02 00 00 01 01 00 00 00 00
    8 * 9 02 00 01 01 01 01 00 01 00

    9 * 14 02 00 10 81 01 00 ff 01 00 00 27 41 00 00
   10 * 14 02 00 11 81 01 00 ff 01 01 00 42 ff 01 00

// action 3 - train - one vehicles - replaces UU 37 - no special graphics - cargo 0
// 11 * 7 03 00 01 0e 00 00 00

   11 * 10 03 00 01 0e 01 FF 00 00 00 00
   12 * 8 03 00 01 0e 00 00 00 00
   13 * 8 03 00 01 0e 01 00 01 00

// action 0 - train - one property - one vehicle - starting at UU 37
// set prop 0 (intro date to 96 37 - 1959) prop 9 (speed to 80 00 - 128kmh) 
// prop 0b (power to d6 06 - 1750hp) prop 12 (sprite type to FD - new graphics) 
   14 * 16 00 00 04 01 0e 00 96 37 09 80 00 0b d6 06 12 FD
// action 4 - train - english - 1 string - starting at UU 37 - 'BR Type 3 Class 37 (Diesel)'
   15 * 33 04 00 02 01 0e 42 52 20 54 79 70 65 20 33 20 43 6c 61 73 73 20 33 37 20 28 44 69 65 73 65 6c 29 00
Last edited by cornelius on 08 Sep 2004 17:37, edited 1 time in total.

Patchman
Tycoon
Tycoon
Posts: 5552
Joined: 02 Oct 2002 18:57
Location: Ithaca, New York
Contact:

Re: Action 2/3 question

Post by Patchman » 07 Sep 2004 19:36

cornelius wrote:1 x action 3 to connect the new vehicle to an existing slot
1 x action 3 for each livery to connect the set IDs to the slot
You can only have one action 3 for each vehicle. You don't choose between the liveries in the action 3, but instead in a variational or random action 2 (depending on what you want).

So you'd have

action 2 (green)
action 2 (blue)
variational action 2
action 3 set to use the variational action 2

User avatar
cornelius
Director
Director
Posts: 519
Joined: 04 Jan 2004 22:11

Re: Action 2/3 question

Post by cornelius » 08 Sep 2004 01:29

edit: to restore the entire post
Patchman wrote:You can only have one action 3 for each vehicle. You don't choose between the liveries in the action 3, but instead in a variational or random action 2 (depending on what you want).

So you'd have

action 2 (green)
action 2 (blue)
variational action 2
action 3 set to use the variational action 2
Okay that makes sense.

So now I have this, where I hoped that the variational action 2 would saying "my set-id is 10, use sprite set 0 if the year is between 0 and 60 after 1920, use sprite set 1 if the year is 61 - 120 years after 1920, otherwise use set 0 again".

The action 3 should then be using set-id 10 with FF set to show it in the purchase list (if I set the action 3 to set-id 01 instead it picks up the blue livery).

I'm guessing it's a dodgy variational action 2?

Thanks for your help - if I get to the bottom of this I'll write up a tutorial for the wiki.

Code: Select all

   11 * 9 02 00 00 01 01 00 00 00 00
   12 * 9 02 00 01 01 01 01 00 01 00

   13 * 18 02 00 10 81 01 00 00 02 00 00 00 3c 01 00 3d 82 00 00

   14 * 10 03 00 01 0e 01 FF 10 00 00 00

Patchman
Tycoon
Tycoon
Posts: 5552
Joined: 02 Oct 2002 18:57
Location: Ithaca, New York
Contact:

Post by Patchman » 08 Sep 2004 04:24

Almost got it, I think. This line:

Code: Select all

13 * 18 02 00 10 81 01 00 00 02 00 00 00 3c 01 00 3d 82 00 00 
should be

Code: Select all

13 * 18 02 00 10 81 01 00 FF 02 00 00 00 3c 01 00 3d 82 00 00 
The "FF" there is the bit mask, if you set it to 0 you clear all the bits in the value and always get 0.

User avatar
cornelius
Director
Director
Posts: 519
Joined: 04 Jan 2004 22:11

Post by cornelius » 08 Sep 2004 08:05

Fantastic! The action 3 needed a bit of tweaking too but it's working fine now. Thanks :)

User avatar
Oracle
Tycoon
Tycoon
Posts: 2138
Joined: 22 May 2003 09:59

Post by Oracle » 08 Sep 2004 15:06

I would recommend changing this:

Code: Select all

13 * 18 02 00 10 81 01 00 FF 02 00 00 00 3c 01 00 3d 82 00 00
to this:

Code: Select all

13 * 14 02 00 10 81 01 00 FF 01 01 00 3d 82 00 00
They both work perfectly but the latter is just a touch more efficient (and I'd say more readable too).

User avatar
cornelius
Director
Director
Posts: 519
Joined: 04 Jan 2004 22:11

Post by cornelius » 08 Sep 2004 17:36

Oracle wrote:They both work perfectly but the latter is just a touch more efficient (and I'd say more readable too).
Yep that makes sense. It also seems to make pre-1980 locos keep their green livery, which I'd been trying to work out how to do ;)

So here it is: My First Grf. It contains a class 37 in two liveries, replacing TTD's UU 37. I haven't tested it with any other sets, and the graphics aren't accurate - just enough to see the test working - but I'm dead chuffed.
Attachments
class37.zip
Windows version
(1.38 KiB) Downloaded 116 times
class37.png
BR green and Large Logo blue (actually I think it might be Scotrail with the dog on the side?)
class37.png (19.15 KiB) Viewed 2197 times

Post Reply

Return to “Graphics Development”

Who is online

Users browsing this forum: No registered users and 10 guests