
NML - a Newgrf Meta Language
Moderator: Graphics Moderators
Re: NML - a Newgrf Meta Language
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... 

Town Names:


Still work in progress: OpenGFX or/and OpenSFX - Please help!
-
- Tycoon
- Posts: 1283
- Joined: 23 Oct 2009 19:35
- Location: Here and there, sometime or another
Re: NML - a Newgrf Meta Language
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.Hirundo wrote:I'd think so, but only testing can find out.oberhümer wrote:Is "railtype_available()" supposed to work for the default types when no other track NewGRFs are loaded?
--- 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. ---
--- 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. ---
Re: NML - a Newgrf Meta Language
The documentation does say something about this:oberhümer wrote: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.Hirundo wrote:I'd think so, but only testing can find out.oberhümer wrote:Is "railtype_available()" supposed to work for the default types when no other track NewGRFs are loaded?
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.http://newgrf-specs.tt-wiki.net/wiki/NML:Railtypes#Railtype_callbacks wrote:The entries marked by * are required.
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!
-
- Tycoon
- Posts: 1283
- Joined: 23 Oct 2009 19:35
- Location: Here and there, sometime or another
Re: NML - a Newgrf Meta Language
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. ---
--- 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. ---
Re: NML - a Newgrf Meta Language
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.
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!
Re: NML - a Newgrf Meta Language
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.oberhümer wrote: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.Hirundo wrote:I'd think so, but only testing can find out.oberhümer wrote:Is "railtype_available()" supposed to work for the default types when no other track NewGRFs are loaded?
Create your own NewGRF? Check out this tutorial!
-
- Tycoon
- Posts: 1283
- Joined: 23 Oct 2009 19:35
- Location: Here and there, sometime or another
Re: NML - a Newgrf Meta Language
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. ---
--- 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. ---
-
- Tycoon
- Posts: 1660
- Joined: 16 Dec 2007 22:24
- Location: Idaho, USA
Re: NML - a Newgrf Meta Language
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
"Fashions and cultures change, but steam trains shall always be majestic."
-Professor Hershel Layton
Re: NML - a Newgrf Meta Language
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.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...
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;
Create your own NewGRF? Check out this tutorial!
-
- Tycoon
- Posts: 1660
- Joined: 16 Dec 2007 22:24
- Location: Idaho, USA
Re: NML - a Newgrf Meta Language
Awesome, thanks a lot, that was exactly what I was looking for! 

Eyecandy Road Vehicles | Fake Subways | Supercheese's NewObjects
"Fashions and cultures change, but steam trains shall always be majestic."
-Professor Hershel Layton
"Fashions and cultures change, but steam trains shall always be majestic."
-Professor Hershel Layton
Re: NML - a Newgrf Meta Language
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?
grf {} block has such parameter? What is named?
Can I include NFO code block in .nml file?
- planetmaker
- OpenTTD Developer
- Posts: 9432
- Joined: 07 Nov 2007 22:44
- Location: Sol d
Re: NML - a Newgrf Meta Language
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.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?
The DOS palette is the preferred and OpenTTD-native palette.
You cannot include NFO, it's a completely separate language.
OpenTTD: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML
Re: NML - a Newgrf Meta Language
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?
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?
Re: NML - a Newgrf Meta Language
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.
Re: NML - a Newgrf Meta Language
I think that in the NML, as openttd normally shows the strings of russian.txt with "{G=m}".
Re: NML - a Newgrf Meta Language
NFO fragment with "{G=m}" for "Metal" (STR_CARGO_NAME_METAL), in Russian "Металл".
and without "{G=m}"
In hex:
with
without
Maybe, can help.
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
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
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
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
Re: NML - a Newgrf Meta Language
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.akasoft wrote:NFO fragment with "{G=m}" for "Metal" (STR_CARGO_NAME_METAL), in Russian "Металл".
Edit: NML r1663 fixes the problem.
Re: NML - a Newgrf Meta Language
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:
But I get a error:
or (if I moved spriteset block above)nmlc: "input", line #: spriteset may not appear inside a conditional block.
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
Re: NML - a Newgrf Meta Language
like it says, you cannot skip spritesets, only item blocks.
the second error is a bug in NML.
the second error is a bug in NML.
Re: NML - a Newgrf Meta Language
Well, I'll wait for bug fixes.
Who is online
Users browsing this forum: Bing [Bot] and 2 guests