NML - a Newgrf Meta Language

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

Moderator: Graphics Moderators

User avatar
Ammler
President
President
Posts: 953
Joined: 18 Jun 2006 18:18
Location: Switzerland
Contact:

Re: NML - a Newgrf Meta Language

Post by Ammler »

the DevZone does build the projects hosted there against every nml nightly, so you would be notified if your source is going to fail on newest nml... :-)
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 »

Hirundo wrote:
oberhümer wrote:Is "railtype_available()" supposed to work for the default types when no other track NewGRFs are loaded?
I'd think so, but only testing can find out.
It does, but this doesn't (i.e. no depot graphics are changed for the default types). I suspect that not enough is defined for each type, since it does work when there's a different GRF (I used Swedish Rails) using the default labels loaded before it, but the documentation says nothing about it.
Attachments
MLSD.zip
(119.39 KiB) Downloaded 161 times
mlsd.nml
(5.41 KiB) Downloaded 149 times
--- 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. ---
Hirundo
Transport Coordinator
Transport Coordinator
Posts: 298
Joined: 27 Jan 2008 13:02

Re: NML - a Newgrf Meta Language

Post by Hirundo »

oberhümer wrote:
Hirundo wrote:
oberhümer wrote:Is "railtype_available()" supposed to work for the default types when no other track NewGRFs are loaded?
I'd think so, but only testing can find out.
It does, but this doesn't (i.e. no depot graphics are changed for the default types). I suspect that not enough is defined for each type, since it does work when there's a different GRF (I used Swedish Rails) using the default labels loaded before it, but the documentation says nothing about it.
The documentation does say something about this:
It seems that implementation in OpenTTD is a bit inconsistent, though. If the overlay is defined, all other *-marked graphics are required and your railtype will look wrong if these are not defined. All non-marked callbacks except depots seem to be used if they are defined, even if the 'required' entries are not defined. Custom depot gfx are only used if overlays are defined.

As to why it works this way, I'm still in the dark.

Since your grf does not implement the required entries, it's not according to (NML) spec. That's the reason why it doesn't work, although I admit that it's quite confusing and not too well documented.
I may update the documentation and/or add warnings to NML when I know more about this.
Create your own NewGRF? Check out this tutorial!
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 »

Seems I misread, I thought it said "If a required callback is not implemented or fails"...
--- 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. ---
Hirundo
Transport Coordinator
Transport Coordinator
Posts: 298
Joined: 27 Jan 2008 13:02

Re: NML - a Newgrf Meta Language

Post by Hirundo »

Notice to developers of industry and object grfs:
Tonight the handling of the tile_check and location_check callbacks changed. Their return values have been unified, see here for details:
http://newgrf-specs.tt-wiki.net/wiki/NM ... ck_results

In the case of industry grfs, you'll see a compile error if anything needs fixing.

In the case of object grfs however, the callback will break silently as the old return values (0 or 1) will do different things than they did before. On the plus side, you can now choose between several built-in error messages or use a custom error message, which was not possible before this change.

The cargo profit calculation got changed too, but since no-one noticed that is was broken (off by a factor of 40 or so) before Terkhen told me this afternoon, I doubt that anyone will be affected by this.
Create your own NewGRF? Check out this tutorial!
Hirundo
Transport Coordinator
Transport Coordinator
Posts: 298
Joined: 27 Jan 2008 13:02

Re: NML - a Newgrf Meta Language

Post by Hirundo »

oberhümer wrote:
Hirundo wrote:
oberhümer wrote:Is "railtype_available()" supposed to work for the default types when no other track NewGRFs are loaded?
I'd think so, but only testing can find out.
It does, but this doesn't (i.e. no depot graphics are changed for the default types). I suspect that not enough is defined for each type, since it does work when there's a different GRF (I used Swedish Rails) using the default labels loaded before it, but the documentation says nothing about it.
As of tonight's OpenTTD nightly, a grf with only depot graphics will work as you expect. Refer to the NML documentation for more details.
Create your own NewGRF? Check out this tutorial!
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 »

My thanks to you. This means a new GRF soon...
--- 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. ---
Supercheese
Tycoon
Tycoon
Posts: 1660
Joined: 16 Dec 2007 22:24
Location: Idaho, USA

Re: NML - a Newgrf Meta Language

Post by Supercheese »

