NML - a Newgrf Meta Language

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

Moderator: Graphics Moderators

Transportman
Tycoon
Tycoon
Posts: 2781
Joined: 22 Feb 2011 18:34

Re: NML - a Newgrf Meta Language

Post by Transportman »

I need some help with one of the vehicles in the 2cc Trainset, I have a vehicle with an articulated part (as the vehicle is longer than 8/8), but for some reason the articulated part is not build, and I do not see where the problem is, as everything else works fine. The source code can be found in this folder. Can someone help me out with this?
Coder of the Dutch Trackset | Development support for the Dutch Trainset | Coder of the 2cc TrainsInNML
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: NML - a Newgrf Meta Language

Post by planetmaker »

Did you try to replace the '1' by a '0'?

Code: Select all

	1: return item_rbm_World_Turbobus;
Transportman
Tycoon
Tycoon
Posts: 2781
Joined: 22 Feb 2011 18:34

Re: NML - a Newgrf Meta Language

Post by Transportman »

planetmaker wrote:Did you try to replace the '1' by a '0'?

Code: Select all

	1: return item_rbm_World_Turbobus;
I tried that, but does not work, and would also be strange as the rest of the vehicles in the set with articulated part do work with a 1.
Coder of the Dutch Trackset | Development support for the Dutch Trainset | Coder of the 2cc TrainsInNML
User avatar
GarryG
Tycoon
Tycoon
Posts: 5920
Joined: 14 Feb 2015 00:44
Location: Newcastle, Australia

Re: NML - a Newgrf Meta Language

Post by GarryG »

I need some help.

I tried many times to try build on slopes and what I been successful with have the blue question marks. I've looked at other peoples projects where slopes are involved, and tried using there samples, but to no avail. When I tried what I thought just got error messages and other problems.

I've uploaded Auz_Roadside_Objects here .. Called it
HelpPlease.rar
(3.42 MiB) Downloaded 73 times
If some one can have a look at it and just fix 2 places I marked "/* HELP REQUIRED HERE */"
One is gravelslope1 and the other is Riders4.

The reason hope can fix 2 I can compare if any difference and hope this will help me fix all the others in this project as well as in Auz_Lineside_Objects.

If someone be kind enough to add what ever I am missing in just these 2 places and send it back to me, then I hope I can learn enough from that to do the rest in this project as well as the Auz_Lineside_Objects.

Do hope someone will be help.

Thank you kindly

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
Eddi
Tycoon
Tycoon
Posts: 8273
Joined: 17 Jan 2007 00:14

Re: NML - a Newgrf Meta Language

Post by Eddi »

planetmaker wrote:Did you try to replace the '1' by a '0'?

Code: Select all

	1: return item_rbm_World_Turbobus;
that's nonsense, as the articulated callback is never called for the 0th vehicle (that's the vehicle currently being built, so its type is already known)
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: NML - a Newgrf Meta Language

Post by planetmaker »

GarryG wrote:I need some help.
(...)
You're a good guy, I like your work a lot, and your questions are usually good and solid, you're polite, you're matter-of-fact and you spell and express yourself reasonably :) Yet, let me take your last posting in order to explain a bit why an answer might take so long... to sketch what makes the difference between an average and a really good question.
You do many things right with that question, you (probably) provide all the information one might need. But it comes short in one point: you don't make it easy to help you. I am rather busy currently and so far always felt lazy; too lazy to download a rar archive, too lazy to install an unrar programme (rar archives compress worse than xz, and are less common than zip), too lazy to dig the complete source. However I visited the forums several times since you asked

It would be easier to help, if - additional to the complete picture you (hopefully) posted inside that rar archive
* Tell exactly you tried! And thus show us what your understanding is of the situation - you do not show us anything here, don't show that you looked at the issue beyond recognizing "doesn't work".
* Show the relevant code snippets directly here. Maybe it's something more or less obvious. If not, there's still the full picture in the archive you attached.
* How did your attempts differ from the solutions that are known to work? Maybe that gives a hint, if not to you when spelling it out, maybe someother person will notice directly when seeing it.
* What are the "error messages and other problems" you ran into exactly? Without spelling that out in detail, it also sparks the feeling that the person helping you might dig in deeper into it than you already did. And if you did try a lot: why should we try the exact same thing and thus possibly do the same mistakes again?

Put together this way, it's my own words. Questions who answer all this have a higher chance to get a quick and yet still possibly satisfying answer - as it's easy. I can have a look during lunch break without access to any tools and stuff without trying much myself; all I need would be a browser. And the links above kinda indicate that I'm not alone with this, I think ;)

