trying to obtain coding skills - anyone i can ask?

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

User avatar
DJ Nekkid
Tycoon
Tycoon
Posts: 2141
Joined: 30 Nov 2006 20:33

Re: trying to obtain coding skills - anyone i can ask?

Post by DJ Nekkid »

it seems like i had an error in the post, but it was correct in the code...

the purchase sprite is A0, not AC, AC is the last of thoose Var2's, that give the engine's proper directional sprites (mainly an active panto and/or red/yellow headlights)
Member of the
ImageImage
User avatar
Zephyris
Tycoon
Tycoon
Posts: 2897
Joined: 16 May 2007 16:59

Re: trying to obtain coding skills - anyone i can ask?

Post by Zephyris »

I think this is what it should be...

Code: Select all

eight real sprite Action 1's plus one for the purchase list
nine action 2's;
AA = Engine forward direction
A0 = Purchase list sprite
AB = Engine reverse direction
B0 = Middle PAX wagon
B1 = First PAX Wagon
B2 = Last PAX Wagon
C0 = Middle Mail Wagon
C1 = First Mail Wagon
C2 = Last Mail Wagon

// VarAction2: MAIL
-1 * 0 02 00 C3 81 40 08 FF 01 C2 00 01 01 C0 00
-1 * 0 02 00 C4 81 40 00 FF 01 C1 00 01 01 C3 00

// VarAction2: Pax
-1 * 0 02 00 B3 81 40 08 FF 01 B2 00 01 01 B0 00
-1 * 0 02 00 B4 81 40 00 FF 01 B1 00 01 01 B3 00

// VarAction2: Panto at the Back
-1 * 0 02 00 AC 81 40 08 FF 01 AA 00 00 00 AB 00

// Action 3:
-1 * 0 03 00 01 46 01 FF A0 00 AC 00
-1 * 0 03 00 81 5B 00 B4 00
-1 * 0 03 00 81 5F 00 C4 00
The variable 40, Position in consist and length of consist, would take the following value for a carriage in position 2 of a 6 carriage long train:

Code: Select all

 00 05  04 01 
(00 nn bb ff)
If you want to use only the bb value, the position counting from the rear of the train you need to do the following:

Code: Select all

-1 * 0
02 // action2
00 // feature 00 (trains)
B3 // action2 id B3
81 // type 81 (general variable, access the lowest byte only) ***
40 // variable 40 (position in and length of consist) ***
    08 // varadjust 08 (shift variable 8 bits to the right and use and mask ***
    FF // and mask FF (use all bits) ***
01 // number of ranges 01 (1 range)
B2 00 // action2 id for first range
    01 // range 1 lower bound
    01 // range 1 upper bound
B0 00 // default action2 id
The *** steps do the following modifications to the value of variable 40:

Code: Select all

00 05 04 01 // variable 40
01 // lowest byte (ff)
04 // shift 8 bits/1 byte to the right (bb)
04 // and mask
User avatar
Paxinum
Engineer
Engineer
Posts: 12
Joined: 15 Mar 2006 18:15
Location: Sweden

Re: trying to obtain coding skills - anyone i can ask?

Post by Paxinum »

Well, a little off topic (or not), but try to improve the wiki while you learn and gather info on other places / from people
will help others that might want to learn code.

(Me myself is considering to learn a little about it, but I have too much to do IRL right now :cry: )
"Last night, I laid on my back in my bed, staring at the stars above, and wondered; where the heck is the roof?"
Post Reply

Return to “Graphics Development”

Who is online

Users browsing this forum: No registered users and 18 guests