NML - a Newgrf Meta Language
Moderator: Graphics Moderators
Re: NML - a Newgrf Meta Language
Okay, OpenTTD is now returning the same values as TTDPatch/the documentation suggest
Re: NML - a Newgrf Meta Language
Tell me please, from what point measured offset_x and offset_y in real sprite block
?
Code: Select all
[left_x, upper_y, width, height, offset_x, offset_y]
- planetmaker
- OpenTTD Developer
- Posts: 9432
- Joined: 07 Nov 2007 22:44
- Location: Sol d
Re: NML - a Newgrf Meta Language
Read the wiki: http://newgrf-specs.tt-wiki.net/wiki/Pa ... oordinates, http://newgrf-specs.tt-wiki.net/wiki/RealSpritesakasoft wrote:Tell me please, from what point measured offset_x and offset_y in real sprite block
?Code: Select all
[left_x, upper_y, width, height, offset_x, offset_y]
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
How I can get "Vehicle type ID" of previous vehicle in consist inside of callback "shorten_vehicle"?
E.g., code below is not work and always return 8/8:
Inside default callback (for sprites) he is work.
E.g., code below is not work and always return 8/8:
Code: Select all
switch (FEAT_TRAINS, SELF, dummy_shorten_vehicle,
[
STORE_TEMP(-1, 0x10F),
var[0x61, 0, 0xFFFF, 0xC6]
])
{
d_m: return SHORTEN_TO_7_8;
d_c: return SHORTEN_TO_7_8;
l_e: return SHORTEN_TO_5_8;
lp_e: return SHORTEN_TO_5_8;
...
return SHORTEN_TO_8_8;
}
Re: NML - a Newgrf Meta Language
var61/62 is not available in callbacks, except non-altering ones like graphics, sound, etc.
Re: NML - a Newgrf Meta Language
And before anyone asks: No, this will not be changed.
Re: NML - a Newgrf Meta Language
The question is about "how" and "can", not about "var 61/62". This is simply for example. Maybe there another way or variable?
Re: NML - a Newgrf Meta Language
i don't know enough about the context you are trying to use this in, but you cannot achieve that by a callback in this case.
if you are trying to build an articulated vehicle, you need to have one separate vehicle-ID for each length.
if you are trying to build an articulated vehicle, you need to have one separate vehicle-ID for each length.
Re: NML - a Newgrf Meta Language
No you don't, but I don't think this is what he's trying to do (var 61 would hardly be useful in the context of building an articulate).Eddi wrote:if you are trying to build an articulated vehicle, you need to have one separate vehicle-ID for each length.
Re: NML - a Newgrf Meta Language
I trying to make the "large" length trains, from 9 to 16, through emulation conventional trains, consisting of articulated vehicles.
E.g., for my "large" carriage (or engine) with length 15 I use two vehicles with length 8 and 7.
First vehicle in a chain draw his sprite, but second is not draw. But he must set valid length information.
I thought used one dummy vehicle for all shorten values (from SHORTEN_TO_1_8 to SHORTEN_TO_8_8), determining it from the "Vehicle type ID" of previous vehicle in a chain.
We can use PARENT context and get this information about engine. I think, information about the previous and the next vehicle in a chain is no less important.
Tell me, var DA "Next wagon index, FFFF if last wagon" is same as vehicle ID or not?
E.g., for my "large" carriage (or engine) with length 15 I use two vehicles with length 8 and 7.
First vehicle in a chain draw his sprite, but second is not draw. But he must set valid length information.
I thought used one dummy vehicle for all shorten values (from SHORTEN_TO_1_8 to SHORTEN_TO_8_8), determining it from the "Vehicle type ID" of previous vehicle in a chain.
We can use PARENT context and get this information about engine. I think, information about the previous and the next vehicle in a chain is no less important.
Tell me, var DA "Next wagon index, FFFF if last wagon" is same as vehicle ID or not?
Re: NML - a Newgrf Meta Language
I've had the same problem in my double deck carriage and long steam engines.akasoft wrote:First vehicle in a chain draw his sprite, but second is not draw. But he must set valid length information.
You can use switch like below. Your articulated vehicle will be 15/8 long:
Code: Select all
switch(FEAT_TRAINS, SELF, switch_veh_length, position_in_vehid_chain % 2) {
1: return SHORTEN_TO_7_8;
return SHORTEN_TO_8_8;
}
item(FEAT_TRAINS, item_your_vehicle) {
...
graphics {
shorten_vehicle: switch_veh_length;
}
}
Re: NML - a Newgrf Meta Language
This not work, when in consists is articulated vehicles with different ID.
E.g., M-C-M, where
M - motorized head, consists of M-D (M motorized head vehicle SHORTEN_TO_8_8, D - dummy tail vehicle SHORTEN_TO_7_8),
C - carriage vehicle, consists of C-D (C carriage head vehicle SHORTEN_TO_8_8, D - dummy tail vehicle SHORTEN_TO_7_8),
Carriage and motorized vehicle can be variable length from 9 to 16.
In total, chain is: M8-D7-C8-D7-M8-D7. Item D is not draw, but set the length, which depends of previos ID respectively.
Version of the even positions of carriage not work, if chain is e.g. M8-D7-C8-D5-M8-D4.
E.g., M-C-M, where
M - motorized head, consists of M-D (M motorized head vehicle SHORTEN_TO_8_8, D - dummy tail vehicle SHORTEN_TO_7_8),
C - carriage vehicle, consists of C-D (C carriage head vehicle SHORTEN_TO_8_8, D - dummy tail vehicle SHORTEN_TO_7_8),
Carriage and motorized vehicle can be variable length from 9 to 16.
In total, chain is: M8-D7-C8-D7-M8-D7. Item D is not draw, but set the length, which depends of previos ID respectively.
Version of the even positions of carriage not work, if chain is e.g. M8-D7-C8-D5-M8-D4.
Re: NML - a Newgrf Meta Language
in CETS we have several dummy-vehicles for that purpose, one each with a fixed length 3, 4, 5 and 6lu ("length units")
vehicles can be 3 to 16lu by the following scheme:
(4 turned out a good length for use with var45/62)
for example this code of a 13lu vehicle:
here an example for a complicated articulated vehicle:
engine (9lu) - wagon A (11lu) - wagon C (3x11lu) - wagon B (11lu)
vehicles can be 3 to 16lu by the following scheme:
Code: Select all
|head|dummy
3 | 3 |
4 | 4 |
5 | 5 |
6 | 6 |
7 | 4 | 3
8 | 4 | 4
9 | 4 | 5
10 | 4 | 6
11 | 4 | 4 3
12 | 4 | 4 4
13 | 4 | 4 5
14 | 4 | 4 6
15 | 4 | 4 4 3
16 | 4 | 4 4 4
for example this code of a 13lu vehicle:
Code: Select all
switch(FEAT_TRAINS, SELF, VEH_ID(cb_articulate_switch), extra_callback_info1) {
2: return dummy_zzzd5;
3: return 0xFF;
return dummy_zzzd4;
}
engine (9lu) - wagon A (11lu) - wagon C (3x11lu) - wagon B (11lu)
Code: Select all
switch(FEAT_TRAINS, SELF, VEH_ID(cb_articulate_custom_switch), extra_callback_info1) {
1: return dummy_zzzd5;
2: return DRG_61a;
14: return DRG_61b;
5: return DRG_61c;
8: return DRG_61c;
11: return DRG_61c;
4: return dummy_zzzd3;
7: return dummy_zzzd3;
10: return dummy_zzzd3;
13: return dummy_zzzd3;
16: return dummy_zzzd3;
17: return 0xFF;
return dummy_zzzd4;
}
Re: NML - a Newgrf Meta Language
A long-open bug was fixed today (if you use "speed: 100km/h;" in your code it'll display 100km/h in game if possible, 101km/h if not instead of 99km/h as it did before) and with that NML was finally ready for the 0.2.0 release. Packages can be found here: http://bundles.openttdcoop.org/nml/releases/
The 0.2 branch will be updated for some time with fixes / small additions, but will receive no major changes. Starting from now the nightlies will no longer consider compatibility with OpenTTD 1.1 and we'll continue to work on it as a tool for OpenTTD 1.2 and later.
The 0.2 branch will be updated for some time with fixes / small additions, but will receive no major changes. Starting from now the nightlies will no longer consider compatibility with OpenTTD 1.1 and we'll continue to work on it as a tool for OpenTTD 1.2 and later.
Re: NML - a Newgrf Meta Language
I have strange problem with my long carriage in OTTD.
This is articulated vehicle with total length 12/8, combined with normal 8/8 vehicle and 4/8 "dummy" car:
Everything looks typical, but I obtain strange, visual artefacts:
On the left picture the fence overlaps the roof of carriage. On the right picture carriages overlaps one another.
What is wrong? This is a mistake in my GRF or bug in OTTD? I'm using OTTD 1.1.3.
This is articulated vehicle with total length 12/8, combined with normal 8/8 vehicle and 4/8 "dummy" car:
Code: Select all
switch(FEAT_TRAINS, SELF, switch_abdnu_shorten, position_in_vehid_chain % 2) {
1: return SHORTEN_TO_4_8;
return SHORTEN_TO_8_8;
}
switch(FEAT_TRAINS, SELF, switch_abdnu_articulated, extra_callback_info1) {
1: return item_abdnu; // Add dummy wagon
return 0xFF;
}
switch(FEAT_TRAINS, SELF, switch_abdnu_graphics, (position_in_vehid_chain%2)*2 + cargo_subtype) {
0: return sset_bdnu; // 2 class carriage
1: return sset_adnu; // 1 class carriage
return sset_dummy;
}
item(FEAT_TRAINS, item_abdnu) {
...
graphics {
...
default: switch_abdnu_graphics;
articulated_part: switch_abdnu_articulated;
shorten_vehicle: switch_abdnu_shorten;
}
}
On the left picture the fence overlaps the roof of carriage. On the right picture carriages overlaps one another.
What is wrong? This is a mistake in my GRF or bug in OTTD? I'm using OTTD 1.1.3.
Re: NML - a Newgrf Meta Language
this should behave better/different with trunk. check here: http://www.tt-forums.net/viewtopic.php?f=68&t=57446 (you may get more severe glitches in other places though, like near foundations)
- planetmaker
- OpenTTD Developer
- Posts: 9432
- Joined: 07 Nov 2007 22:44
- Location: Sol d
Re: NML - a Newgrf Meta Language
http://wiki.openttd.org/FAQ_OpenTTD_versions#TrunkTadeuszD wrote:Thanks for answer.
What do you mean, "trunk"?
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
Yes, of course... Thanks a lot... I've cheked this word in dictionary, but I forgot this "computer's" denotation...
Re: NML - a Newgrf Meta Language
Hello, again...
In my project I use simple recolour sprites for recolouring cargo inside my wagons.
My first version was:
But this version didn't work. I reached internal compiler error:
nmlc: An internal error has occurred:
nmlc-version: 0.2.0 (2c839dc11b3a)
Error: (AssertionError) .
Command: ['nmlc', '-c', '--grf', 'pkp-0.1.grf', 'tmp\\pkp.nml']
Location: File "nml\free_number_list.py", line 33, in pop
This error appears with nml version 0.2.0 and r1702.
I corrected this error in my second version:
This works wery well, but I have question: Why the first version of my code didn't work?
In my project I use simple recolour sprites for recolouring cargo inside my wagons.
My first version was:
Code: Select all
cargo_palette = reserve_sprites(2);
replace(cargo_palette) { recolour_sprite {
0xAA: 0x01;
...
} }
replace(cargo_palette + 1) { recolour_sprite {
0xAA: 0x40;
...
} }
nmlc: An internal error has occurred:
nmlc-version: 0.2.0 (2c839dc11b3a)
Error: (AssertionError) .
Command: ['nmlc', '-c', '--grf', 'pkp-0.1.grf', 'tmp\\pkp.nml']
Location: File "nml\free_number_list.py", line 33, in pop
This error appears with nml version 0.2.0 and r1702.
I corrected this error in my second version:
Code: Select all
palette_coal = reserve_sprites(1);
replace(palette_coal) { recolour_sprite {
0xAA: 0x01;
...
} }
palette_grai = reserve_sprites(1);
replace(palette_grai) { recolour_sprite {
0xAA: 0x40;
...
} }
Who is online
Users browsing this forum: No registered users and 15 guests