Ok, and now after I wrote this rant, I wanted to end on a constructive note and actually *try* to have a look at your problem and try offering a solution to your issues before I hit the sent button on this posting. However your rar file is password-protected. DANG! Sorry mate, looks like rant-only - depsite the fact that you probably don't deserve it. Seriously, though, you need a public repository for this project ;)
User avatar
Quast65
Tycoon
Tycoon
Posts: 2674
Joined: 09 Oct 2011 13:51
Location: The Netherlands

Re: NML - a Newgrf Meta Language

Post by Quast65 »

Hi Planetmaker,

I appreciate that you are willing to look into this issue and I understand that it is very difficult to look at pieces of codes of projects you are not busy with yourself (and that way, you might not have all the files needed).
However, I took a look at NML-coding myself and I think I have found the solution to Garry's problems. I have already PM-ed him about that.

The main issue for the questionmarks in the purchasemenu was, that the ground-tile in the menu wasnt defined and also I found out how to make ground-tiles snow- and desert-aware.
Also not all of the boundingboxes of the possible views were defined, that also gave some issues.

So I think I can help Garry with fixing it ;-)


However, I have a question for you, if you dont mind ;-)
Is it already possible to referr to a sloped ground-tile in the purchasemenu? If not, will that ever be possible?
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: 5920
Joined: 14 Feb 2015 00:44
Location: Newcastle, Australia

Re: NML - a Newgrf Meta Language

Post by GarryG »

Hi Planetmaker,

Thanks for your kind words.

To try and work out how to do things in NML I try to use the examples that came with NML. I open the NML in example_object.nml and copy and paste what I think I need from here to my files and change the references .. Where in this NML they refer to company_land I change that to what ever my object name is.

Some other NML files I went into to try figure out what to do are from FarmObjects, Logging Camp, FRISS, and a few others hoping to get the gist what to do .. but when I ran nmlc to see if what I did worked .. it not work. I changed and rem different things hoping I get it right .. but still no go.

Not understand while the rar file I uploaded is password-protected .. I just copied it down and it unzipped ok.

Quast65 has sent me some information so I'll see if I get this to work and let you know the results .. unfortunate I not be able to check it out till this evening as I off to me regular medical appointments .. have to keep these doctors in a job and be gone most of the day.

Cheers pal

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
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: NML - a Newgrf Meta Language

Post by planetmaker »

Quast65 wrote:Hi Planetmaker,

I appreciate that you are willing to look into this issue and I understand that it is very difficult to look at pieces of codes of projects you are not busy with yourself (and that way, you might not have all the files needed).
However, I took a look at NML-coding myself and I think I have found the solution to Garry's problems. I have already PM-ed him about that.

The main issue for the questionmarks in the purchasemenu was, that the ground-tile in the menu wasnt defined and also I found out how to make ground-tiles snow- and desert-aware.
Also not all of the boundingboxes of the possible views were defined, that also gave some issues.

So I think I can help Garry with fixing it ;-)


However, I have a question for you, if you dont mind ;-)
Is it already possible to referr to a sloped ground-tile in the purchasemenu? If not, will that ever be possible?
So you found a solution and didn't even bother telling people here, keeping them pointlessly busy and post the answers to public questions in private? And I get a nice (also private request by SwissFan, who actually made me look? C'mon guys, I really DO NOT appreciate such behaviour! Am I here in kindergarden? Is this a one-way thing only? Do the other people not part of your elite NewGRF coding circle not deserve the answer to the questions which you encountered but bothered to ask publicly? Does solving it privatly and secretly make you look beter? Especially when it is then asked again all over next month by another person possibly?!

Now I'm really annoyed. And yes, was a bad day, thanks. You can refer to any tile at any place you like. However in a purchase menu you will never *have* a tile, yet you are free to *assume* any slope you are happy with; but referencing / querying a tile will never work

EDITED for clarity
User avatar
Quast65
Tycoon
Tycoon
Posts: 2674
Joined: 09 Oct 2011 13:51
Location: The Netherlands

Re: NML - a Newgrf Meta Language

Post by Quast65 »

planetmaker wrote:
Quast65 wrote:Hi Planetmaker,

I appreciate that you are willing to look into this issue and I understand that it is very difficult to look at pieces of codes of projects you are not busy with yourself (and that way, you might not have all the files needed).
However, I took a look at NML-coding myself and I think I have found the solution to Garry's problems. I have already PM-ed him about that.

The main issue for the questionmarks in the purchasemenu was, that the ground-tile in the menu wasnt defined and also I found out how to make ground-tiles snow- and desert-aware.
Also not all of the boundingboxes of the possible views were defined, that also gave some issues.

So I think I can help Garry with fixing it ;-)


