[NML] Problems with new railtype definition

Discussions about the technical aspects of graphics development, including NewGRF tools and utilities.

Moderator: Graphics Moderators

michael blunck
Tycoon
Tycoon
Posts: 5954
Joined: 27 Apr 2005 07:09
Contact:

Re: [NML] Problems with new railtype definition

Post by michael blunck »

arikover wrote: I read that there is a random switch for railtypes, with only 2 results, but then it says that the outcome is 'pseudo-random, based on location'.
What is that supposed to mean? Is it related to terrain, or rather to tile coordinates? Or maybe something else?
IIRC, it´s based on tile location.

regards
Michael
Image
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: [NML] Problems with new railtype definition

Post by planetmaker »

arikover wrote:[
I read that there is a random switch for railtypes, with only 2 results, but then it says that the outcome is 'pseudo-random, based on location'.
What is that supposed to mean? Is it related to terrain, or rather to tile coordinates? Or maybe something else?
It's the last two bits of the tile coordinate which will be reported as 'random' bits. So if you covered the whole map uniformly with tracks, you'd recognize a regular pattern. De-facto it doesn't matter as you'll never have a map covered entirely by the same type of tracks (type + direction) and it won't be visible.
arikover
Route Supervisor
Route Supervisor
Posts: 466
Joined: 15 Jun 2007 09:27
Skype: madchimiste
Location: Berlin, Deutschland

Re: [NML] Problems with new railtype definition

Post by arikover »

Thank you very much, all of you!
Transportman
Tycoon
Tycoon
Posts: 2792
Joined: 22 Feb 2011 18:34

Re: [NML] Problems with new railtype definition

Post by Transportman »

arikover wrote:Go the if-block way :
I figured I can't use an if-block inside a switch block, nor a switch block inside an if-block.
michael blunck wrote:it could be done in the proper way, with having two sprite blocks and skipping one of them according to the signals_on_traffic_side flag (by an action7/9).
I'm not sure how to do that in nml. I tried :

Code: Select all

if (signals_on_traffic_side) {
    spriteset(spritesetA ...template blah blah);
    spriteset(spritesetB ...template blah blah);
    ...
} else {
    spriteset(spritesetA ...template blah blah);
    spriteset(spritesetB ...template blah blah);
    ...
}
But of course now it says that 'spritesetA' has already been defined and can't be defined twice.

I am evidently missing something here...
I've hit the same problem with the Dutch Trainset when implementing the track-dependency for the power (and disabling that when no compatible trackset is loaded), and I ended up with if/else-ing the graphics-block of the item. One with track-dependency and the power pointing to a switch and one without track-dependency having just a return value. You would need the same and use different names for the various spritesets/switches.
Coder of the Dutch Trackset | Development support for the Dutch Trainset | Coder of the 2cc TrainsInNML
arikover
Route Supervisor
Route Supervisor
Posts: 466
Joined: 15 Jun 2007 09:27
Skype: madchimiste
Location: Berlin, Deutschland

Re: [NML] Problems with new railtype definition

Post by arikover »

Now I understand why some of my other stuff didn't work. if-blocks can be made inside item-blocks, but outside property- or graphics-blocks!

Thank you Transportman!
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 21 guests