Back to Index Page generated: Nov 12, 2024, 11:02:03 PM

Expansion Duplex Fuel Tank

Content

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description Additional fuel tank (3LY) with duplex interaction with main tank. Improved technology allows not only to pump the fuel in the main tank, but also to make the opposite action, for example, in/after skimming process. Additional fuel tank (3LY) with duplex interaction with main tank. Improved technology allows not only to pump the fuel in the main tank, but also to make the opposite action, for example, in/after skimming process.
Identifier oolite.oxp.AndreyBelov.DuplexFuelTank oolite.oxp.AndreyBelov.DuplexFuelTank
Title Duplex Fuel Tank Duplex Fuel Tank
Category Equipment Equipment
Author Andrey Belov aka timer Andrey Belov aka timer
Version 0.52 0.52
Tags
Required Oolite Version
Maximum Oolite Version
Required Expansions
Optional Expansions
Conflict Expansions
Information URL http://wiki.alioth.net/index.php/DuplexFuelTank_OXP n/a
Download URL https://wiki.alioth.net/img_auth.php/1/17/DuplexFuelTank.oxz n/a
License CC-BY-NC-SA 3.0 CC-BY-NC-SA 3.0
File Size n/a
Upload date 1677423756

Documentation

Also read http://wiki.alioth.net/index.php/Duplex%20Fuel%20Tank

Readme.txt

Duplex Fuel Tank OXP
====================

== Overview ==

Additional fuel tank (3LY) with duplex interaction with main tank.
Improved technology allows one not only to pump the fuel into the main tank,
but also to make the opposite action, for example, in skimming process.
The Duplex Fuel Tank takes 8t of cargo space. It is excellent purchase for
enthusiasts of long journeys — as now, You always can refuel ALL your tanks by
Sun skimming or from the gutted fuel tank of an unlucky pirate (with the remarkable Fuel Collector OXP).


== Requires ==

Oolite 1.79;
You need at least 8t free cargo space for device installation;
You must have bought the Fuel Scoops before this becomes available.


== Usage ==

Press "Shift"+"n" until you have selected the duplex tank as your primed equipment.
Press "b" to pump fuel from the main tank to the duplex tank.
Press "n" to pump fuel from the duplex tank to the main tank.


== Gratitude to ==

Smivs - thanks for all ;)


== History ==

2023-02-26 v0.52 - some code cleanup and minor changes.
2015-06-05 v0.51
2013-02-01 v0.4
2013-01-30 v0.3
2013-01-29 v0.1


== Links ==

https://wiki.alioth.net/index.php/DuplexFuelTank_OXP
http://aegidian.org/bb/viewtopic.php?f=4&t=13489


== Licence ==

CC BY-NC-SA 3.0
see http://creativecommons.org/licenses/by-nc-sa/3.0/ for more info.

Equipment

Name Visible Cost [deci-credits] Tech-Level
Duplex Fuel Tank - takes up 8t of cargo space no 620000 12+
DFT no 10 2+
Refill 1LY in additional DFT no 75 2+
Sell Duplex Fuel Tank - reclaims 8t of cargo space yes 4200 12+
Duplex Fuel Tank (empty) yes 10 2+
Duplex Fuel Tank (1/3) yes 10 2+
Duplex Fuel Tank (2/3) yes 10 2+
Duplex Fuel Tank (full) yes 10 2+

Ships

This expansion declares no ships.

Models

This expansion declares no models.

Scripts

