I am learning to code!

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
SkeedR
Tycoon
Tycoon
Posts: 2267
Joined: 11 Jul 2004 14:55
Location: West Midlands
Contact:

I am learning to code!

Post 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!
Last edited by SkeedR on 03 Jan 2006 20:46, edited 1 time in total.
Last known as: Weirdy
User avatar
TGVfan
Engineer
Engineer
Posts: 121
Joined: 10 Oct 2003 19:52
Location: Almere, greater Amsterdam

Post by TGVfan »

Why via PM?

I think there are more people around on this forum who would like to code.
Image
User avatar
Bastiaan
Chairman
Chairman
Posts: 781
Joined: 12 Feb 2004 19:34
Location: Zwolle (NL)
Contact:

Post by Bastiaan »

I've studied the NFO tutorial on the TTDPatch Wiki, but I still can't code... :roll:
Image
User avatar
Hyronymus
Tycoon
Tycoon
Posts: 13235
Joined: 03 Dec 2002 10:36
Location: The Netherlands
Contact:

Post 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).
Marshy
Director
Director
Posts: 630
Joined: 07 May 2004 14:57
Location: Leeds

Post by Marshy »

You want to spend the summer on your computer?! :o

/faints
User avatar
Geo Ghost
Moderator
Moderator
Posts: 6567
Joined: 25 Oct 2004 10:06
Location: UK
Contact:

Post 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 :?
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Post 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*!!!
Last edited by DaleStan on 17 Jun 2005 04:52, edited 1 time in total.
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
User avatar
Wile E. Coyote
Tycoon
Tycoon
Posts: 8515
Joined: 08 Jul 2004 22:14
Skype: wile.e.coyote2
Location: Belgrade, Serbia
Contact:

Post 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.
Serbian rail set with Serbian scenario (ECS, PBI, FIRS and Tourist set compatible) Website | Topic and download | Latest version: 03.06.2015.
Serbian tram set Tracking table | TTD Patch tram set Latest version: 17.06.2015. | Open TTD Remix Latest version: 11.07.2015.
WIN-DOS GRF Converter Topic and download | Version 0.2.1: 09.01.2005.


Runner-up in "Best avatar Forums award" for years 2006 and 2010!
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Post 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.
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
User avatar
SkeedR
Tycoon
Tycoon
Posts: 2267
Joined: 11 Jul 2004 14:55
Location: West Midlands
Contact:

Post 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
Attachments
train.jpg
train.jpg (2.69 KiB) Viewed 2470 times
train.txt
(799 Bytes) Downloaded 91 times
train.grf
(1.75 KiB) Downloaded 65 times
Last known as: Weirdy
User avatar
Lakie
TTDPatch Developer
TTDPatch Developer
Posts: 1799
Joined: 26 May 2004 16:37
Location: Britain
Contact:

Post 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
TTDpatch Developer 2005 - 2010 ~ It all started because of shortened vehicle not loading correctly, now look where I've gone with it!
Grfs coded ~ Finnish Train Set (Teaser) | Bm73 (Release 3) | Emu 680 (Release 3)| Glass Station (Release 1) | UK Roadset (Version 1.1a) | New Water Coasts (Version 7)
Pikka: "Lakie's a good coder, but before he'll add any feature to TTDP you have to convince him that you're not going to use it to destroy the world as we know it."
Patchman
Tycoon
Tycoon
Posts: 7575
Joined: 02 Oct 2002 18:57
Location: Ithaca, New York
Contact:

Post 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.
Josef Drexler

TTDPatch main | alpha/beta | nightly | manual | FAQ | tracker
No private messages please, you'll only get the answering machine there. Send email instead.
User avatar
SkeedR
Tycoon
Tycoon
Posts: 2267
Joined: 11 Jul 2004 14:55
Location: West Midlands
Contact:

Post 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
Last known as: Weirdy
User avatar
SkeedR
Tycoon
Tycoon
Posts: 2267
Joined: 11 Jul 2004 14:55
Location: West Midlands
Contact:

Post 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?)
Attachments
train.txt
I know, change the ID.
(851 Bytes) Downloaded 103 times
Last known as: Weirdy
Patchman
Tycoon
Tycoon
Posts: 7575
Joined: 02 Oct 2002 18:57
Location: Ithaca, New York
Contact:

Post 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.
Josef Drexler

TTDPatch main | alpha/beta | nightly | manual | FAQ | tracker
No private messages please, you'll only get the answering machine there. Send email instead.
User avatar
orudge
Administrator
Administrator
Posts: 25220
Joined: 26 Jan 2001 20:18
Skype: orudge
Location: Banchory, UK
Contact:

Post 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.
User avatar
SkeedR
Tycoon
Tycoon
Posts: 2267
Joined: 11 Jul 2004 14:55
Location: West Midlands
Contact:

Post 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.
Last known as: Weirdy
User avatar
Jezulkim
Chairman
Chairman
Posts: 844
Joined: 04 Jan 2004 09:40
Location: Finland/Suomi

Post 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
Image
In order to protect the visitors of this site,
TTO Full Conversion!
This post has been lol 1337 times.
User avatar
SkeedR
Tycoon
Tycoon
Posts: 2267
Joined: 11 Jul 2004 14:55
Location: West Midlands
Contact:

Post 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
Last known as: Weirdy
User avatar
OzTrans
Tycoon
Tycoon
Posts: 1714
Joined: 04 Mar 2005 01:07

Post 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
Post Reply

Return to “Graphics Development”

Who is online

Users browsing this forum: Ahrefs [Bot], Killer 11 and 36 guests