Page 1 of 2

I am learning to code!

Posted: 16 Jun 2005 14:25
by SkeedR
I have summer holidays coming up and they are empty atm, so if anyone could give me lessons on how to code........ then i could help too! first i would like to help with the AusSet, as whitehand said nicely
WhiteHand wrote:I give up. the ausset is f*cked and you all know it.
so i thought, i have weeks of spare time, why not code! so anyone who could give me lessons just PM me!

Move this if its in the wrong place!

Posted: 16 Jun 2005 16:03
by TGVfan
Why via PM?

I think there are more people around on this forum who would like to code.

Posted: 16 Jun 2005 16:12
by Bastiaan
I've studied the NFO tutorial on the TTDPatch Wiki, but I still can't code... :roll:

Posted: 16 Jun 2005 16:25
by Hyronymus
Didn't Lakie put up a manual for basic coding on his users account here? It's quite understandable and really all you need to know for a start. If you want to proceed you can always nag other coders to help you, even I do that (still).

Posted: 16 Jun 2005 18:48
by Marshy
You want to spend the summer on your computer?! :o

/faints

Posted: 16 Jun 2005 18:50
by Geo Ghost
Marshy wrote:You want to spend the summer on your computer?! :o

/faints
I do it all the time! :lol:
Summer or not, day's of or not. im always on it.

The only thing i can code is a new main menu screen. and thats still reading instructions. I cant understant coding vehicles :?

Posted: 17 Jun 2005 04:02
by DaleStan
Coding:
1: Read the sections on actions 0-4. Ignore callbacks. (and 8)
2: Rip apart some simple GRF files and figure out a few of them.
3: Code a vehicle or two.
4: Go back and read the callbacks section.
5: If, at any point, you get stuck, ask a Smart Question, either here or on IRC.

EDIT: I *HATE* that 8) smiley. *HAAATE*!!!

Posted: 17 Jun 2005 04:18
by Wile E. Coyote
Everythig, but callbacks...
DaleStan, you know my problems to code them. I decoded your coding for 'Sinobus' (to learn how to code) and I still don't understand it :( So, I also think that's good idea little course in coding here in forums.

Posted: 17 Jun 2005 04:57
by DaleStan
They work exactly the same as variational/random action 2s, instead of having the final action 2 point to graphics, the final action 2 returnseither "<result> FF"/"<result> 80" (for 8-bit callbacks) or "<low-result> <high-result>&80" (for 15-bit results, where result=high-result<<8 & low-result)

Go read the Callbacks page, and tell me which paragraphs (even better, which sentences) you don't understand, and I'll try to clarify.
It didn't make sence to me the first time through either. I just skipped it and made a mental note to re-read it later.

Or, if you prefer, post the pseudo-sprites you don't understand and I'll explain them.

Posted: 03 Jan 2006 20:45
by SkeedR
So, here i am again.
But this time I WILL learn to code. So, now on to my first problem.
I'm trying to rework the stats of the lev4, all well and good until ttd says "Too many sprites specified!". Now what? If someone could have a look and tell me where on earth i've gone wrong i would be very pleased, Many Thanks

Weirdy

[EDIT] DOH! I'm such an ejit! I'll attach the files now. :oops: :P
And yes, i was using the txt as a .nfo, but it wouldn't let me attatch it as a .nfo

Posted: 03 Jan 2006 23:31
by Lakie
The first line of code, the sprite 0 line should always be.

Code: Select all

0 * 4    [number of lines of code]
Another why is putting the last sprite number in there.
As always with nfo it should be done in Hex.
Although, I'd recommend DaleStan's renum tool, which should calculate that for you.

So in this case your line would be:

Code: Select all

0 * 4    0D 00 00 00 # 13 lines of code
Hope that helps,
~ Lakie

Posted: 03 Jan 2006 23:37
by Patchman
Also, it's very very important that you pick your own unique GRFID.

Code: Select all

    1 * 8 08 06 "TW" 03 05 00 00
This is the ID from the Wiki tutorial (hence TW). You must not use it for your own files. Even for test files you should pick your own ID, constructed usually by picking your two initials, then a byte for the file type and one for the file version.

GRFID collisions can have nasty side effects, so please always make sure that your files have a unique ID.

Posted: 04 Jan 2006 22:54
by SkeedR
First I would like to say thank you to Patchman and Lakie.
You have helped me to make my VERY first functional .grf, AND I have changed the speed! :D So now i shall continue to learn more coding so that i will soon be able to code all sorts of things. Again, Thank you!
WHOOPIE!!!!!! :P :D :P

Posted: 05 Jan 2006 20:33
by SkeedR
ok, once again i'm stumped. I get an "invalid sprite [5/9]" error.
Once again can someone show me the errors of my way?
(Owen, i still can't attach .nfo's, am i ment to not be able to?)

Posted: 05 Jan 2006 23:46
by Patchman
Yes. Change the ID. NOW.

Then learn to interpret sprite error messages: http://wiki.ttdpatch.net/tiki-index.php ... riteErrors

If you need more help, you should always post the *exact* error message as it appears on the screen, because you left out the most important part there.

Posted: 06 Jan 2006 17:44
by orudge
weirdy wrote:(Owen, i still can't attach .nfo's, am i ment to not be able to?)
Attach them as .txt, please.

Posted: 06 Jan 2006 18:33
by SkeedR
ok, so, my problem is fixed. But now i would like to know, How exactaly do i change the weight? if i even can change the weight.

Posted: 06 Jan 2006 21:33
by Jezulkim
weirdy wrote:ok, so, my problem is fixed. But now i would like to know, How exactaly do i change the weight? if i even can change the weight.
Action 0 property 16 (for trains). It's on the wiki :) http://wiki.ttdpatch.net/tiki-index.php ... ion0Trains

Posted: 06 Jan 2006 22:10
by SkeedR
Jezulkim wrote:
weirdy wrote:ok, so, my problem is fixed. But now i would like to know, How exactaly do i change the weight? if i even can change the weight.
Action 0 property 16 (for trains). It's on the wiki :) http://wiki.ttdpatch.net/tiki-index.php ... ion0Trains
Where exactaly? I am either blind, (of which i am sure i am not), or it is actually not there. :o

Posted: 06 Jan 2006 22:37
by OzTrans
weirdy wrote: ... I am either blind, (of which i am sure i am not) ...
You must be ...

What is that ?

15 B Cargo type, see column 3 (type B) in CargoTypes
16 B Weight in tons
17 B Cost factor

... and if your vehicles weighs more than 255 t, you'll also need this ...

24 B High byte of vehicle weight, weight will be prop.24*256+prop.16