Page 1 of 1

Visual effects in NML

Posted: 02 Dec 2019 16:13
by Arnoud
Hi,

I just added a diesel flatback tram to the 2cc tram set, but I noticed ingame that it seems like the diesel effect is applied not just to the engine, but allso to all of the wagons.
Looking back at my steam/electric vehicles I am now wondering if the same unwanted effect is allso applied there.

From how I understand the documentation there is a means of limiting the visual effect by means of a switch and callback.
What I am looking for is a way to limit the effect to the default position in consist, part 0.

I'm having a hard time finding an example of this.. if anyone could give me an example that would be awesome.

Re: Visual effects in NML

Posted: 02 Dec 2019 17:01
by planetmaker
Don't make your life complicated without need. Use a different vehicleID for the wagons - unless you plan to use more than 65k different vehicles. They look different, they behave different --> different vehicle. Just disallow buying it via climate availability, so it only is available in the refit option of the tram(s).

Re: Visual effects in NML

Posted: 03 Dec 2019 20:26
by Transportman
Or if you don't want to use different IDs for the wagons, you would need a switch that looks at the position_in_articulated_veh or position_in_vehid_chain variables (or their _from_end versions). For trams those will be the same at this moment as you can't combine trams to 1 long vehicle like you can do with trains, so in the example I have to do a modulo 3 (the % 3) to make sure that 2 trains behind each other get the correct working. You don't need it, unless in the future trams can be combined.

You would get a switch like this:

Code: Select all

switch(FEAT_TRAINS, SELF, switch_emu_FLIRT3III_visual_effect_and_powered, (position_in_vehid_chain % 3)) {
    0: return visual_effect_and_powered(VISUAL_EFFECT_ELECTRIC, 0, DISABLE_WAGON_POWER);
    return visual_effect_and_powered(VISUAL_EFFECT_DISABLE, 0, DISABLE_WAGON_POWER);
}
And in the graphics-block of your vehicle, you would have

Code: Select all

visual_effect_and_powered: switch_emu_FLIRT3III_visual_effect_and_powered;

Re: Visual effects in NML

Posted: 04 Dec 2019 10:28
by Arnoud
Transportman wrote: 03 Dec 2019 20:26 Or if you don't want to use different IDs for the wagons, you would need a switch that looks at the position_in_articulated_veh or position_in_vehid_chain variables (or their _from_end versions). For trams those will be the same at this moment as you can't combine trams to 1 long vehicle like you can do with trains, so in the example I have to do a modulo 3 (the % 3) to make sure that 2 trains behind each other get the correct working. You don't need it, unless in the future trams can be combined.

You would get a switch like this:

Code: Select all

switch(FEAT_TRAINS, SELF, switch_emu_FLIRT3III_visual_effect_and_powered, (position_in_vehid_chain % 3)) {
    0: return visual_effect_and_powered(VISUAL_EFFECT_ELECTRIC, 0, DISABLE_WAGON_POWER);
    return visual_effect_and_powered(VISUAL_EFFECT_DISABLE, 0, DISABLE_WAGON_POWER);
}
And in the graphics-block of your vehicle, you would have

Code: Select all

visual_effect_and_powered: switch_emu_FLIRT3III_visual_effect_and_powered;
That is exactly the kind of example I was looking for, adapted it for roadvehicles and its working, so in the next update for the 2cc cargotrams the visual effects will be fixed.
Edit: the mistake I made was trying to reference the switch from the item block rather than the graphics block, that obviously didnt work, silly beginners mistake I guess lol