Variables in NML?

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

Moderator: Graphics Moderators

Post Reply
User avatar
Donald Duck
Engineer
Engineer
Posts: 18
Joined: 24 Apr 2020 07:05

Variables in NML?

Post 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?
Eddi
Tycoon
Tycoon
Posts: 8267
Joined: 17 Jan 2007 00:14

Re: Variables in NML?

Post by Eddi »

no. vehicles don't have any storage like that.
User avatar
jfs
Tycoon
Tycoon
Posts: 1757
Joined: 08 Jan 2003 23:09
Location: Denmark

Re: Variables in NML?

Post by jfs »

The best you can do is have different power, top speed, TE, or different running costs, while on different track.
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 5 guests