item(booster_wagon ...) { } // return power, as computed in TEMP(0) switch (..., power_final, [ LOAD_TEMP(0) ] ) { return } // check vehicle at position 1 from front, and add 400 if booster switch (..., power_check_1, [ STORE_TEMP(2, 0x10F), STORE_TEMP(LOAD_TEMP(0) + (var[0x61, 0, 0xFFFF, 0xC6] == booster_wagon ? 400 : 0), 0) ] { default: power_final } // check vehicle at position 1 from back, and add 400 if booster switch (..., power_check_2, [ STORE_TEMP(position_in_consist_from_end - 1, 0x10F), STORE_TEMP(LOAD_TEMP(0) + (var[0x61, 0, 0xFFFF, 0xC6] == booster_wagon ? 400 : 0), 0) ] { default: power_check_1 } // check vehicle at position 2 from front, and add 100 if booster switch (..., power_check_3, [ STORE_TEMP(2, 0x10F), STORE_TEMP(LOAD_TEMP(0) + (var[0x61, 0, 0xFFFF, 0xC6] == booster_wagon ? 100 : 0), 0) ] { default: power_check_2 } // check vehicle at position 2 from back, and add 100 if booster switch (..., power_check_4, [ STORE_TEMP(position_in_consist_from_end - 2, 0x10F), STORE_TEMP(LOAD_TEMP(0) + (var[0x61, 0, 0xFFFF, 0xC6] == booster_wagon ? 100 : 0), 0) ] { default: power_check_3 } // basic power is 2000 + 200 per booster vehicle switch (..., power_switch, [ STORE_TEMP(2000 + count_veh_id(booster_wagon) * 200, 0), train_length ]) { 1..2: power_final; // no wagons, no bonus 3: power_check_1; // one wagon 4: power_check_2; // two wagons 5: power_check_3; // three wagons default: power_check_4; // four or more wagons } item(engine ...) { power: power_switch; }