NML - a Newgrf Meta Language

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

Moderator: Graphics Moderators

Silverx50
Route Supervisor
Route Supervisor
Posts: 430
Joined: 13 Apr 2007 19:52
Location: Den Haag, The Netherlands

Re: NML - a Newgrf Meta Language

Post by Silverx50 »

.
Quast65 wrote:So, in this case for a 2x2 building you need to cut it up into 4 single-tile graphics and tell the spritesorter via the code how to arrange these 4 tiles in such a way that a complete building shows up.
Thank you. :bow:
This makes it all a bit harder and looks like I'll have to find some more patience while I get the hang of this.
any tips on the easiest way to split the buildings?
I'll take a look at your code and see if I can figure it out.
thanks again.
All my projects are GPLv2 License.

Dutch landmark Object Set Workshop viewtopic.php?f=26&t=75071
My stations workshop viewtopic.php?f=26&t=74749
User avatar
Quast65
Tycoon
Tycoon
Posts: 2654
Joined: 09 Oct 2011 13:51
Location: The Netherlands

Re: NML - a Newgrf Meta Language

Post by Quast65 »

Silverx50 wrote:any tips on the easiest way to split the buildings?
This is the crudest (but also easiest) way to do it:
-Start with copying a couple of complete buildings, and draw a tile next to those.
-Now use the select tool to select the shape of the tile, go over to the building and place it where the front tile is, extend the selection to the top of the building and cut that out (red 1)
-This is your first tile, place that into your template.
-Go back to another complete building and do the same for the left tile and the right tile.
-Finally, go back to another complete building and use the shape of a tile to cut out the front, left and right tile (but dont extend to the top), now you can see where you can cut out the backtile from (red 4).
Example21.png
Example21.png (37.43 KiB) Viewed 4655 times
You will then end up with this:
Example22.png
Example22.png (10.98 KiB) Viewed 4655 times
Please note that this might not be the right order of these sprites, maybe the backtile should be first and then the right, then left and finally front. Its been a while that I coded multitile objects, so I dont remember the right order.
A good test should be to just use 4 different flat tiles (each with a different color or number) first, to see in what order they show up.
But this is the easiest way to split it up.

I hope that you manage to find this out, I am currently very busy with work, so dont have time right now to make some more multitile examples. If you dont manage, I'll see if I can do it at the end of this month, I have some more free time then. Good luck!
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.
frosch
OpenTTD Developer
OpenTTD Developer
Posts: 988
Joined: 20 Dec 2006 13:31
Location: Aschaffenburg

Re: NML - a Newgrf Meta Language

Post by frosch »

Why do you need to cut it up in the graphics file?
Can't you just keep the image as a whole, and then reference subsections from NML?

It is sufficient that the tiles in front have graphics. The hidden tiles do not need any.
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
Silverx50
Route Supervisor
Route Supervisor
Posts: 430
Joined: 13 Apr 2007 19:52
Location: Den Haag, The Netherlands

Re: NML - a Newgrf Meta Language

Post by Silverx50 »

Quast65 wrote:This is the crudest (but also easiest) way to do it:
-Start with copying a couple of complete buildings, and draw a tile next to those.
-Now use the select tool to select the shape of the tile, go over to the building and place it where the front tile is, extend the selection to the top of the building and cut that out (red 1)
-This is your first tile, place that into your template.
-Go back to another complete building and do the same for the left tile and the right tile.
-Finally, go back to another complete building and use the shape of a tile to cut out the front, left and right tile (but dont extend to the top), now you can see where you can cut out the backtile from (red 4).
Thanks. been trying to create a template version of the code. haven't had much succes getting it to work just yet.
will try again tomorrow.
frosch wrote:Why do you need to cut it up in the graphics file?
Can't you just keep the image as a whole, and then reference subsections from NML?

It is sufficient that the tiles in front have graphics. The hidden tiles do not need any.
Not sure how to do this either. will try to get through the code Quast65 provided first.
All my projects are GPLv2 License.

