Station Coding- Help Needed

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
User avatar
mph
Engineer
Engineer
Posts: 124
Joined: 24 Aug 2007 20:47

Station Coding- Help Needed

Post by mph »

Hi.

I am trying to code some stations. I have made a lot of progress on my own, however i have run into a couple of problems, and I would be very grateful of any help you could give me.

There are a couple of issues for now.

1- Is it possible to specify which sprite is displayed in the construction window? Currently, i have a station building that is 2x1, and it shows the "second" sprite- a small one, rather than the corner one - if you understand what i mean. For buildings 3x1, it shows the middle sprite? Is this a problem with the order i have the sprites in? If it is not to difficult - i would prefer to specify a certain sprite as i have coded several buildings and it may be easier to do this. I have not found any information on the wiki concerning this.

2- I have been looking into variational action 2 to try and have the buildings change to snowy versions above the snowline, but i simply dont understand it.
Mainly- the part i dont understand is this:
<varadjust> <nvar> (<set-id> <low-range> <high-range>){n}
Now, i have never done any coding/programming before, so perhaps this is something i would understand if i had. Maybe there is some kind of tutorial out there you could point me towards?
Further i dont understand what to do with the information for Variable 42- terrain and track type info, which i assume is what i need to use for this.
I have "Stolen" some code from the UK waypoints set, in an attempt to try and decipher it- i will post the appropriate action02 here just in case it my help you describing what you mean or point out any glaring errors
i have made ;)
02 04
10 //cargo id 010
81 //to decide upon a general variable, or a variable of the object in question
42 // Variable- terrain and track tyoe
00 FF 01 04 80 04 04 00 80
I am keen to get throung these problems and I would really appreciate any help anyone could give me.
previously known as daylight
User avatar
minime
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 18 Jan 2004 10:02
Skype: dan.masek
Location: Prague, Czech Republic
Contact:

Re: Station Coding- Help Needed

Post by minime »

mph wrote:Is it possible to specify which sprite is displayed in the construction window?
Action 3, cargo type FF.
mph wrote:I have been looking into variational action 2 to try and have the buildings change to snowy versions above the snowline, but i simply dont understand it.
Mainly- the part i dont understand is this:
<varadjust> <nvar> (<set-id> <low-range> <high-range>){n}
You have to be more specific about what you don't understand about it.
In regards to bitwise operations, have a look at Wikipedia.

I'll continue what you posted here...
02 04
10 //cargo id 10
81 // checking a BYTE
42 // Variable- terrain and track tyoe
00 // shift-num -- no bit shifting, regular varaction2
FF // AND mask -- keep the value as is. therefore we're checking the TT part of var42
01 // Number of variations - just one
04 80 04 04 // this would be better written as \wx8004 04 04 -- return callback result of 4, when the value is 04
00 80 // better as \wx8000 -- otherwise return callback result of 0
Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. --Albert Einstein
Image Image Image
User avatar
mph
Engineer
Engineer
Posts: 124
Joined: 24 Aug 2007 20:47

Re: Station Coding- Help Needed

Post by mph »

Thanks for your help.

I have only looked into the variational action 2 part so far.
Your explanations of the parts of the example i gave were really useful.
I think i understand a bit better, although im not certain, i'll play around a bit to see if i can understand better, im sure it will come in time ;)
I didn't quite understand the 8000 or 8004 part. What is it i do with this? I managed to get it to work in a slightly diffent way-
rather than 1 set with 4 views (As it was in the UK Waypoints grf)- i had 2 sets with 2 views.
I then did the following- pointing towards 2 different action 2s refering to 2 different sets of sprites depending on whether it is snowy or not.
22 * 7 02 04 00 00 01 00 00
23 * 7 02 04 01 00 01 01 00
24 * 14 02 04 02 81 42 00 FF 01 01 00 04 04 00 00
25 * 10 03 04 01 01 01 FF 00 00 02 00
This, i am more than happy with this and i thank you again, although i would appreciate if you could explain how to use something with 80 in the high byte, rather than specifing an action2 ID, as this i believe would allow me to specify a snowy ground sprite rather than having to draw the snow into the sprite.