I can't seem to figure out how to work the sound_effect callback in NML, and the documentation is sorely lacking in example code. I want to set different sound effects I've created for different sound events for a vehicle (SOUND_EVENT_START and SOUND_EVENT_TUNNEL, for instance). Do I use a switch block or some such? I would be very grateful if someone could provide a code snippet to demonstrate...
Eyecandy Road Vehicles | Fake Subways | Supercheese's NewObjects

"Fashions and cultures change, but steam trains shall always be majestic."
-Professor Hershel Layton
Hirundo
Transport Coordinator
Transport Coordinator
Posts: 298
Joined: 27 Jan 2008 13:02

Re: NML - a Newgrf Meta Language

Post by Hirundo »

Supercheese wrote:I can't seem to figure out how to work the sound_effect callback in NML, and the documentation is sorely lacking in example code. I want to set different sound effects I've created for different sound events for a vehicle (SOUND_EVENT_START and SOUND_EVENT_TUNNEL, for instance). Do I use a switch block or some such? I would be very grateful if someone could provide a code snippet to demonstrate...
I assume you're able to code a basic vehicle, if not refer to http://www.tt-wiki.net/wiki/NMLTutorial for an excellent explanation.
In the sound_effect callback, the variable extra_callback_info1 contains the sound effect. It's indeed best to use a switch block for this purpose, it will look roughly like the following. The usual caveats (code not tested, may contain typos/errors) apply.

Code: Select all

// Assuming a train here
switch(FEAT_TRAINS, SELF, some_vehicle_sound_effect_switch, extra_callback_info1) {
    SOUND_EVENT_START: return sound("soundfile1.wav");
    SOUND_EVENT_TUNNEL: return sound("soundfile2.wav");
    CB_FAILED; // play default sound in other cases
}
// And then in the graphics block:
        sound_effect: some_vehicle_sound_effect_switch;
For a more detailed explanation of the possible return values, refer to the documentation of the sound_effect callback which you seem to have found already. (link)
Create your own NewGRF? Check out this tutorial!
Supercheese
Tycoon
Tycoon
Posts: 1660
Joined: 16 Dec 2007 22:24
Location: Idaho, USA

Re: NML - a Newgrf Meta Language

Post by Supercheese »

Awesome, thanks a lot, that was exactly what I was looking for! :bow:
Eyecandy Road Vehicles | Fake Subways | Supercheese's NewObjects

"Fashions and cultures change, but steam trains shall always be majestic."
-Professor Hershel Layton
akasoft
Engineer
Engineer
Posts: 120
Joined: 25 Aug 2011 11:48

Re: NML - a Newgrf Meta Language

Post by akasoft »

How can I specify the palette? (DOS or windows, like here)

grf {} block has such parameter? What is named?

Can I include NFO code block in .nml file?
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 »

akasoft wrote:How can I specify the palette? (DOS or windows, like here)

grf {} block has such parameter? What is named?

Can I include NFO code block in .nml file?
You can't specifiy the palette, it's automatically set, nor is setting it explicitly necessary: if all used graphics files are of the windows palette: the windows palette is used. If there's at least one DOS-paletted file, the DOS palette is used. The action14 property is always set automatically.
The DOS palette is the preferred and OpenTTD-native palette.

You cannot include NFO, it's a completely separate language.
akasoft
Engineer
Engineer
Posts: 120
Joined: 25 Aug 2011 11:48

Re: NML - a Newgrf Meta Language

Post by akasoft »

I use nmlc rev. 1662 and openttd rev. 22893.
I prepared russian.lng file for FIRS translation into Russian with gender/case/plural support. File attached.
I builded grf file with no errors. And used it in game.
In game all string with prefix "{G=m}" was displayed empty. Industry name, cargo name. String with other prefixes (e.g. "{G=f}", "{G=p}") displayed normally.
Screenshot attached (in Russian).

If I remove the prefix "{G=m}", then string without them displayed normally.

That the discrimination of men in openttd? :)

Bug or What I doing wrong?
russian.lng
(41.74 KiB) Downloaded 339 times
It's for Quarry Industry (STR_IND_QUARRY )
It's for Quarry Industry (STR_IND_QUARRY )
man_empty.png (6.45 KiB) Viewed 3564 times
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: NML - a Newgrf Meta Language

Post by Yexo »

