OpenTTD / nml

NewGRF Meta Language
GNU General Public License v2.0
42 stars 36 forks source link

Technical Question: What is the reason for limitation of 6 sprite sets per station? #294

Closed trolleytrev closed 1 year ago

trolleytrev commented 1 year ago

Hello, hello!

No one on tt-forums had any ideas so I thought I'd ask the devs directly. I was curious as to why a station is limited to 6 custom sprite sets? I only ask as I am currently developing a station GRF and I would like to have an "auto-station" option like ISR that will automatically pick the tiles but as I am using 1 sprite-set per unique tile, I can only use up to 6 different tiles maximum for this feature, unless I make a massive sprite-set containing lots of tiles.

Is the limitation a NewGRF spec issue, OTTD limitation or just an arbitrary limit? And failing an increased limit, am I just missing something about how to code a station in nml or do I need a "hack-job" solution like I suggested above?

I have attached a zip of my (huge, sorry!) .nml file if it's of any use. Somewhat ironically, I can't directly upload an NML file, lol. Thanks, GitHub... YASS.zip

Any insights would be much appreciated.

Many thanks,

Trevor.

glx22 commented 1 year ago

It is a limitation of the NewGRF station spec. Stations were the first addition after vehicles and unfortunately they use a completely different implementation compared to industries or objects, which were introduced later. The main limitation is sprite layouts are static for stations (defined in Action0), while for other features it's a basic Action2). OpenTTD 1.2 introduce an advanced format for them (which is used in NML) allowing some dynamic behaviour, but it's still quite limited compared to what is available for other features.

It's possible to work around the limitation by using a switch as a custom spriteset like I did that in my CHIPS magic tile conversion. I used an overly complex implementation because I wanted to fully test NML capabilities (hence the huge amount of LOAD_TEMP()), but the interesting part for you will be custom_building switch and its usage in custom_spritesets.

frosch123 commented 1 year ago

Historically there was only a single spriteset for stations :) It was extended to allow combining/reusing sprites in different stations.

So, the intention is to implement stations like this:

A station can use multiple sprites from the same spriteset. It is assumed that related sprites (which only appear together) are defined in the same spriteset. So a station would for example use "ground_tiles(10), cranes(6), cranes(8), cargos(4), cargos(6)" (in total 5 sprites from 3 spritesets).

What is your use-case, that requires picking more than 6 spritesets independently? Is there an example in the YASS.nml you uploaded?

trolleytrev commented 1 year ago

No examples yet, however I had to make the ground, rear buildings, front buildings and glass overlays all on the same spriteset as I was hitting this limitation with ordinary tiles.

Use case is I have a sprite layout for every type of tile. I want to implement a feature called "auto station" so you don't have to pick each tile individually. My original intention was to change the graphics the same way that I am already doing it for multi-track stations with the tiles, by using a switch to index the sprite layout array. However, to do this for an entire station will need many different sprite layouts which inevitably will reference more than 6 spritesets.

Which brings me to the question: Is the spriteset limit arbitrary or a result of game/grf spec limitation? Because if it's just arbitrary, it should be a very simple task to increase it to, say 256, (or even better, a word rather than a byte, 65536!).

glx22 commented 1 year ago

My CHIPS conversion uses 7 spritesets per layout, 2 directly referenced in the sprite layout, 1 via custom_spritesets and the 4 last via a switch also in custom_spritesets.