I think the only way i can thank you for your help is to post a little screenshot
Attachments
Snow.png
Snow.png (18.08 KiB) Viewed 2588 times
previously known as daylight
User avatar
DanMacK
Tycoon
Tycoon
Posts: 3906
Joined: 27 Feb 2004 20:03
Location: Ontario, Canada
Contact:

Re: Station Coding- Help Needed

Post by DanMacK »

Ooooooooh! Nice and Britishy. Looks like a nice rural station.
User avatar
Sanchimaru
Tycoon
Tycoon
Posts: 1542
Joined: 05 Feb 2004 22:39
Location: Kobe, Japan
Contact:

Re: Station Coding- Help Needed

Post by Sanchimaru »

A new coder is born :]
I wish you luck on your path, mph. You know that you will be very vlued here if you can code stations, I have heared that it's one of the most difficult parts to learn.

Maybe when you have finished the set you are working on right now, you want to lend a hand for the Industrial Stations Renewal? ;)
User avatar
Dave
Moderator
Moderator
Posts: 17249
Joined: 26 Dec 2005 20:19
Location: North London

Re: Station Coding- Help Needed

Post by Dave »

DanMacK wrote:Ooooooooh! Nice and Britishy. Looks like a nice rural station.
Yes he turned up out of nowhere and started drawing big things like Birmingham Moor Street Station and a variation on a couple of larger terminii.

I was having orgasms then. I might start again now if this is close to release.
Official TT-Dave Fan Club

Dave's Screenshot Thread! - Albion: A fictional Britain
Flickr


Why be a song when you can be a symphony? r is a...
User avatar
minime
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 18 Jan 2004 10:02
Skype: dan.masek
Location: Prague, Czech Republic
Contact:

Re: Station Coding- Help Needed

Post by minime »

mph wrote:I didn't quite understand the 8000 or 8004 part. What is it i do with this?
That is difficult to say without seeing that pseudosprite in context.

Having bit 15 set means that the value is a callback result. You can use callbacks for various things, such as selecting the tile layout to draw, animation, etc.

As for the rest - why don't you show us the whole code as you have it now (comment it, tho), as well as the source sprites. Then we can go through and discuss ways how you could improve or extend it.
Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. --Albert Einstein
Image Image Image
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Re: Station Coding- Help Needed

Post by DaleStan »

mph wrote:I didn't quite understand the 8000 or 8004 part. What is it i do with this?
If you're familiar with the C family of languages, that is akin to asking "I didn't quite understand the 'return 0;' or 'return 4;' part. What is it i do with this?"

Like minime said: Context.
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
mph
Engineer
Engineer
Posts: 124
Joined: 24 Aug 2007 20:47

Re: Station Coding- Help Needed

Post by mph »

Im glad you like my stations.
For those of you who are interested, there are a few of my drawings knocking around. I am working on a British Station Set. For the first version i have focused on older station buildings, of which i have done about 8, ranging from small rural stations up to a large terminus station - (the one I entered into the artist competition under the name "Daylight" back in june i think). To accompany this there are also several platform tiles, including footbridge, benches, shelters, signs and sloping ends. The majority of all this has been coded by Maedhros a while ago, but hes unfortunately too busy to finish it off.
So- I am hoping to learn to do it myself!! and if all goes well, it wont be too long before i can release something.



I really appreciate all your help. Thankyou for bearing with me.
DaleStan wrote:If you're familiar with the C family of languages
hmmm.... the problem is i dont really understand any programming languages. Im completely new to all this...

With regards to my question- I think i understand a little better now but i will try to clarify.
I think- 8004 refers to the tile type 04 defined in action0, the 8000 to the tyle type 00. Is it ok to give such a result here- since the station layout is being defined by callback? I think i need to get the hang of using varaction2 to define the station layout to understand this further.
This would explain both the way it changes the sprites depending on terrain, and why it was completely meaningless to you out of context!

