Page 57 of 65

Re: NML - a Newgrf Meta Language

Posted: 12 May 2016 19:42
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.

Re: NML - a Newgrf Meta Language

Posted: 13 May 2016 14:19
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 5699 times
You will then end up with this:
Example22.png
Example22.png (10.98 KiB) Viewed 5699 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!

Re: NML - a Newgrf Meta Language

Posted: 13 May 2016 18:00
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.

Re: NML - a Newgrf Meta Language

Posted: 14 May 2016 21:45
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.

Re: NML - a Newgrf Meta Language

Posted: 17 May 2016 17:34
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 5271 times
Here is the .rar with GRF, code and graphics:
2x2.rar
(19.74 KiB) Downloaded 158 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:

Re: NML - a Newgrf Meta Language

Posted: 17 May 2016 21:38
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!

Re: NML - a Newgrf Meta Language

Posted: 17 May 2016 22:17
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.

Re: NML - a Newgrf Meta Language

Posted: 18 May 2016 02:07
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:

Re: NML - a Newgrf Meta Language

Posted: 18 May 2016 07:54
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.

Re: NML - a Newgrf Meta Language

Posted: 18 May 2016 22:39
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

Re: NML - a Newgrf Meta Language

Posted: 19 May 2016 15:11
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

Re: NML - a Newgrf Meta Language

Posted: 02 Jun 2016 10:15
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.

Re: NML - a Newgrf Meta Language

Posted: 02 Jun 2016 12:12
by 3iff
Do you want something like this...?
Unnamed, 1st Jan 1940#2.png
Unnamed, 1st Jan 1940#2.png (57.74 KiB) Viewed 4683 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.

Re: NML - a Newgrf Meta Language

Posted: 02 Jun 2016 12:54
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....

Re: NML - a Newgrf Meta Language

Posted: 02 Jun 2016 13:06
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.

Re: NML - a Newgrf Meta Language

Posted: 02 Jun 2016 13:29
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:

Re: NML - a Newgrf Meta Language

Posted: 02 Jun 2016 14:08
by 3iff
My pleasure. Glad I could locate the problem.

Re: NML - a Newgrf Meta Language

Posted: 02 Jun 2016 23:38
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

Re: NML - a Newgrf Meta Language

Posted: 07 Jun 2016 13:48
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 4350 times
and here's the code it the last entry in the file.
AuzInd160.nml
(6.61 MiB) Downloaded 203 times
Thought some of you might like it to use in your own sets.

Re: NML - a Newgrf Meta Language

Posted: 08 Jun 2016 05:14
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 4316 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 146 times