However, I have a question for you, if you dont mind ;-)
Is it already possible to referr to a sloped ground-tile in the purchasemenu? If not, will that ever be possible?
So you found a solution and didn't bother telling people here, keeping them pointlessly busy and post the answers to public questions in private? Am I here in kindergarden, is this a one-way thing only, where some people don't deserve the answer to the questions publicly so that it remains apparently open and is asked again all over next month?!

Now I'm really annoyed.

I have just found this out two hours ago my friend and it has not been tested with Garry's work yet. Trust me, I will share this!! Please do not be annoyed, it was not intended that way to p*ss you off!
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: 2674
Joined: 09 Oct 2011 13:51
Location: The Netherlands

Re: NML - a Newgrf Meta Language

Post by Quast65 »

Sorry for the double post, but I saw you edited your post Planetmaker. I will try to explain why I posted my reply a couple of posts back.

As you may or may not know I have a bit of knowledge of NFO-coding. But I had no experience at all with NML-coding.
I knew that Garrys problem was very simply fixable in NFO and thus probably also in NML.
The first time he asked for help was 24th of February, almost a month ago!!!!! http://www.tt-forums.net/viewtopic.php? ... 0#p1164627
I have even pointed out a couple of times what the probable issues were (not all boundingboxes defined and also missing groundsprites for the purchase menu).
But no-one was helping as far as I knew. So I even offered to completely recode his entire work into NFO, so the issues would be solved and he could focus on his fantastic graphical work.

However, from experience, I know that it is very handy to be able to code your graphical work yourself, so you can instantly see how your work looks ingame, if it is ok or what changes should be made.
And, knowing a bit about Garrys medical condition, I knew that NFO wasnt the best solution for him.

So today, I took it on myself to spend an entire day reading up on NML, trying out tutorials and ploughing through threads to get even more information.
And just a couple of hours ago I managed to find a solution in NML for his issues and even more things that could be helpfull (mainly regarding ground-tiles being climate-, snowhights- and desert-aware).

As I already had contact with him via PM (mostly concerning a lot of tiny graphical errors that would otherwise flood his development thread and would take the focus of the main things he was discussing and showing publically), I informed him and send him my solution via PM.
After this I was reading a bit more in the forums and saw that at almost the exact moment I offered Garry a solution, you very kindly offered to help him out too.
And as we are are all doing this stuff voluntarily and in our (for some not that greatly available) free time, I thought it was a good idea to inform you as soon as possible that someone else was also doing this, to avoid people doing unneccessary double work.

I regret and apologize if that first post of mine made you think that you were simply pushed aside and that your offer for looking at these issues was not appreciated. I hope this explains that that was absolutely not the case!!!
Also, there is no elite coding circle. I take pride in being one of the few people that are able to draw and code AND always shares all his work, solutions and problems with the community! I hope that all of my work being GPL-licensed and my many and various posts in these forums shows that.

I hope this all will make you a little less annoyed and please keep up the great work that you are doing for this game and community!
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: 5920
Joined: 14 Feb 2015 00:44
Location: Newcastle, Australia

Re: NML - a Newgrf Meta Language

Post by GarryG »

Hi all, especially Planetmaker and Quast65,

Looks like all is working fine now thanks to everyone.

So that others can learn what was so hard to try show me .. here is a copy of the source files to my project Auz_Roadside_Objects. It also includes the newgrf file.

Goes to show great minds think alike .. where Planetmaker and Quast65 unknown to each other both started to help me with this problem same day and looks like same time. Thanks guys for everything.

Hope not I can make these Object projects even better. Now lets me start planning other ideas to include.

Other the next few days hope to re-code the Auz_Lineside_Objects .. being a bigger file I expect it will take me a bit longer.

I had to have physio today .. I swear those fella have a licence to torcher :)

Thanks again

Garry
Attachments
AuzRoadsideObjectsSourceCodes.rar
(5.71 MiB) Downloaded 53 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
Transportman
Tycoon
Tycoon
Posts: 2781
Joined: 22 Feb 2011 18:34

Re: NML - a Newgrf Meta Language

Post by Transportman »

Transportman wrote:I need some help with one of the vehicles in the 2cc Trainset, I have a vehicle with an articulated part (as the vehicle is longer than 8/8), but for some reason the articulated part is not build, and I do not see where the problem is, as everything else works fine. The source code can be found in this folder. Can someone help me out with this?
I think I found the problem, and I want to apologize for not pointing to the file that creates the problem. In the 2cc Trainset all vehicle IDs are set from one central file, and the ID for this vehicle I have problems with is 17000. If I change it to 15000 the articulated part works properly.