If this could possibly be the case- I will have a look myself- but do let me know if i sound completely on the wrong track and i can attach the nfo for you.

I'm sure i will be back with more questions!
previously known as daylight
User avatar
mph
Engineer
Engineer
Posts: 124
Joined: 24 Aug 2007 20:47

Re: Station Coding- Help Needed

Post by mph »

Ok.

I have worked out how to define the layout with variational action 2, and everything is much clearer to me now.

I have a couple more questions however.

1- In the same way that you can find what platform a tile is on with variables 40, 41, 46, 47, 49 is it possible to do the same with the length? I feel like i am just missing something obvious. What i want to do is to code a building on an "Island" platform that is 2x2, and will show walls on the outer platforms if the station doesnt continue. As it is, i could do this if the length was 1, or the same sprite repeated, but not if the different positions along the stations length have different sprites.

2- Is it possible to reuse sprites within a single station tile, and is this neccesary? For example, i have some snow overlays- do i have to have one version for each set of sprites- this means i will have something like 36 real sprites showing snowy overlay, when i should be able to make to with 4. I am confused as if i only add them to the first set- will it matter that the sets have different numbers of sprites.
A similar situation that i have is that i have a large arched station roof- in order to add people tothe platform, will i have to redo the roof parts for each set, or can i just change the platform sprites.

I hope I have made myself clear :wink:

Thankyou again for any help, I am getting there.
previously known as daylight
User avatar
minime
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 18 Jan 2004 10:02
Skype: dan.masek
Location: Prague, Czech Republic
Contact:

Re: Station Coding- Help Needed

Post by minime »

1) Those variables let you get the position and size in both dimensions. You must be missing something.

2) Just toss all the sprites into one A1 set and then reuse them in different layouts. There's no point having an identical sprite included multiple times, if you can help it (and in this situation you should be able to).
Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. --Albert Einstein
Image Image Image
User avatar
mph
Engineer
Engineer
Posts: 124
Joined: 24 Aug 2007 20:47

Re: Station Coding- Help Needed

Post by mph »

- thankyou!

for the first question- i do apologize for missing that! "position along platform"

the second- i have only one large set of sprites- but how do i then do my action 2 to show different sets depending on the ammount of cargo if i only have one set?

edit-

Not a coding question- but for anyone else that might read this:
I have drawn this station building below. I think its quite nice, and there is definately a place for it in my set-
however,- the building i originally based this on is not an "island" building, and actually looks nothing like this- and im no longer sure it looks like a british station. Secondly i have lost the photos i used, and cant remember which station it was.
Now- should i include it? if this is to be included- what do i call it? Does someone know a similar looking station that i could name it after. Im not worried if its not exactly the same, or even an island building, but any ideas would be of great help.
Attachments
island.png
island.png (6.02 KiB) Viewed 2016 times
Last edited by mph on 12 Nov 2007 18:52, edited 1 time in total.
previously known as daylight
User avatar
minime
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 18 Jan 2004 10:02
Skype: dan.masek
Location: Prague, Czech Republic
Contact:

Re: Station Coding- Help Needed

Post by minime »

Callback 14 and decision based upon variable 60.
Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. --Albert Einstein
Image Image Image
User avatar
Ameecher
Tycoon
Tycoon
Posts: 11919
Joined: 12 Aug 2006 15:39
Contact:

Re: Station Coding- Help Needed

Post by Ameecher »

It certainly looks british to me, you sure it isn't Brockenhurst?
Image
User avatar
Ben_K
Tycoon
Tycoon
Posts: 1166
Joined: 01 Jun 2006 15:15
Location: Sydney, AUS

Re: Station Coding- Help Needed

Post by Ben_K »

Looks vaguely like the Billingshurst one. I'm sure you could find a British one to match it!
Post Reply

Return to “Graphics Development”

Who is online

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