Page 1 of 1

Variables in NML?

Posted: 20 Apr 2022 09:32
by Donald Duck
I'm trying to make a battery-driven locomotive, so that it charges when it's on electrified tracks and discharges when it's on non-electrified tracks. To do this, I would like to store how much battery it has in a variable. Here is some pseudo-code showing approximately what I want to do:

Code: Select all

switch(FEAT_TRAINS, SELF, switch_battery_charge, current_railtype){
    RAIL: -1;
    ELRL: 2;
}

item(FEAT_TRAINS){
    var battery = 100;

    //Repeat the following every unit of time
    battery += switch_battery_charge;
}
Is there a way to do this in NML?

Re: Variables in NML?

Posted: 20 Apr 2022 11:02
by Eddi
no. vehicles don't have any storage like that.

Re: Variables in NML?

Posted: 20 Apr 2022 20:47
by jfs
The best you can do is have different power, top speed, TE, or different running costs, while on different track.