So, as follow-up question, is there a way to make the articulated_part callback work with higher vehicle IDs, or should I reshuffle the vehicle IDs in the set to end below a certain ID? The first option is preferred, but the second option of reshuffling the vehicle IDs is also possible as I use a very generous spacing of 1000 IDs per type.
Coder of the Dutch Trackset | Development support for the Dutch Trainset | Coder of the 2cc TrainsInNML
User avatar
Quast65
Tycoon
Tycoon
Posts: 2674
Joined: 09 Oct 2011 13:51
Location: The Netherlands

Re: NML - a Newgrf Meta Language

Post by Quast65 »

Hi all!

I have a question about the additional text in the purchase menu.
In NFO-code it is possible to get a different text for each view in the purchase menu, is this also possible in NML? And if so, how?
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.
Transportman
Tycoon
Tycoon
Posts: 2781
Joined: 22 Feb 2011 18:34

Re: NML - a Newgrf Meta Language

Post by Transportman »

Quast65 wrote:Hi all!

I have a question about the additional text in the purchase menu.
In NFO-code it is possible to get a different text for each view in the purchase menu, is this also possible in NML? And if so, how?
Not sure how it works in NFO, but can't you use the additional_text callback with a switch to determine the view you want to show the text for? If the variable you need to use is not available in NML, you can also use the NFO variable to check against in the switch.
Coder of the Dutch Trackset | Development support for the Dutch Trainset | Coder of the 2cc TrainsInNML
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: NML - a Newgrf Meta Language

Post by planetmaker »

User avatar
Quast65
Tycoon
Tycoon
Posts: 2674
Joined: 09 Oct 2011 13:51
Location: The Netherlands

Re: NML - a Newgrf Meta Language

Post by Quast65 »

Uhm... Yes, I think.
I mean the text that shows up in the purchase menu here:
Auz44.png
Auz44.png (24.88 KiB) Viewed 3409 times
I have figured out how to get that text in NML, using this codeline:

Code: Select all

additional_text:    string(STR_OBJECT1_PURCHASE);
STR_OBJECT1_PURCHASE is then defined in my .lng with the actual text that I want to show up.
But now the text is the same for all 4 views, in NFO it can be different per view.

So, is this possible also for NML?
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
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: NML - a Newgrf Meta Language

Post by planetmaker »

Like transportman writes: use a switch and query the view.

Something like (pseudo-code):

Code: Select all

switch add_text_switch(FEATURE_BLAH, ..., view) {
1: string(STR_TEXT_VIEW2);
2: string(STR_TEXT_VIEW3);
3: string(STR_TEXT_VIEW4);
default: string(STR_TEXT_VIEW1);
}

(...)

additional_text: add_text_switch;
User avatar
Quast65
Tycoon
Tycoon
Posts: 2674
Joined: 09 Oct 2011 13:51
Location: The Netherlands

Re: NML - a Newgrf Meta Language

Post by Quast65 »

Thnx! With this I think I will be able to complete an example code for single-tile objects that are snow-aware (so a different graphic when placed on or above snowline) and with ground-tiles that adapt to the various snow-lines.
And also with separate graphics for the purchase-menu including additional text per view.
Maybe this example can be handy for other or new coders ;-)

By the way, if I understand correctly. Switches are what used to be Variable Action 2's in NFO?
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.
Eddi
Tycoon
Tycoon
Posts: 8273
Joined: 17 Jan 2007 00:14

Re: NML - a Newgrf Meta Language

Post by Eddi »

Transportman wrote:
Transportman wrote:I need some help with one of the vehicles in the 2cc Trainset, I have a vehicle with an articulated part (as the vehicle is longer than 8/8), but for some reason the articulated part is not build, and I do not see where the problem is, as everything else works fine. The source code can be found in this folder. Can someone help me out with this?
I think I found the problem, and I want to apologize for not pointing to the file that creates the problem. In the 2cc Trainset all vehicle IDs are set from one central file, and the ID for this vehicle I have problems with is 17000. If I change it to 15000 the articulated part works properly.

So, as follow-up question, is there a way to make the articulated_part callback work with higher vehicle IDs, or should I reshuffle the vehicle IDs in the set to end below a certain ID? The first option is preferred, but the second option of reshuffling the vehicle IDs is also possible as I use a very generous spacing of 1000 IDs per type.
no, articulated parts must have IDs below 16384 (0x4000), i.e. a 14 bit number. this is because the callback has 15 bits and the highest bit has special meaning (reverse the vehicle). there is no way to circumvent this.

also, as a corner case, the highest possible vehicle ID (0x3FFF) cannot be reversed, as the value 0x7FFF means "no more vehicles"
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 3 guests