NML - a Newgrf Meta Language
Moderator: Graphics Moderators
-
- Tycoon
- Posts: 1283
- Joined: 23 Oct 2009 19:35
- Location: Here and there, sometime or another
Re: NML - a Newgrf Meta Language
It can be fixed: http://newgrf-specs.tt-wiki.net/wiki/Ac ... troduction
--- 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. ---
- planetmaker
- OpenTTD Developer
- Posts: 9432
- Joined: 07 Nov 2007 22:44
- Location: Sol d
Re: NML - a Newgrf Meta Language
In NML that variable is - iirc - called extra_callback_info1. Not exactly sure right now whether it works outside callbacks for this distinction alone.
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
Ah, that feature is so new[0] that I wasn't even aware of it, thanks!oberhümer wrote:It can be fixed: http://newgrf-specs.tt-wiki.net/wiki/Ac ... troduction

[0] Well, relatively. It's still almost a 1000 revisions old...
Re: NML - a Newgrf Meta Language
..... BEER TRAM?
Re: NML - a Newgrf Meta Language
Hello, again!
I have question... When the bitmask_consist_info is calculeted?
I have two types of wagons in my consist. All "normal" wagons have switch to calculate bitmask_vehicle_info (0x08 mean "dangerous" cargo):
The special "buffer" wagon at the end of the consist use information from bitmask_consist_info (if the train carry dangerous cargo, this wagon must be empty):
But this don't work.
I allways have cargo_capacity=50.
What is wrong in my code?
I'm using nmlc 0.2.2
I have question... When the bitmask_consist_info is calculeted?
I have two types of wagons in my consist. All "normal" wagons have switch to calculate bitmask_vehicle_info (0x08 mean "dangerous" cargo):
Code: Select all
switch(FEAT_TRAINS, SELF, switch_zaes_bitmask, cargo_type_in_veh){
OIL_: return 0x08;
PETR: return 0x08;
RFPR: return 0x08;
return 0x00;
}
item(FEAT_TRAINS, item_zaes) {
...
graphics {
bitmask_vehicle_info: switch_zaes_bitmask;
}
}
Code: Select all
switch(FEAT_TRAINS, SELF, switch_eaos_capacity, (bitmask_consist_info & 0x08)){
0x08: return 0;
return 50;
}
item(FEAT_TRAINS, item_eaos) {
...
graphics {
cargo_capacity: switch_eaos_capacity;
purchase_cargo_capacity: return 50;
}
}

