[NML] Groundtiles for Slope-Aware Object

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

Moderator: Graphics Moderators

Post Reply
User avatar
Quast65
Tycoon
Tycoon
Posts: 2670
Joined: 09 Oct 2011 13:51
Location: The Netherlands

[NML] Groundtiles for Slope-Aware Object

Post by Quast65 »

Hi all!

GarryG and I need some help...

We need some help with converting the NML code of a slope-aware object.
Right now it automatically uses the grassy tiles as groundtiles.
But we would like to choose what groundtile is used for each slope (if possible, by defining the number it has in OpenGFX-BASE).
Could someone be so kind to convert the code below, or point us to an example that uses this?
Thnx in advance!
Q65_SlopeAware.nml
(11.55 KiB) Downloaded 30 times
Projects: http://www.tt-forums.net/viewtopic.php?f=26&t=57266
Screenshots: http://www.tt-forums.net/viewtopic.php?f=47&t=56959
Scenario of The Netherlands: viewtopic.php?f=60&t=87604

Winner of the following screenshot competitions:
sep 2012, jan 2013, apr 2013, aug 2013, mar 2014, mar 2016, oct 2020
All my work is released under GPL-license (either V2 or V3), if not clearly stated otherwise.
User avatar
OzTrans
Tycoon
Tycoon
Posts: 1680
Joined: 04 Mar 2005 01:07

Re: [NML] Groundtiles for Slope-Aware Object

Post by OzTrans »

Quast65 wrote: 02 Apr 2024 09:07 ... We need some help with converting the NML code of a slope-aware object. ...
Not that I can help with NML; but here are some hints what you can do ...

- For each object tile, you need to define 19 sprite layouts, each having the relevant ground-sprite referenced.
- Following that you check the slope and point to the relevant layouts.

There is another (more complex) way, but much less typing required :

You can use 'Advanced sprite layouts using register offsets'; i.e. you place an offset (sprite number depending on slope) into a register (temporary storage) just prior to referencing the single sprite-layout and that has also added the register to the sprite-layout.

In other words; the ground-sprite number is set to the first sprite (the flat one), then place the slope ID into the register. This requires that all ground sprites are in consecutive order.

I could show you sample code in NFO ...
User avatar
Quast65
Tycoon
Tycoon
Posts: 2670
Joined: 09 Oct 2011 13:51
Location: The Netherlands

Re: [NML] Groundtiles for Slope-Aware Object

Post by Quast65 »

OzTrans wrote: 02 Apr 2024 22:58 Not that I can help with NML; but here are some hints what you can do ...
Thank you for your reply!
In other words; the ground-sprite number is set to the first sprite (the flat one), then place the slope ID into the register. This requires that all ground sprites are in consecutive order.
This wont work for what we have in mind.
For this project, we want to use the coastal tiles as groundtiles, they arent in consecutive order. (as some of them arent even really coastal, but referr back to the grassy ones, like the gorges, I hope you know which I mean with gorges ;-) )
But also for future projects I think it would be handy to know how to give certain slopes certain groundtiles via number in OpenGFX-base.
- For each object tile, you need to define 19 sprite layouts, each having the relevant ground-sprite referenced.
- Following that you check the slope and point to the relevant layouts.
This is a good hint to start from, thnx!
I could show you sample code in NFO ...
For the idea we want to work from, I already have NFO examples, thnx.

Again thnx for the reply, Ill see what I can come up with.
Projects: http://www.tt-forums.net/viewtopic.php?f=26&t=57266
Screenshots: http://www.tt-forums.net/viewtopic.php?f=47&t=56959
Scenario of The Netherlands: viewtopic.php?f=60&t=87604

Winner of the following screenshot competitions:
sep 2012, jan 2013, apr 2013, aug 2013, mar 2014, mar 2016, oct 2020
All my work is released under GPL-license (either V2 or V3), if not clearly stated otherwise.
User avatar
OzTrans
Tycoon
Tycoon
Posts: 1680
Joined: 04 Mar 2005 01:07

Re: [NML] Groundtiles for Slope-Aware Object

Post by OzTrans »