Dutch landmark Object Set Workshop viewtopic.php?f=26&t=75071
My stations workshop viewtopic.php?f=26&t=74749
User avatar
Quast65
Tycoon
Tycoon
Posts: 2654
Joined: 09 Oct 2011 13:51
Location: The Netherlands

Re: NML - a Newgrf Meta Language

Post by Quast65 »

frosch wrote:Why do you need to cut it up in the graphics file?
Can't you just keep the image as a whole, and then reference subsections from NML?
That is indeed a very good suggestion, it makes life for graphic artists a lot easier if they dont have to bother with cutting up graphics. (also easier for artists who want to add snowy graphics)
However it does mean that templates are very important!!!
I recommend (for this case as it is a 2x2 building) to always start with 4 groundtiles, extend the invisible blue of the template to the hight it will need for the desired building and check before you place the building into the template if the groundtiles still are in the right place and order (as you have to change some values of the sprites in the code).

To be honest, cutting up via code was not that easy ;-) But I managed to do it and also figured out the code for the layout of the tiles:
Example23.png
Example23.png (45.55 KiB) Viewed 4227 times
Here is the .rar with GRF, code and graphics:
2x2.rar
(19.74 KiB) Downloaded 108 times
I do believe that I used a lot of code for the boundingboxes (I have defined a boundingbox for each tile), I have seen some examples where this was done a lot better (some clean up of my code or suggestions are very welcome ;-) ) , but at least this is something you might be able to work with (and also figure out how to code objects with other sizes than 2x2).

Good luck! :twisted:
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.
Silverx50
Route Supervisor
Route Supervisor
Posts: 430
Joined: 13 Apr 2007 19:52
Location: Den Haag, The Netherlands

Re: NML - a Newgrf Meta Language

Post by Silverx50 »

Quast65 wrote:Here is the .rar with GRF, code and graphics:
you are amazing! I'd been struggling with trying to figure out how to get nml to accept what I thought was correct.
now I see what I'd been doing wrong. with this I can code babylon.
and I think I can figure out how to get the other sizes from this code.

thanks!
All my projects are GPLv2 License.

Dutch landmark Object Set Workshop viewtopic.php?f=26&t=75071
My stations workshop viewtopic.php?f=26&t=74749
User avatar
GarryG
Tycoon
Tycoon
Posts: 5850
Joined: 14 Feb 2015 00:44
Location: Newcastle, Australia

Re: NML - a Newgrf Meta Language

Post by GarryG »

Quast65 a life saver. One of the reasons most of my objects in my Auz_Roadside_Objects and Auz-Lineside_Objects are 1x1 and overlap tiles as I didn't know how to do 2x2. Thanks pal.
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
User avatar
Quast65
Tycoon
Tycoon
Posts: 2654
Joined: 09 Oct 2011 13:51
Location: The Netherlands

Re: NML - a Newgrf Meta Language

Post by Quast65 »

Thnx guys, good to hear that this will help you with your work!!
Like I said before, I think the code could be a bit cleaner regarding the boundingboxes.
However having all tiles with a separate defined boundingbox is not that bad, may be usefull for buildings that have different hights or that have plaza's/gardens that then can be bridged, without strange glitches happening.
I look forward to what you can come up with! :bow:
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
3iff
Tycoon
Tycoon
Posts: 1093
Joined: 21 Oct 2005 09:26
Location: Birmingham, England

Re: NML - a Newgrf Meta Language

Post by 3iff »

Looks interesting. I did have one 2*2 building that I had to cut up and then try and reassemble. It was a mess. This code looks far easier. I might have an opportunity to use it soon.
User avatar
GarryG
Tycoon
Tycoon
Posts: 5850
Joined: 14 Feb 2015 00:44
Location: Newcastle, Australia

Re: NML - a Newgrf Meta Language

Post by GarryG »

Can a town be made in NML?

Been asked if the shops I done in my objects sets can be made into a town.

If so .. can someone help me get started .. has someone done a town in NML that I can borrow the sources and NML files from, or would someone be kind enough to start one for me with just a few buildings in it and I go from there.

