Articulated train callback?

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
MarkyParky
Engineer
Engineer
Posts: 89
Joined: 20 Nov 2003 15:20

Articulated train callback?

Post by MarkyParky »

Hello,

I have some difficulties to understand all the callback staff, as documentation is great when you now whad you are searching for, but very hard to learn from scratch ;) and when I am looking to some already made GRFs, they contains too many callback features, that it is also confusing for me.

I have two sets of sprites each assigned different CID. Now I want to make a train unit consisting of two wagons (using thos sprites) that you can buy at once. I studied HiroTrams and some other threads on this forum, and I have following code, still it is not working due some misunderstanding and I am not abel to figure it out.

Code: Select all

//Two sets of sprites
  19 * 09  02 00 AA 01 01 00 00 00 00
  20 * 09  02 00 BB 01 01 01 00 01 00
//Use set AA for first car and set BB for second
  21 * 18  02 00 01 81 40 80 FF 00 00 02 AA 00 00 00 BB 00 01 01
//Callback to attach one more vehicle 
  22 * 12  02 00 02 81 10 00 FF 01 40 80 01 FF
//If callback is 16, goto 0002 else goto 0001
  23 * 13  02 00 00 81 0C 00 FF 02 00 16 16 01 00
//Set some train properties, including callback bit for articulated train.
  24  * 40	 00 00 0E 01 40 00 00 00 03 50 04 50 05 02 06 07 09 50 00 0B 70 00 12 FD 14 4B 15 00 16 0C 17 10 19 02 1E 10 21 02 22 40 
//Start loading by goto 0000.
  25 * 07	 03 00 01 40 00 00 00
User avatar
FooBar
Tycoon
Tycoon
Posts: 6553
Joined: 21 May 2007 11:47
Location: The Netherlands
Contact:

Post by FooBar »

Have you noticed this thread: http://www.tt-forums.net/viewtopic.php?t=32628
I had some similar problems and maybe the answers given there helps you to solve your problem.
MarkyParky
Engineer
Engineer
Posts: 89
Joined: 20 Nov 2003 15:20

Post by MarkyParky »

Yes, I have noticed it. I would even say, that most of my present knowledge comes out of this thread. Still I dont understand certain values and also the syntax seems a bit confusing to me still. Also they are not explaining there some basic stuff that is already clear to them, but not yet to me ;)
michael blunck
Tycoon
Tycoon
Posts: 5954
Joined: 27 Apr 2005 07:09
Contact:

Post by michael blunck »

There are a lot of bugs in your program. Please check this carefully and read again the Wiki docs:

Code: Select all

// action 08 goes here ...

// action 00: train properties
   1 * 40    00 00 10 01 40         // veh-ID = 40
		00 00 00 // intro date 1921
		03 50 	// vehicle life span
		04 50 	// model life span
		05 02 	// maglev
		06 07 	// all climates
		09 50 00 // speed 80 km/h
		0B 70 00 // power 112 hp
		12 FD 	// new graphics
		14 4B 	// capacity 75t
		15 00 	// passengers
		16 0C 	// weight 12t
		17 10 	// price factor
		19 02 	// steam engine effects
		1E 10 	// CBs: articulated
		21 02 	// vehicle shortening: 25%
		22 40 	// no power, no effects

// action 01 sprite block(s) go here ...

// Two sets of sprites 
   2 * 9  02 00 AA 01 01 00 00 00 00	// first veh 
   3 * 9  02 00 BB 01 01 01 00 01 00   // second veh

// Use set AA for first veh and set BB for second 
   4 * 14  02 00 00 81 40 10 FF 01 
		AA 00 00 00	// first veh 
		BB 00 		  // all other
		
// articulated: (40) - 40
   5 * 14  02 00 01 81 10 00 FF 01 
		40 80 01 01   // first additional veh = veh-ID 40 
		FF FF 	     // that´s all

// check for CBs
   6 * 14  02 00 02 81 0C 00 FF 01
		01 00 16 16   // CB 16: articulated
		00 00	      // graphics

// action 03
   7 * 7    03 00 01 40 00 02 00

// action 04 (name) - will go here ...
Structure and comment your programs, that will help.

BTW, some of your action0 properties make no sense in this context.

BTW2, if there are more questions please discuss that in the TTDPatch graohics forum. Most .grf developers read there.

HTH
regards
Michael
Image
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5631
Joined: 13 Sep 2004 13:21
Location: The Moon

Post by PikkaBird »

And get yourself a copy of NFORenum (from Dalestan's signature), it's extremely useful for working out where your NFO is going wrong.
MarkyParky
Engineer
Engineer
Posts: 89
Joined: 20 Nov 2003 15:20

Post by MarkyParky »

Thank you very much Michal,

from the way you structure the code I finaly do understand the way callbacks works ;). I spend checking wiki last two weeks ;), but I understand some things just now, as you corrected my code and I can see the difference.
Post Reply

Return to “Graphics Development”

Who is online

Users browsing this forum: Ahrefs [Bot] and 23 guests