Your language file looks fine, so it's either a bug in NML or in OpenTTD. Right now I'm trying to find out which one it is and fix it.
akasoft
Engineer
Engineer
Posts: 120
Joined: 25 Aug 2011 11:48

Re: NML - a Newgrf Meta Language

Post by akasoft »

I think that in the NML, as openttd normally shows the strings of russian.txt with "{G=m}".
akasoft
Engineer
Engineer
Posts: 120
Joined: 25 Aug 2011 11:48

Re: NML - a Newgrf Meta Language

Post by akasoft »

NFO fragment with "{G=m}" for "Metal" (STR_CARGO_NAME_METAL), in Russian "Металл".

Code: Select all

         "Р_С" 80 D1 83 "Р·Р°." 00
   68 * 2837     04 0B 87 41 00 DC C3 9E EE 82 9A 14 EE 82 9A 10 08 "Р_РчС" 82 "Р°Р>Р>о" 82 9A
         10 06 "Р_РчС" 82 "Р°Р>Р>Р°о" 82 9A 11 EE 82 9A 0E 01 D0 9C D0 B5 D1 82 "Р°Р>Р>о" 82
         9A 12 00 C3 9E 0E D0 9C D0 95 00 C3 9E EE 82 9A 0D " Р_РчС" 82 "Р°Р>Р>Р°" 00
and without "{G=m}"

Code: Select all

         "Р_С" 80 D1 83 "Р·Р°." 00
   68 * 2832     04 0B 87 41 00 DC C3 9E EE 82 9A 14 EE 82 9A 10 08 "Р_РчС" 82 "Р°Р>Р>о" 82 9A
         10 06 "Р_РчС" 82 "Р°Р>Р>Р°о" 82 9A 11 D0 9C D0 B5 D1 82 "Р°Р>Р>о" 82
         9A 12 00 C3 9E 0E D0 9C D0 95 00 C3 9E EE 82 9A 0D " Р_РчС" 82 "Р°Р>Р>Р°" 00
In hex:
with

Code: Select all

         D1 83 D0 B7 D0 B0 2E 00
   68 * 2837     04 0B 87 41 00 DC C3 9E EE 82 9A 14 EE 82 9A 10 08 D0 BC D0 B5 D1 82 D0 B0 D0 BB D0 BB EE 82 9A
         10 06 D0 BC D0 B5 D1 82 D0 B0 D0 BB D0 BB D0 B0 EE 82 9A 11 EE 82 9A 0E 01 D0 9C D0 B5 D1 82 D0
         B0 D0 BB D0 BB EE 82 9A 12 00 C3 9E 0E D0 9C D0 95 00 C3 9E EE 82 9A 0D 20 D0 BC D0 B5 D1 82 D0
         B0 D0 BB D0 BB D0 B0 00 C3 9E EE 82 9A 14 EE 82 9A 10 08 D1 81 D0 BF D0 B8 D1 80 D1 82 D0 BD D0
         BE D0 B5 EE 82 9A 10 06 D1 81 D0 BF D0 B8 D1 80 D1 82 D0 BD D0 BE D0 B3 D0 BE EE 82 9A 11 EE 82
         9A 0E 03 D0 A1 D0 BF D0 B8 D1 80 D1 82 D0 BD D0 BE D0 B5 EE 82 9A 12 00 C3 9E 0E D0 A1 D0 9F 00
         C3 9E EE 82 87 20 D1 81 D0 BF D0 B8 D1 80 D1 82 D0 BD D0 BE D0 B3 D0 BE 00 C3 9E EE 82 9A 14 EE
         82 9A 10 08 D0 BC D0 BE D0 BB D0 BE D0 BA D0 BE EE 82 9A 10 06 D0 BC D0 BE D0 BB D0 BE D0 BA D0
         B0 EE 82 9A 11 EE 82 9A 0E 03 D0 9C D0 BE D0 BB D0 BE D0 BA D0 BE EE 82 9A 12 00 C3 9E 0E D0 9C
         D0 9E 00 C3 9E EE 82 87 20 D0 BC D0 BE D0 BB D0 BE D0 BA D0 B0 00 C3 9E EE 82 9A 14 EE 82 9A 10
         08 D1 84 D1 80 D1 83 D0 BA D1 82 D1 8B EE 82 9A 10 06 D1 84 D1 80 D1 83 D0 BA D1 82 D0 BE D0 B2
without