Or if someone already has a town done or in progress, your welcome to use the buildings I done in my projects.

Thanks all

Cheers

Garry
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
User avatar
Quast65
Tycoon
Tycoon
Posts: 2654
Joined: 09 Oct 2011 13:51
Location: The Netherlands

Re: NML - a Newgrf Meta Language

Post by Quast65 »

GarryG wrote:Can a town be made in NML?

Been asked if the shops I done in my objects sets can be made into a town.

If so .. can someone help me get started .. has someone done a town in NML that I can borrow the sources and NML files from, or would someone be kind enough to start one for me with just a few buildings in it and I go from there.

Or if someone already has a town done or in progress, your welcome to use the buildings I done in my projects.

Thanks all

Cheers

Garry
There are some people working on it, this search link might help you to find some persons busy with that or that are able to get you started:
search.php?keywords=%22houses+in+NML%22 ... ubmit=Zoek
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.
Silverx50
Route Supervisor
Route Supervisor
Posts: 430
Joined: 13 Apr 2007 19:52
Location: Den Haag, The Netherlands

Re: NML - a Newgrf Meta Language

Post by Silverx50 »

Quast65 wrote: (and also figure out how to code objects with other sizes than 2x2).
So I've the time I haven't spent drawing I have spent trying to take the code you made for the 2x2 and create a template for a 2x3/3x2 and from there I waned to go to 3x3.
but after a week of disappointment I actually got somewhere only to run into a wall again.
I think I've templated the 6 tiles correctly but something I've done isn't correct as it doesn't draw tile 6 correctly (If I use sprite aligner and move the 1.1 that is drawn where tile 6 should be you see a half drawn tile 6.) The second problem I'm running into is that I don't understand why it's drawing tile 1.1 plus those overlapping tiles where tile 6 should be.
i've added the code and template in the rar file.
Attachments
3x2 problems.png
3x2 problems.png (130.24 KiB) Viewed 3650 times
3x2.rar
(19.4 KiB) Downloaded 80 times
All my projects are GPLv2 License.

Dutch landmark Object Set Workshop viewtopic.php?f=26&t=75071
My stations workshop viewtopic.php?f=26&t=74749
User avatar
3iff
Tycoon
Tycoon
Posts: 1093
Joined: 21 Oct 2005 09:26
Location: Birmingham, England

Re: NML - a Newgrf Meta Language

Post by 3iff »

Do you want something like this...?
Unnamed, 1st Jan 1940#2.png
Unnamed, 1st Jan 1940#2.png (57.74 KiB) Viewed 3639 times
Give me a few minutes to work out why your original code doesn't work...then I'll explain what I know.

----------

I'm not sure why it doesn't work but

Code: Select all

//select correct sprites for position of the tiles for the one view
switch (FEAT_OBJECTS, SELF, switch_template_2x3_001_position_view1, relative_pos) {
	relative_coord(0, 0): spritelayout_template_2x3_001_t1_view1;
	relative_coord(0, 1): spritelayout_template_2x3_001_t2_view1;
	relative_coord(1, 0): spritelayout_template_2x3_001_t3_view1;
	relative_coord(1, 1): spritelayout_template_2x3_001_t4_view1;
   relative_coord(2, 0): spritelayout_template_2x3_001_t5_view1;
	relative_coord(2, 2): spritelayout_template_2x3_001_t6_view1;
	spritelayout_template_2x3_001_t6_view1;  // This is the default call
    }
It seems that coord(2, 2) fails for some reason and it defaults to sprite 1, so it displays it in position 6.
In the above code, I reset the default to view 6 and it works...just as a temporary measure, of course.

Perhaps the relative_pos is set wrong?? but I don't really know.
Silverx50
Route Supervisor
Route Supervisor
Posts: 430
Joined: 13 Apr 2007 19:52
Location: Den Haag, The Netherlands

Re: NML - a Newgrf Meta Language

Post by Silverx50 »

3iff wrote:It seems that coord(2, 2) fails for some reason and it defaults to sprite 1, so it displays it in position 6.
In the above code, I reset the default to view 6 and it works...just as a temporary measure, of course.

