NML - a Newgrf Meta Language

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

Moderator: Graphics Moderators

Post Reply
oberhümer
Tycoon
Tycoon
Posts: 1283
Joined: 23 Oct 2009 19:35
Location: Here and there, sometime or another

Re: NML - a Newgrf Meta Language

Post by oberhümer »

I guess I didn't fix it on my testing copy then :roll:
--- Licenses: GNU LGPL, version 2 or newer, code and graphics. CC-By-SA, graphics, alternatively. If you're using any, I'd like to hear about it --- Call them "track types" ---
--- Mostly inactive developer for: NuTracks - Central European Train Set --- Running/compiling for: Linux (x86) - Android - Windows (32/64 bit) ---

--- Need a file packer? 7-Zip --- BOINC - use your computing power to benefit science --- Block trackers, not ads --- Unix in dispersible pellets, the formula for the future. ---
Eddi
Tycoon
Tycoon
Posts: 8254
Joined: 17 Jan 2007 00:14

Re: NML - a Newgrf Meta Language

Post by Eddi »

Yexo wrote:

Code: Select all

misc_flags: ROADVEH_FLAG_2CC;
Instead of the correct code

Code: Select all

misc_flags: bitmask(ROADVEH_FLAG_2CC);
Shouldn't NML be doing type checking to catch mistakes like these?
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: NML - a Newgrf Meta Language

Post by Yexo »

Please keep in mind all of the following are also valid nml code:

Code: Select all

param[1] = bitmask(ROADVEH_FLAG_2CC);
param[2] = 1;
misc_flags: param[param[2]];
Should NML still be able to detect the error in this case?

Code: Select all

misc_flags: 1;
Also valid, but did the user really wanted the value 1 (make it a tram) or did he want to set bit 1 so it would be

Code: Select all

misc_flags: bitmask(1);
, in which case it's not a tram but 2cc is enabled?
Eddi
Tycoon
Tycoon
Posts: 8254
Joined: 17 Jan 2007 00:14

Re: NML - a Newgrf Meta Language

Post by Eddi »

types are a tricky thing indeed. i imagine they had the same discussion 50 years ago when designing the first high level languages

the real question here is whether

Code: Select all

misc_flags: 1;
should throw an error, and i think it should. there should be an explicit cast to interpret a value as a bitmask.

lack of strict type checking will only bite you in the face and punch you in the arse in the long run.
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: NML - a Newgrf Meta Language

Post by Alberth »

Alternatively, you could introduce the concept 'bit-number' as numerical type. It may not work for every situation (I'd not forbid bitmask(1) ), but it may catch the large number of cases where the grf author uses pre-defined constants.
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: NML - a Newgrf Meta Language

Post by Yexo »

Eddi wrote:the real question here is whether

Code: Select all

misc_flags: 1;
should throw an error, and i think it should. there should be an explicit cast to interpret a value as a bitmask.
Here I disagree with you as allowing a literal number makes the conversion from nfo to nml a lot easier.
Eddi
Tycoon
Tycoon
Posts: 8254
Joined: 17 Jan 2007 00:14

Re: NML - a Newgrf Meta Language

Post by Eddi »

just to be clear: i mean something like

Code: Select all

misc_flags: bitvalue(1);
meaning a bitmask where bit 0 (value 1) is set, and

Code: Select all

misc_flags: bitmask(1);
meaning a bitmask where bit 1 (value 2) is set.

names of the conversion macros may be seen as "just a suggestion"
User avatar
Hyronymus
Tycoon
Tycoon
Posts: 13233
Joined: 03 Dec 2002 10:36
Location: The Netherlands
Contact:

Re: NML - a Newgrf Meta Language

Post by Hyronymus »

Is it possible to decompile a grf which has not been 'written'/made with NML?
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 »

Hyronymus wrote:Is it possible to decompile a grf which has not been 'written'/made with NML?
currently NewGRFs cannot (yet) be de-compiled into NML. The only available newgrf de-compiler is currently grfcodec which de-compiles into NFO only.
User avatar
Hyronymus
Tycoon
Tycoon
Posts: 13233
Joined: 03 Dec 2002 10:36
Location: The Netherlands
Contact:

Re: NML - a Newgrf Meta Language

Post by Hyronymus »

And thus there is no converter for NFO > NML either?!
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 »

Hyronymus wrote:And thus there is no converter for NFO > NML either?!
Unfortunately the answer currently is 'no'. Only the reverse works.
User avatar
DJ Nekkid
Tycoon
Tycoon
Posts: 2141
Joined: 30 Nov 2006 20:33

Re: NML - a Newgrf Meta Language

Post by DJ Nekkid »

Hyronymus wrote:And thus there is no converter for NFO > NML either?!

If you want to learn NFO i can teach you, just add me to msn :=)
Member of the
ImageImage
User avatar
Hyronymus
Tycoon
Tycoon
Posts: 13233
Joined: 03 Dec 2002 10:36
Location: The Netherlands
Contact:

Re: NML - a Newgrf Meta Language

Post by Hyronymus »

DJ Nekkid wrote:
Hyronymus wrote:And thus there is no converter for NFO > NML either?!

If you want to learn NFO i can teach you, just add me to msn :=)
I managed basic NFO once but I got and get lost with advanced NFO. If I could i.e. add cargo support to the Dutch Trainset that would be nice but I just don't get it. Also, the Dutch Trainset was written with GRFmaker so I'm not confident on how clean and standard the code is.
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 »

Hyronymus wrote: I managed basic NFO once but I got and get lost with advanced NFO. If I could i.e. add cargo support to the Dutch Trainset that would be nice but I just don't get it. Also, the Dutch Trainset was written with GRFmaker so I'm not confident on how clean and standard the code is.
grfmaker basically is incompatible with both nfo and nml sources, it's a completely separate format yet again.