Path
Scripts/duplex_fuel_tank.js
(function(){

'use strict';

this.name        = 'DuplexFuelTank';
this.author      = 'Andrey Belov';
this.copyright   = '© 2015 Andrey Belov aka timer [ TiNe Corp. ]';
this.licence     = 'CC BY-NC-SA 3.0'; // see http://creativecommons.org/licenses/by-nc-sa/3.0/ for more info.
this.description = 'Additional fuel tank with duplex interaction with main tank.';
this.version     = '0.52';


const _DFT_MAX_FUEL      = 3;
const _DFT_MAX_SHIP_FUEL = 7.0;


this.playerBoughtEquipment = function(equipmentKey) {
    if ( equipmentKey === 'EQ_DUPLEX_FUEL_TANK_REFILL' ) {
        this._dft_refill();
    }
    else if ( equipmentKey === 'EQ_DUPLEX_FUEL_TANK' ) {
        this._dft_buy();
    }
    else if ( equipmentKey === 'EQ_DUPLEX_FUEL_TANK_REMOVAL' ) {
        this._dft_sell();
    }
};

this._dft_buy = function() {
    player.ship.awardEquipment('EQ_DUPLEX_FUEL_TANK_CTRL');
    player.ship.awardEquipment('EQ_DUPLEX_FUEL_TANK_STATE_' + _DFT_MAX_FUEL);
};

this._dft_sell = function() {
    player.ship.removeEquipment('EQ_DUPLEX_FUEL_TANK_REMOVAL');
    player.ship.removeEquipment('EQ_DUPLEX_FUEL_TANK_CTRL');
    let cs = this._dft_get_current_state();
    player.ship.removeEquipment('EQ_DUPLEX_FUEL_TANK_STATE_' + cs);
    player.ship.removeEquipment('EQ_DUPLEX_FUEL_TANK');
    player.credits += (EquipmentInfo.infoForKey('EQ_DUPLEX_FUEL_TANK').price * 0.07);
};

this._dft_refill = function() {
    let cs = this._dft_get_current_state();

    player.ship.removeEquipment('EQ_DUPLEX_FUEL_TANK_REFILL');
    if ( cs < _DFT_MAX_FUEL ) {
        player.ship.removeEquipment('EQ_DUPLEX_FUEL_TANK_STATE_' + cs);
        player.ship.awardEquipment('EQ_DUPLEX_FUEL_TANK_STATE_' + (cs+1));
    }
};

// Call from EQ script
this.$dft_pump_to_main = function() {
    let cs = this._dft_get_current_state();

    if ( cs < 1 ) {
        this._dft_print('DFT: additional tank is empty.');
        return;
    }

    if ( player.ship.fuel >= _DFT_MAX_SHIP_FUEL ) {
        this._dft_print('DFT: main tank full.');
        return;
    }

    let ff = 1.0 - ( _DFT_MAX_SHIP_FUEL - player.ship.fuel );
    if ( ff > 0 ) {
        this._dft_print('DFT: main tank full, ' + ff.toFixed(1) + ' fuel lost.');
    }

    player.ship.removeEquipment('EQ_DUPLEX_FUEL_TANK_STATE_' + cs);
    cs--;
    player.ship.awardEquipment('EQ_DUPLEX_FUEL_TANK_STATE_' + cs);

    player.ship.fuel += 1.0;

    if ( player.ship.fuel > _DFT_MAX_SHIP_FUEL ) {
        // should never happens
        player.ship.fuel = _DFT_MAX_SHIP_FUEL;
    }

    this._dft_print_state(cs);
};

// Call from EQ script
this.$dft_pump_from_main = function() {
    let cs = this._dft_get_current_state();

    if ( cs >= _DFT_MAX_FUEL ) {
        this._dft_print('DFT: additional tank is full.');
        return;
    }

    if ( player.ship.fuel < 1.0 ) {
        this._dft_print('DFT: main tank too low.');
        return;
    }

    player.ship.removeEquipment('EQ_DUPLEX_FUEL_TANK_STATE_' + cs);
    cs++;
    player.ship.awardEquipment('EQ_DUPLEX_FUEL_TANK_STATE_' + cs);

    player.ship.fuel -= 1.0;

    this._dft_print_state(cs);
};

this._dft_print_state = function(cs) {
    this._dft_print('DFT state: ' + cs + '/' + _DFT_MAX_FUEL);
};

this._dft_print = function(msg) {
    // TODO MFD?
    player.consoleMessage(msg, 3);
};

this._dft_get_current_state = function() {
    for ( let k = 0; k <= _DFT_MAX_FUEL; k++ ) {
        if ( player.ship.equipmentStatus('EQ_DUPLEX_FUEL_TANK_STATE_'+k) === 'EQUIPMENT_OK' ) {
            return k;
        }
    }

    return 0;
};

// Special for Smivs ;)
this.$dftSabotage = function() {
    if ( player.ship.equipmentStatus('EQ_DUPLEX_FUEL_TANK') === 'EQUIPMENT_OK' ) {
        let cs = this._dft_get_current_state();
        if ( cs > 0 ) {
            player.ship.removeEquipment('EQ_DUPLEX_FUEL_TANK_STATE_' + cs);
            player.ship.awardEquipment('EQ_DUPLEX_FUEL_TANK_STATE_0');
            player.consoleMessage('DFT malfunction: fuel leak!', 3);
        }
    }
};

// Condition scripting method (Thanks Smivs again)
this.allowAwardEquipment = function( equipment, ship, context ) {
    // Can't buy service equipment - only scripting operations
    return !!(context == 'scripted');
};

}).call(this);
Scripts/eq_duplex_fuel_tank.js
(function(){

'use strict';

this.name        = 'eqDuplexFuelTank';
this.author      = 'Andrey Belov';
this.description = 'http://wiki.alioth.net/index.php/DuplexFuelTank_OXP';


/* Use button "n" for pump fuel to main tank */
this.activated = function() {
    this._dft_pump(true);
};

/* Use button "b" for pump fuel from main tank */
this.mode = function() {
    this._dft_pump(false);
};

this._dft_pump = function(mode) {
    if ( player.ship.equipmentStatus('EQ_DUPLEX_FUEL_TANK') !== 'EQUIPMENT_OK' ) {
	    return;
	}

	let dft = worldScripts['DuplexFuelTank'];

    if (mode) {
        dft.$dft_pump_to_main();
    }
    else {
        dft.$dft_pump_from_main();
    }
};

}).call(this);