How to do Dual-mode Electro Diesels in NML
Moderator: Graphics Moderators
- NekoMaster
- Tycoon
- Posts: 4001
- Joined: 16 Aug 2008 22:26
- Skype: neko-master
- Location: Oshawa, Ontario, CANADA
How to do Dual-mode Electro Diesels in NML
I was wondering how one does Dual-Mode electro-diesels like the EMD FL9, the GE P32AC-DM, and the ALP-45DP
I would like to have them run as dual mode electro-diesels for Metro track (though NARS ADD-ON defaults to El. Rail if no metro/3rd track type is available)
I hope its not too hard or complicated as I still don't understand a lot of the more complex NML stuff even if I am using the 2cc Trains in NML code.
I would like to have them run as dual mode electro-diesels for Metro track (though NARS ADD-ON defaults to El. Rail if no metro/3rd track type is available)
I hope its not too hard or complicated as I still don't understand a lot of the more complex NML stuff even if I am using the 2cc Trains in NML code.
Proud Canadian
Nekomasters Projects! (Downloads available on BaNaNaS!) \(>^w^<)/
# NARS ADD-ON SET 2CC | 2cc Rapid Transit For Me! (2ccRTFM) | 2cc Wagons In NML (2ccWIN)
# NML Category System (Organize your GRFS!) <- TT-Forums Exclusive Download!
Nekomasters Projects! (Downloads available on BaNaNaS!) \(>^w^<)/
# NARS ADD-ON SET 2CC | 2cc Rapid Transit For Me! (2ccRTFM) | 2cc Wagons In NML (2ccWIN)
# NML Category System (Organize your GRFS!) <- TT-Forums Exclusive Download!
Re: How to do Dual-mode Electro Diesels in NML
Essentially, you code them as standard rail vehicles, then use the current_railtype variable to check for your powered railtypes and set the appropriate callback results (power, running_cost_factor, visual_effect_and_powered, etc). To use the current_railtype variable you need a railtypetable containing the labels you want to check for.
- andythenorth
- Tycoon
- Posts: 5658
- Joined: 31 Mar 2007 14:23
- Location: Lost in Music
Re: How to do Dual-mode Electro Diesels in NML
Code: Select all
// -- power -- //
switch (FEAT_TRAINS, SELF, double_juice_switch_power, current_railtype) {
RAIL: return 3750;
ELRL: return 6750;
return 6750;
}
item(FEAT_TRAINS, double_juice, 160) {
property {
name: string(STR_NAME_double_juice, string(STR_NAME_SUFFIX_ELECTRODIESEL));
climates_available: NO_CLIMATE; // nml constant
engine_class: ENGINE_CLASS_DIESEL;
visual_effect_and_powered: visual_effect_and_powered(VISUAL_EFFECT_DISABLE, 0, DISABLE_WAGON_POWER);
introduction_date: date(2000,01,01); // consist just supplies intro year - openttd randomises intro dates a bit anyway
cargo_capacity: 0;
sprite_id: SPRITE_ID_NEW_TRAIN; //enable new graphics - nml constant
power: 6750hp;
speed: 100mph;
weight: 120ton;
tractive_effort_coefficient: 0.4;
cost_factor: 213.33333333333331;
running_cost_base: RUNNING_COST_DIESEL;
running_cost_factor: 168.33333333333331;
refit_cost: 0; // btw this needs to be 0 if we want autorefit without using cb
refittable_cargo_classes: bitmask();
non_refittable_cargo_classes: bitmask(); // don't set non-refittable classes, increases likelihood of breaking cargo support
cargo_allow_refit: [];
cargo_disallow_refit: [];
default_cargo_type: PASS;
cargo_age_period: 185;
misc_flags: bitmask(TRAIN_FLAG_2CC); // nml constants
dual_headed: 0;
model_life: VEHICLE_NEVER_EXPIRES;
retire_early: 36; // magic from Eddi
reliability_decay: 20; // default value
vehicle_life: 40;
length: 2;
track_type: RAIL;
}
graphics {
default: double_juice_switch_graphics;
purchase: double_juice_sg_purchase;
power: double_juice_switch_power;
purchase_power: double_juice_switch_power;
visual_effect_and_powered: double_juice_switch_visual_effect_and_powered;
articulated_part: double_juice_articulated_cb_switch;
}
}
FIRS Industry Replacement Set (released) | HEQS Heavy Equipment Set (trucks, industrial trams and more) (finished)
Unsinkable Sam (ships) (preview released) | CHIPS Has Improved Players' Stations (finished)
Iron Horse ((trains) (released) | Termite (tracks for Iron Horse) (released) | Busy Bee (game script) (released)
Road Hog (road vehicles and trams) (released)
Unsinkable Sam (ships) (preview released) | CHIPS Has Improved Players' Stations (finished)
Iron Horse ((trains) (released) | Termite (tracks for Iron Horse) (released) | Busy Bee (game script) (released)
Road Hog (road vehicles and trams) (released)
Re: How to do Dual-mode Electro Diesels in NML
As Pikka says, you use a switch to check the current_railtype and return a different speed/power/etc.
My example is for dual-voltage electric but the principle is the same.
You then have a callback to that switch in the graphics block of the train.
My example is for dual-voltage electric but the principle is the same.
You then have a callback to that switch in the graphics block of the train.
Code: Select all
switch (FEAT_TRAINS, SELF,sw_BR395_speed, current_railtype) {
ELRL: return 225;
BR_3RDR: return 160;
return 225;
}
item (FEAT_TRAINS, item_BR395, 77) {
property {
name: string(STR_NAME_BR395);
climates_available: ALL_CLIMATES;
introduction_date: date(2009,4,21);
model_life: 8;
retire_early: 1;
vehicle_life: 50;
reliability_decay: 7;
refittable_cargo_classes: 0;
cargo_allow_refit: [PASS];
loading_speed: 14;
cost_factor: 107;
running_cost_factor: 77;
sprite_id: SPRITE_ID_NEW_TRAIN;
speed: 225 km/h;
misc_flags: TRAIN_FLAG_MU;
refit_cost: 0;
track_type: BR_3RDC;
ai_special_flag: AI_FLAG_CARGO;
power: 4480 hp;
running_cost_base: RUNNING_COST_ELECTRIC;
dual_headed: 0;
default_cargo_type: PASS;
cargo_capacity: 50;
weight: 265 ton;
engine_class: ENGINE_CLASS_ELECTRIC;
tractive_effort_coefficient: 0.3;
air_drag_coefficient: 0.1;
length: 8;
effect_spawn_model_and_powered: EFFECT_SPAWN_MODEL_ELECTRIC;
extra_weight_per_wagon: 0;
bitmask_vehicle_info: 0;
}
graphics {
additional_text: return(string(str_purchase_loco_with_liveries,string(str_purchase_type_emu),string(str_route_2),string(str_BR395_usage),string(str_BR395_eos),string(str_BR395_liveries)));
can_attach_wagon: CB_RESULT_ATTACH_ALLOW;
cargo_subtype_text: sw_BR395_cargo_subtype_text;
articulated_part: switch_articulated_BR395;
default: sw_BR395a;
purchase: spriteset_BR395_Purchase;
colour_mapping: return PALETTE_CC_FIRST;
speed: sw_BR395_speed;
}
}
Last edited by Leanden on 26 May 2017 19:59, edited 1 time in total.
Re: How to do Dual-mode Electro Diesels in NML
Not sure, but when we were discussing how to do this for dual-mode trucks on IRC, the conclusion was that the switch needs to check for every potential type of electrified road that you know of rather than just ELRD - and the understanding was that rail would behave the same way. Maybe Frosch or Wolf01 will be able to explain this better than me as they were the ones helping me get this working for Trolleybi.
Re: How to do Dual-mode Electro Diesels in NML
Thats why you have a railtype table.
So you dont have to switch for each railtype, instead you use the ones set in the table.
So you dont have to switch for each railtype, instead you use the ones set in the table.
Re: How to do Dual-mode Electro Diesels in NML
Yes. There's no way for the vehicle to know "this rail/roadtype is boosty" except the code explicitly telling it so. That's why the UKRS2 dual mode vehicles don't always work as expected with newer rail sets - the new sets use labels that didn't exist when UKRS2 was coded.supermop wrote:Not sure, but when we were discussing how to do this for dual-mode trucks on IRC, the conclusion was that the switch needs to check for every potential type of electrified road that you know of rather than just ELRD - and the understanding was that rail would behave the same way. Maybe Frosch or Wolf01 will be able to explain this better than me as they were the ones helping me get this working for Trolleybi.
Rather than have a long list of compatible labels, Andy's Double Juice appears to assume every railtype except the default RAIL is electrified and provides full power. That's probably the right way to do things - I think it's safe to assume with dual-mode vehicles that most players want the higher stats all the time, with whatever rail set they're using, and the alternative mode is only there as flavour for detail-oriented or "realism" players.
-
- Tycoon
- Posts: 5948
- Joined: 27 Apr 2005 07:09
- Contact:
Re: How to do Dual-mode Electro Diesels in NML
There´s already a Standardized railtype scheme to avoid those problems. Still inventing 'own' railtype labels is a 'bad feature', isn´t it?PikkaBird wrote: There's no way for the vehicle to know "this rail/roadtype is boosty" except the code explicitly telling it so. [...]
regards
Michael
- andythenorth
- Tycoon
- Posts: 5658
- Joined: 31 Mar 2007 14:23
- Location: Lost in Music
Re: How to do Dual-mode Electro Diesels in NML
I also gently disagree with the concept of railtype grfs being disconnected from train grfs. Arbitrary combinations are hard to support reliably. I only test and support Iron Horse with the Termite grf (and I'lll likely merge Termite into Iron Horse at some point).PikkaBird wrote:Andy's Double Juice appears to assume every railtype except the default RAIL is electrified and provides full power.
FIRS Industry Replacement Set (released) | HEQS Heavy Equipment Set (trucks, industrial trams and more) (finished)
Unsinkable Sam (ships) (preview released) | CHIPS Has Improved Players' Stations (finished)
Iron Horse ((trains) (released) | Termite (tracks for Iron Horse) (released) | Busy Bee (game script) (released)
Road Hog (road vehicles and trams) (released)
Unsinkable Sam (ships) (preview released) | CHIPS Has Improved Players' Stations (finished)
Iron Horse ((trains) (released) | Termite (tracks for Iron Horse) (released) | Busy Bee (game script) (released)
Road Hog (road vehicles and trams) (released)
Re: How to do Dual-mode Electro Diesels in NML
That still has the problem of needing to enumerate every known 'should be powered' railtype in a long list, whether those types are standardized or not. There isn't a way currently to say 'extra power on ELRL' and have the newgrf determine what list of other rails provide power in the same manner as 'ELRL'.michael blunck wrote:There´s already a Standardized railtype scheme to avoid those problems. Still inventing 'own' railtype labels is a 'bad feature', isn´t it?PikkaBird wrote: There's no way for the vehicle to know "this rail/roadtype is boosty" except the code explicitly telling it so. [...]
regards
Michael
Electric roads are a bit unique as well, as there is no 'standard types' list, however the author in question (me) happens to be the only one who has created and released any other than ELRD so far. So I have perfect knowledge of a de facto standard list at the moment, but as soon as the next author creates a new electric road type, my newgrf is 'broken'.
-
- Tycoon
- Posts: 5948
- Joined: 27 Apr 2005 07:09
- Contact:
Re: How to do Dual-mode Electro Diesels in NML
Standardisation is the fundamental condition to tackle this problem in a comparatively easy way.supermop wrote: That still has the problem of needing to enumerate every known 'should be powered' railtype in a long list, whether those types are standardized or not.
Since railtype labels are translated into numbers it is possible to set up an ordered railtype translation table with "electrified" resp "should be powered" tracks in a contiguous block:
Code: Select all
railtypetranslationtable(
{"RAIL"}, {"MONO"}, {"MGLV"}, {"SABN"}, {"SACN"}, {"SADN"},
{"ELRL"}, {"SABE"}, {"SACE"}, {"SADE"}, {"SAB3"}, {"SABZ"}
)
Code: Select all
def(3) veh_railtype(
setspeed(100 km/h) if(ELRL .. SABZ) // increase speed if on electrified track
cbfail() else
)
Michael
Re: How to do Dual-mode Electro Diesels in NML
Let me hook up to this thread. I have following idea: switching electric to diesel/steam and reverse (for example, by refitting in depot from passengers to mail and back, with 0 capacity).
I have a question: if such dual vehicle is refitted to electric (which results of 0 power for non-electrified track), how it will be handled by pathfinder?
Would such train be stuck in depot (or at last pathsignal before non-electrified track), or just will run blindly into non-electrified track?
I have a question: if such dual vehicle is refitted to electric (which results of 0 power for non-electrified track), how it will be handled by pathfinder?
Would such train be stuck in depot (or at last pathsignal before non-electrified track), or just will run blindly into non-electrified track?
Formerly known as: McZapkie
Projects: Reproducible Map Generation patch, NewGRFs: Manpower industries, PolTrams, Polroad, 600mm narrow gauge, wired, ECS industry extension, V4 CEE train set, HotHut.
Another favorite games: freeciv longturn, OHOL/2HOL.
Projects: Reproducible Map Generation patch, NewGRFs: Manpower industries, PolTrams, Polroad, 600mm narrow gauge, wired, ECS industry extension, V4 CEE train set, HotHut.
Another favorite games: freeciv longturn, OHOL/2HOL.
-
- Tycoon
- Posts: 2781
- Joined: 22 Feb 2011 18:34
Re: How to do Dual-mode Electro Diesels in NML
It would get stuck the moment it is refitted to a type for which it has no power at that railtype.McZapkie wrote:Let me hook up to this thread. I have following idea: switching electric to diesel/steam and reverse (for example, by refitting in depot from passengers to mail and back, with 0 capacity).
I have a question: if such dual vehicle is refitted to electric (which results of 0 power for non-electrified track), how it will be handled by pathfinder?
Would such train be stuck in depot (or at last pathsignal before non-electrified track), or just will run blindly into non-electrified track?
The pathfinder will happily take into account the possible power outputs, at least to the extent of not running a train onto a track on which it has no power. I do not know if the pathfinder includes some total power figure in the penalties, or only considers "does this train have power along this path?".
Coder of the Dutch Trackset | Development support for the Dutch Trainset | Coder of the 2cc TrainsInNML
Who is online
Users browsing this forum: Google Adsense [Bot] and 68 guests