Perhaps the relative_pos is set wrong?? but I don't really know.
thanks for looking at it. what you did works indeed.
well Now to see if I run into the same problems at 3x3....
All my projects are GPLv2 License.

Dutch landmark Object Set Workshop viewtopic.php?f=26&t=75071
My stations workshop viewtopic.php?f=26&t=74749
User avatar
3iff
Tycoon
Tycoon
Posts: 1093
Joined: 21 Oct 2005 09:26
Location: Birmingham, England

Re: NML - a Newgrf Meta Language

Post by 3iff »

I was pleased that I managed to part-solve it...I'm obviously getting better at NML.

You should probably try and find out why it's not working properly...actually, I might try something myself. I've just spotted a couple of potential candidates.

HA!

You have coord (2,2). I think it should be (2,1) - Yes, that's where the problem is. Works fine now even with the default as view 1.
Silverx50
Route Supervisor
Route Supervisor
Posts: 430
Joined: 13 Apr 2007 19:52
Location: Den Haag, The Netherlands

Re: NML - a Newgrf Meta Language

Post by Silverx50 »

3iff wrote:You have coord (2,2). I think it should be (2,1) - Yes, that's where the problem is. Works fine now even with the default as view 1.
ah wow thank you, didn't notice that. This should help me a great deal :bow:
All my projects are GPLv2 License.

Dutch landmark Object Set Workshop viewtopic.php?f=26&t=75071
My stations workshop viewtopic.php?f=26&t=74749
User avatar
3iff
Tycoon
Tycoon
Posts: 1093
Joined: 21 Oct 2005 09:26
Location: Birmingham, England

Re: NML - a Newgrf Meta Language

Post by 3iff »

My pleasure. Glad I could locate the problem.
User avatar
GarryG
Tycoon
Tycoon
Posts: 5850
Joined: 14 Feb 2015 00:44
Location: Newcastle, Australia

Re: NML - a Newgrf Meta Language

Post by GarryG »

3iff & Silverx50 Thanks fellas you answered some things I been pondering on for a while too.
Quast65 helped me with 2x2 and 2x1 and now got the answers to 2x3s. With the NML file that you all included, the answer is there for no matter what size tile set up we want.

Getting me motivated again.

Thanks fellas

Cheers
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
User avatar
GarryG
Tycoon
Tycoon
Posts: 5850
Joined: 14 Feb 2015 00:44
Location: Newcastle, Australia

Re: NML - a Newgrf Meta Language

Post by GarryG »

Started adding Industries to my new Industry set AuzInd160 and wanted to add a Bulk Grain Shed on a 2x2 tile set up. Normally we had to split the building into 4 pieces, but thanks to Quast65 with his idea of the 2x2 tile layout, I manage to put this idea in to the Industries.

Here's the sprite I used from Quast65 with the Grain Sheds. I only using the first 2.
grain_sheds_1.png
grain_sheds_1.png (7.37 KiB) Viewed 3306 times
and here's the code it the last entry in the file.
AuzInd160.nml
(6.61 MiB) Downloaded 75 times
Thought some of you might like it to use in your own sets.
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
User avatar
GarryG
Tycoon
Tycoon
Posts: 5850
Joined: 14 Feb 2015 00:44
Location: Newcastle, Australia

Re: NML - a Newgrf Meta Language

Post by GarryG »

Been able to use all 4 of the 2x2 tile sets that Quast65 made for Objects to also be used for Industrial Settings.
lakeandwatertower_1.png
lakeandwatertower_1.png (10.13 KiB) Viewed 3272 times
Here's a text file with the codes I used just for those Lakes.


Hope these help as you fellas have helped me in the past and most likely will help me in the future.

Can now make a building that covers a 2x2 tile without splitting it to single tiles.

Cheers

EDIT: I uploaded the wrong text file as there is an error in it at line 1751 .. I have 100 there should be 10_0

But here's another that been corrected.
Using all 4 2x2 Tiles.txt
(120.16 KiB) Downloaded 71 times
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 5 guests