Quast65 wrote: 03 Apr 2024 13:03 This wont work for what we have in mind.
For this project, we want to use the coastal tiles as groundtiles, they aren't in consecutive order. ...
Understood ... You need to get the sprite number of the first coastal sprite by reading 'PatchVariable 0x16'. You can get it via an Action-D. This variable contains the first sprite number of the coastal tile range. Then arrange your sprite layouts in order of those coastal tiles (18 of them including the 2 gorges), increasing the sprite numbers by 1 as you go along.

If you cannot see the gorges in the base set; you need to add them yourself using Action-5 Type-0x0D.
User avatar
Quast65
Tycoon
Tycoon
Posts: 2670
Joined: 09 Oct 2011 13:51
Location: The Netherlands

Re: [NML] Groundtiles for Slope-Aware Object

Post by Quast65 »

OzTrans wrote: 03 Apr 2024 23:05 Understood ...
I have had success!!! :P
Using 19 tilechecks, that either picks a certain graphic if it suits the slope, or referrs back to another one, until it gets the right one for the slope, works!
I can now specify what specific groundtile I want for each slope and it automatically picks the right graphic for each slope ingame.
It is probably not the most elegant way to do it in NML, but if it works, it works :tongue:

I still have to clean it all up a bit, will post sources then.
Projects: http://www.tt-forums.net/viewtopic.php?f=26&t=57266
Screenshots: http://www.tt-forums.net/viewtopic.php?f=47&t=56959
Scenario of The Netherlands: viewtopic.php?f=60&t=87604

Winner of the following screenshot competitions:
sep 2012, jan 2013, apr 2013, aug 2013, mar 2014, mar 2016, oct 2020
All my work is released under GPL-license (either V2 or V3), if not clearly stated otherwise.
User avatar
Quast65
Tycoon
Tycoon
Posts: 2670
Joined: 09 Oct 2011 13:51
Location: The Netherlands

Re: [NML] Groundtiles for Slope-Aware Object

Post by Quast65 »

GarryG wrote: 05 Apr 2024 07:31 ..
Hi Garry,
I am having some issues at the moment with sending PM's
I hope to notify you this way that I have found the coding solution to our issue.
Will PM you a test GRF soon!
So, no need to work on those overlapping graphics 8)
Projects: http://www.tt-forums.net/viewtopic.php?f=26&t=57266
Screenshots: http://www.tt-forums.net/viewtopic.php?f=47&t=56959
Scenario of The Netherlands: viewtopic.php?f=60&t=87604

Winner of the following screenshot competitions:
sep 2012, jan 2013, apr 2013, aug 2013, mar 2014, mar 2016, oct 2020
All my work is released under GPL-license (either V2 or V3), if not clearly stated otherwise.
User avatar
GarryG
Tycoon
Tycoon
Posts: 5904
Joined: 14 Feb 2015 00:44
Location: Newcastle, Australia

Re: [NML] Groundtiles for Slope-Aware Object

Post by GarryG »

Quast65 wrote: 05 Apr 2024 16:59 I am having some issues at the moment with sending PM's
Me too .. tried answer yours and another yesterday and this morning and they not send and got a 503 error message.
Last edited by GarryG on 05 Apr 2024 23:06, edited 1 time in total.
Soot Happens
Screenshot Of The Month Winner March 2020
All my projects are GPLv2 License unless stated.
Auz Road Sets: viewtopic.php?f=29&t=87335
Auz Project Releases: viewtopic.php?f=67&t=84725
Auz Trains: http://www.tt-forums.net/viewtopic.php?f=26&t=74193
Auz Industry Sets: http://www.tt-forums.net/viewtopic.php?f=26&t=74471
Auz Objects: viewtopic.php?f=26&t=75657
Auz Bridges: viewtopic.php?f=26&t=75248
Auz Stations: viewtopic.php?f=26&t=76390
Auz Tracks: viewtopic.php?f=26&t=82691
Auz Subway Stations: viewtopic.php?f=26&t=85335
Auz Eyecandy TramTracks: viewtopic.php?t=89908
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 11 guests