Page 1 of 2

Coding Troubles, Test GRF of the train has been released

Posted: 29 Dec 2005 16:35
by Villem
Alright i read the .nfo coding tutorials and i tried to code a vehicle i had drawn, but i hit a snag.

after i encoded the file, TTDPatch says the file has more sprites than specified.. But i have 1 set of sprites that consists of 8 sprites, and so is specified in the nfo file(ignore the offsets for now, i haven't touched them yeat).

What exactly is wrong with the code, besides the obivius wrong offsets?

[EDIT]See http://www.tt-forums.net/viewtopic.php?p=388922#388922 for the GRF.

Posted: 29 Dec 2005 17:14
by PikkaBird
It means more sprites than specified in sprite 0 (you have specified 0 sprites).

Try running the nfo through nforenum. :)

Posted: 29 Dec 2005 17:28
by Villem
Ah yes, that worked. Thanks Pikka.
Now i need to sort out the palette problem my graphics seem to be having..

[edit]ok i sorted out palette problems.

Posted: 29 Dec 2005 18:12
by jvassie
success then? screenies! :D

James

Posted: 29 Dec 2005 18:21
by Villem
First view with correct offsets, though the train is going the wrong way..
and i still need to make it doubleheaded..
The Train is the Russian 2TE10U(usually its doubleheaded but the 2 head's can be seperated). Its quite a monster at pulling heavy freight trains. :)

[edit] im gona proceed and bang my head on the table cause i don't get what is wrong with my speed & power action 0's, but according to nforenum and ttdpatch theres something wrong with them

//!!Warning (99): Offset 8: No more data was expected.
14 * 11 00 00 01 01 13 09 31 30 30 12 FD
//!!Warning (99): Offset 8: No more data was expected.
15 * 12 00 00 01 01 13 0B 35 39 30 30 12 FD

Posted: 29 Dec 2005 21:48
by Flamelord
I had the same problem awhile ago. I think that you've only told it to change one property, then tried to change more than one. I bet if you review the beginning of those action 0s you'll find that this is true.

Posted: 29 Dec 2005 21:50
by Villem
They both are told to change one property, and they only change one property.

Line 14 defines speed, while line 15 defines power. Neither do define anything else.

Posted: 29 Dec 2005 21:52
by Flamelord
Then I must be very confused. Sorry about that; my inexperience coding NFOs is showing through again. :oops:

Posted: 29 Dec 2005 22:00
by Villem
Ok i fixed the no more data was expected, but now it complains about invalid property 30..

and in this case, number 30 is part of the value in speed & power adjustments, i don't know why nforenum thinks its a property.

Posted: 29 Dec 2005 22:05
by OzTrans
Why make it complicated ...

a) change all properties for 1 vehicle in the same sprite :

Code: Select all

-1 * 11     00 00 03 01 13 09 31 0B 35 39 12 FD
b) now what else was wrong :

. there is no property 30, at least until today.
. power is a word, i.e. it is 2 bytes long, unless that 30 30 was that new property.

Posted: 29 Dec 2005 22:06
by Villem
well, str2hex brings 100 in hex as 31 30 30
and 5900 in hex as 35 39 30 30

But your solution fixed it, thanks.
Though, now my train can go 3,614mp/h and has 14,645hp of power :O

and i changed them seperately so i don't get confused with the code, im only starting out.

Posted: 29 Dec 2005 22:16
by OzTrans
Well, 100 km/h is 64h and 5900 hp is 0Ch 17h (in little endian).

If you want to define those properties seperately, that's ok; but now your code should then look as follows :

Code: Select all

-1 * 7      00 00 01 01 13 12 FD
-1 * 8      00 00 01 01 13 09 64 00
-1 * 8      00 00 01 01 13 0B 0C 17
Just keep going and you'll soon get the hang of it.

EDIT: corrected that property 09 code.