What is wrong in my code?
I'm using nmlc 0.2.2
- stevenh
- TTDPatch Developer
- Posts: 759
- Joined: 24 Jul 2005 05:07
- Location: Canberra, Australia
- Contact:
Re: NML - a Newgrf Meta Language
i.e. it wont work like:planetmaker wrote:In NML that variable is - iirc - called extra_callback_info1. Not exactly sure right now whether it works outside callbacks for this distinction alone.
Code: Select all
graphics {
purchase: series_70_purchase_sprite; //Purchase menu sprite
additional_text: return string(STR_70_SERIES_ADDITIONAL); //Additional text shown in purchase list
articulated_part: switch_series_70_articulated;
shorten_vehicle: switch_series_70_length;
cargo_capacity: switch_series_70_capacity;
purchase_cargo_capacity: series_70_purchase_sprite;
default: switch_series_70_sprites;
extra_callback_info1: series_70_purchase_sprite;
}
supermop wrote:..... BEER TRAM?
http://train.sakura.ne.jp/train/hiroden ... dex01.html
Re: NML - a Newgrf Meta Language
try linking 'default' to a switch block that queries variable 'extra_callback_info1'.
Re: NML - a Newgrf Meta Language
stevenh wrote:supermop wrote:..... BEER TRAM?
- stevenh
- TTDPatch Developer
- Posts: 759
- Joined: 24 Jul 2005 05:07
- Location: Canberra, Australia
- Contact:
Re: NML - a Newgrf Meta Language
Right, I chained it all together:FooBar wrote:try linking 'default' to a switch block that queries variable 'extra_callback_info1'.
Code: Select all
switch (FEAT_ROADVEHS, SELF, switch_series_70_sprites2, extra_callback_info1 ) {
0: series_70_part_0;
series_70_purchase_sprite;
}
switch (FEAT_ROADVEHS, SELF, switch_series_70_sprites, position_in_consist ) {
1: series_70_part_1;
2: series_70_part_2;
switch_series_70_sprites2; //default
}
graphics {
...
default: switch_series_70_sprites;
}
(See attachment)
- Attachments
-
- So close.
- NearlyCorrect.png (4 KiB) Viewed 3539 times
Re: NML - a Newgrf Meta Language
Now you only make the decision normal sprite / purchase sprite for part 0 of the vehicle.
Try something like this:
Note that I intoduced a dummy sprite that is completely transparent. Note that I did not test this code.
Try something like this:
Code: Select all
switch (FEAT_ROADVEHS, SELF, switch_series_70_sprites_real, position_in_consist ) {
1: series_70_part_1;
2: series_70_part_2;
series_70_part_0; //default
}
switch (FEAT_ROADVEHS, SELF, switch_series_70_sprites_window, position_in_consist ) {
0: series_70_purchase_sprite;
some_1px_transparent_sprite; //all other vehicle parts
}
switch (FEAT_ROADVEHS, SELF, switch_series_70_sprites_choice, extra_callback_info1 ) {
0: switch_series_70_sprites_real; //for vehicles on the map
switch_series_70_sprites_window; //for vehicles anywhere else
}
graphics {
...
default: switch_series_70_sprites_choice;
}
Re: NML - a Newgrf Meta Language
Nice, I once encountered a tram that was a bar in Helsinki, was not aware the concept was universal.
Re: NML - a Newgrf Meta Language
I just upgraded from nml 1792 to 1846 and now my grf doesn't build any more. I checked the documentation, but that's still the same. What has changed, and more importantly, what do I need to change to get it working again?
The code I get an error on is this:
The error I get is "Unrecognized identifier 'recolour_grai' encountered", with a reference to the second line of that code snippet. I'm surprized that it's unregcognized, as it's defined one line earlier...
Thanks!
The code I get an error on is this:
Code: Select all
recolour_grai = reserve_sprites(1);
replace(recolour_grai) {
recolour_sprite {
0xE5: 0x3F;
0xE8: 0x40;
0xE9: 0x41;
0xEA: 0x42;
0xEB: 0x43;
0xEC: 0x33;
0xED: 0x44;
0xEE: 0x34;
}
}
Thanks!
- planetmaker
- OpenTTD Developer
- Posts: 9432
- Joined: 07 Nov 2007 22:44
- Location: Sol d
Re: NML - a Newgrf Meta 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
Hmmm crap, I should have checked that first. Thanks though! 
I did some more testing myself, and can confirm that r1834 is working. It spits a huge amount of 'deprecated' warnings, but it works.
There are now some other issues with the grf not showing up ingame...
But let's upgrade OpenTTD first

I did some more testing myself, and can confirm that r1834 is working. It spits a huge amount of 'deprecated' warnings, but it works.
There are now some other issues with the grf not showing up ingame...
But let's upgrade OpenTTD first

