Skip to content

Commit

Permalink
Added options for dropping fuel
Browse files Browse the repository at this point in the history
  • Loading branch information
Tro95 committed May 4, 2020
1 parent 1d62a45 commit df7f0a3
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
7 changes: 6 additions & 1 deletion drop_cargo.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
/* global PardusOptions, PardusOptionsUtility */
function drop_cargo() {
var drop_table;

if (!GM_getValue(PardusOptionsUtility.getVariableName('cargo_drop_enabled'), true)) {
return;
}

findTables();
parseDropCargoTables();
autodropFuel();
Expand All @@ -27,7 +32,7 @@ function drop_cargo() {
}

function autodropFuel() {
if (commodities[items.indexOf("Hydrogen fuel")].ship_stock > fuel_space_left) {
if (GM_getValue(PardusOptionsUtility.getVariableName('drop_excess_fuel'), true) && commodities[items.indexOf("Hydrogen fuel")].ship_stock > fuel_space_left) {
commodities[items.indexOf("Hydrogen fuel")].sell(commodities[items.indexOf("Hydrogen fuel")].ship_stock - fuel_space_left);
}
}
Expand Down
37 changes: 35 additions & 2 deletions options.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,14 @@ function troderOptions() {
padding: '10px',
});

var shiptransfer_subtab = troder_options_tab.addSubTab({
var ship_transfer_subtab = troder_options_tab.addSubTab({
label: 'Ship Transfer',
});

var cargo_drop_subtab = troder_options_tab.addSubTab({
label: 'Cargo Dropping',
});

droidWashingOptions(droidwashing_subtab);
fuelOptions(troder_options_tab);
planetAOptions(planets_subtab);
Expand All @@ -49,10 +53,39 @@ function troderOptions() {
planetDOptions(planets_subtab);
starbaseOptions(sb_subtab);
blackmarketOptions(bm_subtab);
shipTransferOptions(shiptransfer_subtab);
shipTransferOptions(ship_transfer_subtab);
cargoDroppingOptions(cargo_drop_subtab);

troder_options_tab.refreshElement();

function cargoDroppingOptions(subtab) {
const cargo_dropping_main_box = subtab.addBox({
heading: 'Cargo Dropping',
description: 'These options control cargo dropping.'
});

cargo_dropping_main_box.addBooleanOption({
variable: 'cargo_drop_enabled',
description: 'Enable cargo dropping',
defaultValue: true,
});

const cargo_dropping_items_box = subtab.addBox({
heading: 'Items',
description: 'These options configure the individual resources to drop.'
});

cargo_dropping_items_box.addBooleanOption({
variable: 'drop_excess_fuel',
description: 'Drop excess fuel',
defaultValue: true,
info: {
title: 'Excess Fuel',
description: 'Excess fuel is any fuel above the configured amount of fuel to leave on the ship. This value can be configured in the \'General\' tab of the Pardus Troder options, and defaults to 5t.'
},
});
}

function shipTransferOptions(subtab) {
const ship_transfer_options_box = subtab.addBox({
heading: 'Ship Transfer',
Expand Down

0 comments on commit df7f0a3

Please sign in to comment.