Page 1 of 1

NewGRF Questions

Posted: 03 Apr 2019 20:45
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.

Re: NewGRF Questions

Posted: 03 Apr 2019 20:59
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.

Re: NewGRF Questions

Posted: 03 Apr 2019 21:10
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.

Re: NewGRF Questions

Posted: 03 Apr 2019 21:34
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)

Re: NewGRF Questions

Posted: 03 Apr 2019 21:47
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.

Re: NewGRF Questions

Posted: 05 Apr 2019 08:58
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

Re: NewGRF Questions

Posted: 09 Apr 2019 17:45
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!