Posted: 29 Dec 2005 22:17
by Villem
ah so, str2hex gives incorrect numbers, thanks for the help. :]
but nforenum doesn't like that you gave only 64 for the value in speed, it would want 1 more byte set(so i added 00 after it and it accepted it and values are right ingame)..

Posted: 29 Dec 2005 22:35
by OzTrans
You can use 'str2hex' only to translate text strings, like vehicle names; with values that works differently. Having a calculator that does this is a real bonus.

EDIT: Sorry about that, property 09 (speed) is of course also a word, so it's got to be 09 64 00.

Posted: 30 Dec 2005 11:18
by Villem
Alright i want to make the train multihead by default, but i can't find the wiki page in ttdpatch wiki that tells about coding multihead trains.

Also i tried implementing the misc.switch that makes the train 2 company coloured, but after i added it what i think was correct it still wasn't 2 cc(and i had drawn in the proper 2cc colour too).

Code: Select all

15 * 12	 00 00 02 01 13 0B 0C 17 02 00

Posted: 30 Dec 2005 11:25
by Patchman
You should get NFORenum (see DaleStan's sig for a link) to check your NFO files.

Broken down, your sprite does this:
00 = action 0
00 = feature 0 (trains)
02 = two properties are set
01 = for one vehicle
13 = vehicle ID 13
0B = property 0B, power
0C 17 = power value, 170C hex = 5900 HP
02 = property 02, reliability decay speed
00 = no reliability decay

Instead of setting property 02 to 00, you probably want to set property 27 (misc flags) to 02 (bit 1 set = uses 2CC). And to make it multiheaded, set property 13 to 01.

Posted: 30 Dec 2005 11:37
by Villem
Yeah im using nforenum, the wiki just confused me.

Thanks patchman.

now, ill try fix this problem with that both heads are facing wrong ways..

Posted: 30 Dec 2005 16:51
by Villem
Alright, with most(i hope)of the bugs squished, i need some help to squish out the remaining of them.

Thus i release the GRF, note the intorduction date is not correct, i have not yeat changed it. it should come out at 1958-1959 range, Arctics/Tropics only.


Known Bugs However Are:

1). The Train clips with its name in the depot buylist, i have no idea how to fix it thus far.
2). The Train clips with TTD's wagons in the buylist & ingame, and TTD wagons generally look out of place with it. i will try to fix this in near future.


And these are the following persons who i want to thank for helping me code this grf, and teaching me how to draw the train in it.

Patchman, the one who helped me to make this train multihead and use 2 company colour support.

Pikkabird, pointed me to nforenum that got me to my first beta.

Flamelord, he was right afterall, the lines did change more than 1 property!

OzTransLtd, helped me to get the power & speed action0's to work.

Purno, without your drawing tutorials that train would not have graphics.

DaleStan, without your nforenum tool this grf would not be here.

eis_os, your ingame sprite aligning tool was invaluable, without it, this grf probably would not be here.

and those who made all that nfo coding info at the ttdpatch wiki avaible, you provided my first steps to nfo.

Posted: 30 Dec 2005 19:22
by Killer 11
that's very nice!
could you help me with the coding of Lithuania set?

Posted: 30 Dec 2005 22:44
by OzTrans
It is somewhat a dangerous practice to only define a few vehicle properties; whatever you have not defined will be copied from a vehicle with the same ID as yours from another trainset that happens to be activated; thus giving you unpredictable results. As far as alignment goes, you need to further work on that. Best is to put some box cars between the 2 heads and make adjustments against their alignment.

In the purchase list, there is only room for about 56 pixels; in order to make your engine fit, you need to provide another set of sprites with shorter horizontal views (cut out 4 pixel columns each) and then reference that in action-3 as follows (you'll need another action-2, of course) :

Code: Select all

12 * 10     03 00 01 13 01 FF xx 00 00 00
xx = the set ID, probably 01 in your case.
BTW, FF is the cargo ID for the purchase list entry.