Code: Select all

         D1 83 D0 B7 D0 B0 2E 00
   68 * 2832     04 0B 87 41 00 DC C3 9E EE 82 9A 14 EE 82 9A 10 08 D0 BC D0 B5 D1 82 D0 B0 D0 BB D0 BB EE 82 9A
         10 06 D0 BC D0 B5 D1 82 D0 B0 D0 BB D0 BB D0 B0 EE 82 9A 11 D0 9C D0 B5 D1 82 D0 B0 D0 BB D0 BB
         EE 82 9A 12 00 C3 9E 0E D0 9C D0 95 00 C3 9E EE 82 9A 0D 20 D0 BC D0 B5 D1 82 D0 B0 D0 BB D0 BB
         D0 B0 00 C3 9E EE 82 9A 14 EE 82 9A 10 08 D1 81 D0 BF D0 B8 D1 80 D1 82 D0 BD D0 BE D0 B5 EE 82
         9A 10 06 D1 81 D0 BF D0 B8 D1 80 D1 82 D0 BD D0 BE D0 B3 D0 BE EE 82 9A 11 EE 82 9A 0E 03 D0 A1
         D0 BF D0 B8 D1 80 D1 82 D0 BD D0 BE D0 B5 EE 82 9A 12 00 C3 9E 0E D0 A1 D0 9F 00 C3 9E EE 82 87
         20 D1 81 D0 BF D0 B8 D1 80 D1 82 D0 BD D0 BE D0 B3 D0 BE 00 C3 9E EE 82 9A 14 EE 82 9A 10 08 D0
         BC D0 BE D0 BB D0 BE D0 BA D0 BE EE 82 9A 10 06 D0 BC D0 BE D0 BB D0 BE D0 BA D0 B0 EE 82 9A 11
         EE 82 9A 0E 03 D0 9C D0 BE D0 BB D0 BE D0 BA D0 BE EE 82 9A 12 00 C3 9E 0E D0 9C D0 9E 00 C3 9E
         EE 82 87 20 D0 BC D0 BE D0 BB D0 BE D0 BA D0 B0 00 C3 9E EE 82 9A 14 EE 82 9A 10 08 D1 84 D1 80
         D1 83 D0 BA D1 82 D1 8B EE 82 9A 10 06 D1 84 D1 80 D1 83 D0 BA D1 82 D0 BE D0 B2 EE 82 9A 11 EE
Maybe, can help.
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: NML - a Newgrf Meta Language

Post by Yexo »

akasoft wrote:NFO fragment with "{G=m}" for "Metal" (STR_CARGO_NAME_METAL), in Russian "Металл".
Thanks for the offer, but NML is capable of producing NFO output that is a lot more readable than what you post here (use "-o firs.nfo" on the command line), and that is also what I'm using. The bug in this case is indeed in NML, I'll push a fix within the next hour.

Edit: NML r1663 fixes the problem.
akasoft
Engineer
Engineer
Posts: 120
Joined: 25 Aug 2011 11:48

Re: NML - a Newgrf Meta Language

Post by akasoft »

Tell me please the equivalent of Action7/9 in NML (example of usage). I want to skip several action like blocks item {}, spriteset, cargotable, switch, spritelayout and others.

But I get a error:
nmlc: "input", line #: spriteset may not appear inside a conditional block.
or (if I moved spriteset block above)
nmlc: An internal error has occurred:
nmlc-version: r1665 (cda3d3a99f14)
Error: (AttributeError) "'SpritesetCollection' object has no attribute 'ski
p_needed'".
Command: ['nmlc', '--nfo=skiptest.nfo', '--grf=skiptest.grf', 'skiptest.nml']

Location: File "nml\actions\action7.py", line #, in cond_skip_actions
skiptest_1.nml
(1.59 KiB) Downloaded 111 times
skiptest_2.nml
(1.59 KiB) Downloaded 120 times
Eddi
Tycoon
Tycoon
Posts: 8289
Joined: 17 Jan 2007 00:14

Re: NML - a Newgrf Meta Language

Post by Eddi »

like it says, you cannot skip spritesets, only item blocks.

the second error is a bug in NML.
akasoft
Engineer
Engineer
Posts: 120
Joined: 25 Aug 2011 11:48

Re: NML - a Newgrf Meta Language

Post by akasoft »

Well, I'll wait for bug fixes.
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: Bing [Bot] and 2 guests