Re: NML - a Newgrf Meta Language
Yeah, now I'm getting the 'unexpected sprite 123' warning other users were complaining about.
But I'm getting it on my railtype table. Which was working previously.
this is the table:
and that results in this in NFO:
Doesn't look too unexpected to me, really...
So I may be in the wrong topic with this problem...
EDIT: I've found that if I replace the railtypetable with the following that then the grf works:
But I'm getting it on my railtype table. Which was working previously.
this is the table:
Code: Select all
railtypetable {
RAIL,
ELRL,
metro: [MTRO, "3RDR"]
}
Code: Select all
// param[80] = 1380209203
121 * 9 0D 50 D= FF 00 dx52445233
122 * 9 09 00 04 0D dx4F52544D 01
// param[80] = 1330795597
123 * 9 0D 50 D= FF FF dx4F52544D
124 * 7 06
50 04 FF wx000E
FF
125 * 18 00 08 b1 03 00
12 "RAIL" "ELRL" "\00\00\00\00"
So I may be in the wrong topic with this problem...
EDIT: I've found that if I replace the railtypetable with the following that then the grf works:
Code: Select all
railtypetable {
RAIL,
ELRL,
metro: ["3RDR"]
}
Re: NML - a Newgrf Meta Language
As of today, NML fully supports 32bpp / extra zoom level sprites, including mask files. These are provided via the alternative_sprites block. Documentation can be found on the wiki (mainly here and here)
Create your own NewGRF? Check out this tutorial!
Re: NML - a Newgrf Meta Language
I have a question about the industry flags. Right now you can use flags like "build before 1950" and "allow ships and aircrafts", but is there anyway to customize these flags?
My scenario will begin around 1830, so a flag like "build before 1950" doesn't really help me. Is there anyway to create a factory like this with NML:
- Build on water
- Allow ships (but not aircrafts)
- Factory AND station accepts NO cargo
- Factory AND station supplies one type of cargo
The problem is that the flags are based on the Oil Rig... The factory part of Oil Rig doesn't require passengers or mail, but the station still accepts it.
Are there any workarounds or do you think more advanced flags will be available in the future?
My scenario will begin around 1830, so a flag like "build before 1950" doesn't really help me. Is there anyway to create a factory like this with NML:
- Build on water
- Allow ships (but not aircrafts)
- Factory AND station accepts NO cargo
- Factory AND station supplies one type of cargo
The problem is that the flags are based on the Oil Rig... The factory part of Oil Rig doesn't require passengers or mail, but the station still accepts it.
Are there any workarounds or do you think more advanced flags will be available in the future?
Re: NML - a Newgrf Meta Language
No, the flags are what they are. They're remains of basic TTD essentially.
If you want something different, you can replicate most (if not all) flags via callbacks. This allows you to customize allowing and disallowing construction any way you want. Including dates and building on water.
Allowing ships but not aircraft is not possible. You have to reuse the existing oil rig industry tile with builtin station. If you try to customize anything of that tile it will lose it's station capabilities.
Cargo acceptance and production is controlled via simple property definitions. Unless you want something really fancy, then there are some callbacks that may come in handy.
If you want something different, you can replicate most (if not all) flags via callbacks. This allows you to customize allowing and disallowing construction any way you want. Including dates and building on water.
Allowing ships but not aircraft is not possible. You have to reuse the existing oil rig industry tile with builtin station. If you try to customize anything of that tile it will lose it's station capabilities.
Cargo acceptance and production is controlled via simple property definitions. Unless you want something really fancy, then there are some callbacks that may come in handy.
- planetmaker
- OpenTTD Developer
- Posts: 9432
- Joined: 07 Nov 2007 22:44
- Location: Sol d
Re: NML - a Newgrf Meta Language
You cannot customize these build flags (they're for the default industries and mostly for hysterical reasons), but...Bad_Brett wrote:I have a question about the industry flags. Right now you can use flags like "build before 1950" and "allow ships and aircrafts", but is there anyway to customize these flags?
is still perfectly feasible. You need to implement that via the industry callbacks: http://newgrf-specs.tt-wiki.net/wiki/NM ... _callbacks . Namely I'd suggest to use- Build on water
- Allow ships (but not aircrafts)
- Factory AND station accepts NO cargo
- Factory AND station supplies one type of cargo
construction_probability (and return a different probability depending on the year)
location_check
I'm not sure exactly what you mean with the latter two points, though. You can of course define cargo acceptance and production as you want (max 3 input, max 2 output) and even change that via callback (though I'd not recommend to do that as those info are not supported by the GUI).
Check out the FIRS repository and source code for industries which do all this.
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
Thanks for the tips! I guess the best way is to use callbacks instead of the flags then.
My plan is to include fishing boats and a "fish resource". It would be strange if it was be possible to send mail to the fishes.
I've adjusted the output and input of my Oil Rig replacement. So if I click on the factory part of the Oil Rig, it doesn't accept passengers anymore. The problem is that the station part still accepts passengers and mail.planetmaker wrote: I'm not sure exactly what you mean with the latter two points, though. You can of course define cargo acceptance and production as you want (max 3 input, max 2 output) and even change that via callback (though I'd not recommend to do that as those info are not supported by the GUI).
Check out the FIRS repository and source code for industries which do all this.
My plan is to include fishing boats and a "fish resource". It would be strange if it was be possible to send mail to the fishes.

Who is online
Users browsing this forum: No registered users and 16 guests