Yes, it is possible, but the documentation for NML is still by far not as extensive as the documentation for the underlying NFO language. Therefore it is often useful to also read the nfo documentation at http://wiki.ttdpatch.net/tiki-index.php ... phicsSpecs The documentation for callback 16 (not 19) which is used to created articulated vehicles can be found here: http://wiki.ttdpatch.net/tiki-index.php ... allback_16_BarthVader wrote:I looked into the documentation but I can't find anything about how to make articulated vehicles. Is it possible?
NML - a Newgrf Meta Language
Moderator: Graphics Moderators
Re: NML - a Newgrf Meta Language
Re: NML - a Newgrf Meta Language
This is supported since NML r1080. In your railtype table you can now instead of just an identifier (like 3RDR) also use a literal string (like "3RDR"). Identifiers are not allowed to start with a number, but strings are. To reference the railtype later in your code use the builtin function railtype (like: railtype("3RDR")).oberhümer wrote:2. Less important: NML can't handle numbers in railtype names. This makes it hard, if not impossible, to make third rail (3RDR) vehicles.
-
- Tycoon
- Posts: 1283
- Joined: 23 Oct 2009 19:35
- Location: Here and there, sometime or another
Re: NML - a Newgrf Meta Language
Thank you very much for that.
--- 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. ---
-
- Engineer
- Posts: 10
- Joined: 02 Oct 2010 18:47
Re: NML - a Newgrf Meta Language
Could I ask for some example?
edit: Example of articulated vehicle coded in NML. I've already checked those projects and couldn't find one.
edit: Example of articulated vehicle coded in NML. I've already checked those projects and couldn't find one.
Last edited by BarthVader on 10 Dec 2010 14:15, edited 1 time in total.
- planetmaker
- OpenTTD Developer
- Posts: 9432
- Joined: 07 Nov 2007 22:44
- Location: Sol d
Re: NML - a Newgrf Meta Language
Of what?BarthVader wrote:Could I ask for some example?
If you mean NML projects in general, check out OpenGFX+RV, +Airports, +Trains, +Industries, SwedishRails and a number of TownName NewGRFs as found on the DevZone.
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
A simple tram with 4 parts coded in NML (tram foster expression from ogfx+rv, made into an articulated vehicle by attaching the engine to itself 3 times).
Code: Select all
template tmpl_tram(x, y) {
[ x, y, 8, 18, -3, -10]
[ 16 + x, y, 20, 18, -14, -5]
[ 48 + x, y, 28, 15, -14, -8]
[ 96 + x, y, 20, 18, -6, -7]
[128 + x, y, 8, 18, -3, -10]
[144 + x, y, 20, 18, -14, -9]
[176 + x, y, 28, 15, -14, -8]
[224 + x, y, 20, 18, -6, -7]
}
spriteset(foster_express_set, "tram_foster_express.png") {
tmpl_tram(48,1)
}
spritegroup foster_express_group {
loading: foster_express_set;
loaded: foster_express_set;
}
switch(FEAT_ROADVEHS, SELF, foster_express_articulated_parts, extra_callback_info1) {
1..3: return 88;
CB_FAILED;
}
switch(FEAT_ROADVEHS, SELF, foster_express_callbacks, current_callback) {
VEH_CB_ARTICULATED_PARTS: foster_express_articulated_parts;
foster_express_group;
}
item(FEAT_ROADVEHS, foster_express_tram, 88) {
property {
name: string(STR_NAME_FOSTER_EXPRESS);
climates_available: ALL_CLIMATES;
model_life: 40; // years
vehicle_life: 30; // years
introduction_date: date(1965,1,1);
reliability_decay: 1;
running_cost_base: RUNNING_COST_ROADVEH; // Default road vehicle running cost base
running_cost_factor: 135;
cost_factor: 143;
speed: 75 km/h;
power: 220 hp;
weight: 22 ton;
sprite_id: SPRITE_ID_NEW_ROADVEH; // We have our own sprites
loading_speed: 16; // loading speed
tractive_effort_coefficient: 0.3;
air_drag_coefficient: 0.5;
cargo_capacity: 45; // passengers
refittable_cargo_classes: bitmask(CC_PASSENGERS); // Allow passengers (and tourists)
non_refittable_cargo_classes: NO_CARGO_CLASS; // Disallow other cargos
refittable_cargo_types: 0;
misc_flags: bitmask(ROADVEH_FLAG_TRAM); // This is a tram
callback_flags: bitmask(VEH_CBF_ARTICULATED_PARTS);
}
graphics {
foster_express_callbacks;
}
}
- Attachments
-
- tram_foster_express.png (2.39 KiB) Viewed 5405 times
-
- Engineer
- Posts: 10
- Joined: 02 Oct 2010 18:47
Re: NML - a Newgrf Meta Language
Well, thanks a lot.
-
- Engineer
- Posts: 10
- Joined: 02 Oct 2010 18:47
Re: NML - a Newgrf Meta Language
How to code wagons that can be used to make articulated vehicles but can't be used separately (e. g. tenders)?
Already checked TTDPatch Wiki, nothing there.
Already checked TTDPatch Wiki, nothing there.
- planetmaker
- OpenTTD Developer
- Posts: 9432
- Joined: 07 Nov 2007 22:44
- Location: Sol d
Re: NML - a Newgrf Meta Language
You need add to each engine the VEH_CB_CAN_ATTACH_WAGON callback and check for the vehicleID of the wagon to be attached - and fail for those engines where it must not be attached to. You can - afaik - not prevent the wagon being attached to engines from another set which allow other wagons. Or use VEH_CB_ARTICULATED_PARTS for articulated vehicles, but that still doesn't prevent the wagon to be attached to other engines.BarthVader wrote:How to code wagons that can be used to make articulated vehicles but can't be used separately (e. g. tenders)?
Already checked TTDPatch Wiki, nothing there.
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
Planetmaker: while everything you write is true, it's not an answer to the question asked. The question was about articulated vehicles.
Just set "climates_available" to "NO_CLIMATE".BarthVader wrote:How to code wagons that can be used to make articulated vehicles but can't be used separately (e. g. tenders)?
Already checked TTDPatch Wiki, nothing there.
-
- Engineer
- Posts: 10
- Joined: 02 Oct 2010 18:47
Re: NML - a Newgrf Meta Language
Wow... it was so easy... Thanks again.
-
- Tycoon
- Posts: 1283
- Joined: 23 Oct 2009 19:35
- Location: Here and there, sometime or another
Re: NML - a Newgrf Meta Language
So... new bug, new report (note that I'm still using the version I reported the other bugs in). What it boils down to is that I can't make sprite groups which use more than one sprite set per line (loading/unloading, on road vehicles). I've written them exactly as written in the documentation, and it didn't mention anything about them being specific to trains. Like this:
When compiling code that uses this, there is the error "Invalid amount of arguments for real sprite." I'm sure the actual sprites in the sprite sets all are correct.
Code: Select all
spritegroup some_sprite_group {
loaded: [empty_set, half_set, full_set];
loading: [empty_set, half_set, full_set];
}
--- 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
That error message is related to a real sprite, not to the spritegroup block. Since r1109 NML will print the a line number with that error so it should be easier to find the cause. However since the openttdcoop server is currently down I can't push that revision yet, so you'll have to wait a bit. If you post the complete nml file I'll take a look at it to see if I can find the problem.oberhümer wrote:When compiling code that uses this, there is the error "Invalid amount of arguments for real sprite." I'm sure the actual sprites in the sprite sets all are correct.
-
- Tycoon
- Posts: 1283
- Joined: 23 Oct 2009 19:35
- Location: Here and there, sometime or another
Re: NML - a Newgrf Meta Language
This is the problematic file. You'll find there is nothing wrong with the sprite defnitions.
- Attachments
-
- f9000_graphics.pnml.txt
- (3.8 KiB) Downloaded 162 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. ---
--- 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
That snippet you post is unproblematic and doesn't create an error here (using NML r1118). Please post the complete (pre-processed) NML file. Maybe it's related to something triggered in another part of the code. You can also send it via pm, if you don't want to publish it here.
Btw, you use the same sprite set definitions (sizes, offsets) for a lot of vehicles. You'd save a lot of code and make alignment easier, if you use something like
Btw, you use the same sprite set definitions (sizes, offsets) for a lot of vehicles. You'd save a lot of code and make alignment easier, if you use something like
Code: Select all
template tmpl_f9000(x,y) {
[x, y, 8, 18, -4, -9]
[x+16, y, 20, 16, -10, -8]
[x+48, y, 28, 12, -14, -6]
[x+96, y, 20, 16, -10, -8]
[x+128, y, 8, 18, -4, -9]
[x+144, y, 20, 16, -10, -8]
[x+176, y, 28, 12, -14, -6]
[x+224, y, 20, 16, -10, -8]
}
spriteset(f9000_coil_set, "tile_template.png") { tmpl_f9000(18,136) }
spritegroup f9000_coil_grp {
loaded: f9000_coil_set;
loading: f9000_coil_set;
}
spriteset(f9000_coil_set, "tile_template.png") { tmpl_f9000(96,8) }
spritegroup f9000_good_grp {
loaded: f9000_good_set;
loading: f9000_good_set;
}
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
-
- Tycoon
- Posts: 1283
- Joined: 23 Oct 2009 19:35
- Location: Here and there, sometime or another
Re: NML - a Newgrf Meta Language
Thank you for the tip. I'll try with the newest version of NML - perhaps that fixed it. The problem definitely is/was with that file, since I have no problems when removing it.
--- 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
As NML has no release yet, it can change from commit to commit, so it is highly recommend to update quite often. You are welcome on the DevZone, where your project could be automatically built (and rebuild with probably updated NML nightlies)
Town Names: Portuguese Belarusian French Swiss · Temperate Lumber Mill
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
Well, now I'm there, and have already encountered the next problem: the 2cc flag for trucks seems to turn them into trams instead (however, the reverse is not true). Download this file to test.
(Actually, I should have filed a report on the Devzone... maybe next time.)
(Actually, I should have filed a report on the Devzone... maybe next time.)
--- 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
I've just compiled narvs to test (with the f9000 enabled) but it worked like it should, no tram. However if you'd useoberhümer wrote:Well, now I'm there, and have already encountered the next problem: the 2cc flag for trucks seems to turn them into trams instead (however, the reverse is not true). Download this file to test.
(Actually, I should have filed a report on the Devzone... maybe next time.)
Code: Select all
misc_flags: ROADVEH_FLAG_2CC;
Code: Select all
misc_flags: bitmask(ROADVEH_FLAG_2CC);
Who is online
Users browsing this forum: No registered users and 1 guest