Variables in NML?
Posted: 20 Apr 2022 09:32
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:
Is there a way to do this in NML?
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;
}