If you want to kind-of start over with the Dutch trains, it's for a beginner probably easiest to start with NML - especially as you obviously got NML working. For getting started with trains you can look at OpenGFX+Trains' code. AFAIK everything wrt trains is supported in NML and the only thing I haven't (yet) coded into that set is an articulated vehicle, but that's feasable in NML, too (there's an articulated tram as regression test: http://dev.openttdcoop.org/projects/nml ... d_tram.nml).
User avatar
Hyronymus
Tycoon
Tycoon
Posts: 13233
Joined: 03 Dec 2002 10:36
Location: The Netherlands
Contact:

Re: NML - a Newgrf Meta Language

Post by Hyronymus »

planetmaker wrote:
Hyronymus wrote: I managed basic NFO once but I got and get lost with advanced NFO. If I could i.e. add cargo support to the Dutch Trainset that would be nice but I just don't get it. Also, the Dutch Trainset was written with GRFmaker so I'm not confident on how clean and standard the code is.
grfmaker basically is incompatible with both nfo and nml sources, it's a completely separate format yet again.

If you want to kind-of start over with the Dutch trains, it's for a beginner probably easiest to start with NML - especially as you obviously got NML working. For getting started with trains you can look at OpenGFX+Trains' code. AFAIK everything wrt trains is supported in NML and the only thing I haven't (yet) coded into that set is an articulated vehicle, but that's feasable in NML, too (there's an articulated tram as regression test: http://dev.openttdcoop.org/projects/nml ... d_tram.nml).
Hit me with a hammer hard enough and I might :P.
User avatar
AndersI
Tycoon
Tycoon
Posts: 1732
Joined: 19 Apr 2004 20:09
Location: Sweden
Contact:

Re: NML - a Newgrf Meta Language

Post by AndersI »

planetmaker wrote:
Hyronymus wrote:grfmaker basically is incompatible with both nfo and nml sources, it's a completely separate format yet again.
True, and false. You can use GRFMaker to produce NFO, but I don't know what would be the point. GRFMaker can also import NFO, but the import is not complete, and not completely correct.
User avatar
Aegir
Tycoon
Tycoon
Posts: 2883
Joined: 09 Feb 2004 10:02
Contact:

Re: NML - a Newgrf Meta Language

Post by Aegir »

AndersI wrote:
planetmaker wrote:
Hyronymus wrote:grfmaker basically is incompatible with both nfo and nml sources, it's a completely separate format yet again.
True, and false. You can use GRFMaker to produce NFO, but I don't know what would be the point. GRFMaker can also import NFO, but the import is not complete, and not completely correct.
*snort*

Nice to know after, what, how many years now that folks are still spreading misinformation about GRFMaker.

You tell 'em AndersI :)
Currently working under the name 'reldred' on Github, and Discord.
NFO/NML coder, part-time patch writer for JGRPP, and all round belligerent.

14:40 <orudge> I can't say I discriminate against any particular user
14:41 <Aegir> orudge: I can!
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 »

planetmaker wrote:grfmaker basically is incompatible with both nfo and nml sources, it's a completely separate format yet again.
Aegir wrote:Nice to know after, what, how many years now that folks are still spreading misinformation about GRFMaker.
Please stand by your snort and claim and show me the full grfmaker version of FIRS / SwedishRails / AirportsPlus / 2cctrainset.
AndersI wrote:You can use GRFMaker to produce NFO, but I don't know what would be the point. GRFMaker can also import NFO, but the import is not complete, and not completely correct.
Yes, the import of a grf (or nfo, not much difference) is unfortunately the really difficult thing as it requires semantical understanding of the grf and full knowledge of the target language (which are the full newgrf specs). That's something which for an export is not needed, any programme knows its own data formats after all. And one can limit output to a subset of the full newgrf specs and write 100% correct NewGRF.

Writing GRFs is a basic functionality for a NewGRF programming language, writing nfo then comes at relatively little extra costs. Given GRFMaker's "source" is a binary *.lst file (which is what I primarily had in mind when I said 'separate format'). Thus I think it's fair to say it has its own format - which is nothing bad, it just is so.

But possibly we should move any discussion needed about GRFMaker's to its own thread then.

EDIT: rephrased some misunderstandable wording.
User avatar
Aegir
Tycoon
Tycoon
Posts: 2883
Joined: 09 Feb 2004 10:02
Contact:

Re: NML - a Newgrf Meta Language

Post by Aegir »

planetmaker wrote:
planetmaker wrote:grfmaker basically is incompatible with both nfo and nml sources, it's a completely separate format yet again.
Aegir wrote:Nice to know after, what, how many years now that folks are still spreading misinformation about GRFMaker.
Please stand by your snort and claim and show me the full grfmaker version of FIRS / SwedishRails / AirportsPlus / 2cctrainset.
<snip>

I had something more vulgar to say, I'm not in the business of proving or justifying myself to the likes of anyone on this forum. You don't 'get' it, that's obvious. That's fine. Folks were spreading BS about GRFMaker five years ago too. :roll:
Currently working under the name 'reldred' on Github, and Discord.
NFO/NML coder, part-time patch writer for JGRPP, and all round belligerent.

14:40 <orudge> I can't say I discriminate against any particular user
14:41 <Aegir> orudge: I can!
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: NML - a Newgrf Meta Language

Post by Yexo »

And that does help exactly how? If GRFMaker really can do more than what planetmaker descriped please enlighten us. If you don't want to, fine, but keep out of here.
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 5 guests