Visual effects in NML

Discussions about the technical aspects of graphics development, including NewGRF tools and utilities.

Moderator: Graphics Moderators

Post Reply
Arnoud
Engineer
Engineer
Posts: 78
Joined: 29 Sep 2008 05:02
Location: Amsterdam

Visual effects in NML

Post 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.
Coder for the 2cc trams (passenger) and the 2cc cargo trams
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Visual effects in NML

Post 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).
Transportman
Tycoon
Tycoon
Posts: 2781
Joined: 22 Feb 2011 18:34

Re: Visual effects in NML

Post 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;
Coder of the Dutch Trackset | Development support for the Dutch Trainset | Coder of the 2cc TrainsInNML
Arnoud
Engineer
Engineer
Posts: 78
Joined: 29 Sep 2008 05:02
Location: Amsterdam

Re: Visual effects in NML

Post 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
Coder for the 2cc trams (passenger) and the 2cc cargo trams
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 21 guests