NewGRF Questions

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

Post Reply
User avatar
DigitalSoma
Engineer
Engineer
Posts: 7
Joined: 23 Mar 2019 01:16
Contact:

NewGRF Questions

Post by DigitalSoma »

I had an idea for a newGRF to simulate a train yard (see image), but never having made a newGRF before, I have a few questions on what things are possible in newGRF coding.

1.) Would you be able to have a newGRF reorder the wagons of a train while loading in a station? If in depot, it's [engine, grain, grain, livestock, livestock], would you be able to have it reorder itself to [engine, livestock, grain, grain, livestock] based on what cargo was loaded first to last?

2.) If an empty wagon is set to an invisible sprite, will it be empty in the depot, or are the sprites in the depot separate from trains on the rails?

Thanks for any advice you could give.
Attachments
newGRF_idea.jpg
(106.57 KiB) Not downloaded yet
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: NewGRF Questions

Post by planetmaker »

DigitalSoma wrote:I had an idea for a newGRF to simulate a train yard (see image), but never having made a newGRF before, I have a few questions on what things are possible in newGRF coding.

1.) Would you be able to have a newGRF reorder the wagons of a train while loading in a station? If in depot, it's [engine, grain, grain, livestock, livestock], would you be able to have it reorder itself to [engine, livestock, grain, grain, livestock] based on what cargo was loaded first to last?

2.) If an empty wagon is set to an invisible sprite, will it be empty in the depot, or are the sprites in the depot separate from trains on the rails?

Thanks for any advice you could give.
You cannot re-order the wagons of a train via NewGRF. That's a player action. You can choose to show different sprites depending on many different factors... not sure what you describe is possible... it might with some quite complicated shenengians on sprite control.

Sprites in depots can be different ones than used on the track (and often are for various reasons, e.g. offsets / placement). Yet: why would an empty wagon become invisible? I'd consider that highly confusing.
User avatar
DigitalSoma
Engineer
Engineer
Posts: 7
Joined: 23 Mar 2019 01:16
Contact:

Re: NewGRF Questions

Post by DigitalSoma »

planetmaker wrote:
You cannot re-order the wagons of a train via NewGRF. That's a player action. You can choose to show different sprites depending on many different factors... not sure what you describe is possible... it might with some quite complicated shenengians on sprite control.

Sprites in depots can be different ones than used on the track (and often are for various reasons, e.g. offsets / placement). Yet: why would an empty wagon become invisible? I'd consider that highly confusing.
To simulate coupling and decoupling through a combination of a station and train set newGRF, basically. I was thinking empty wagons could have a weight of zero and be invisible as if the wagons were left at the station. The train then goes to a loading station or a depot to refit and as it loads the wagons become visible to simulate wagons being coupled to the locomotive or the rest of the train.

Of course, going through this thread and seeing new development on reversing and decoupling patches, this may not be necessary in the first place, but from what I remember reading in the past people were having trouble getting this functionality to work properly.
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: NewGRF Questions

Post by planetmaker »

DigitalSoma wrote:
planetmaker wrote:
You cannot re-order the wagons of a train via NewGRF. That's a player action. You can choose to show different sprites depending on many different factors... not sure what you describe is possible... it might with some quite complicated shenengians on sprite control.

Sprites in depots can be different ones than used on the track (and often are for various reasons, e.g. offsets / placement). Yet: why would an empty wagon become invisible? I'd consider that highly confusing.
To simulate coupling and decoupling through a combination of a station and train set newGRF, basically. I was thinking empty wagons could have a weight of zero and be invisible as if the wagons were left at the station. The train then goes to a loading station or a depot to refit and as it loads the wagons become visible to simulate wagons being coupled to the locomotive or the rest of the train.

Of course, going through this thread and seeing new development on reversing and decoupling patches, this may not be necessary in the first place, but from what I remember reading in the past people were having trouble getting this functionality to work properly.
My personal opinion: A decent shunting via NewGRF will prove more challanging than tidying up some of the patches (I had a go at the NewGRF way implementing proper reversing so that trains don't flip at terminal stations... it's interesting and works only somewhat... so not better but worse than a direct patch to OpenTTD. But it teaches you a lot of what you can do with (vehicle) NewGRFs)
User avatar
DigitalSoma
Engineer
Engineer
Posts: 7
Joined: 23 Mar 2019 01:16
Contact:

Re: NewGRF Questions

Post by DigitalSoma »

planetmaker wrote:
My personal opinion: A decent shunting via NewGRF will prove more challanging than tidying up some of the patches (I had a go at the NewGRF way implementing proper reversing so that trains don't flip at terminal stations... it's interesting and works only somewhat... so not better but worse than a direct patch to OpenTTD. But it teaches you a lot of what you can do with (vehicle) NewGRFs)
Thanks for the advice! I thought it would be difficult to do, but just wanted to check with people with more experience.
michael blunck
Tycoon
Tycoon
Posts: 5948
Joined: 27 Apr 2005 07:09
Contact:

Re: NewGRF Questions

Post by michael blunck »

DigitalSoma wrote: [train reversing / shunting]
[...] just wanted to check with people with more experience.
To get helpful answers, you might talk to "Snail" about train reversing (newgrf) and to "karn" about realistic shunting (patch).

regards
Michael
Image
User avatar
DigitalSoma
Engineer
Engineer
Posts: 7
Joined: 23 Mar 2019 01:16
Contact:

Re: NewGRF Questions

Post by DigitalSoma »

michael blunck wrote:
DigitalSoma wrote: [train reversing / shunting]
[...] just wanted to check with people with more experience.
To get helpful answers, you might talk to "Snail" about train reversing (newgrf) and to "karn" about realistic shunting (patch).

regards
Michael
I'll check them out, thanks!
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: Google [Bot] and 19 guests