Config/script.js |
"use strict";
this.name = "LaveInitialShipyard";
this.author = "phkb";
this.copyright = "2020 phkb";
this.description = "Makes sure Lave has a Cobra Mk I and an Adder for sale when the game starts.";
this.licence = "CC BY-NC-SA 4.0";
//-------------------------------------------------------------------------------------------------------------
this.startUpComplete = function () {
// only do this if we're in Lave, and the clock has just started.
if (galaxyNumber == 0 && system.ID == 7 && clock.daysComponent == 2084004 && clock.hoursComponent == 20 && clock.minutesComponent == 13) {
var bAdder = false;
var bCobra = false;
if (system.mainStation.shipyard && system.mainStation.shipyard.length > 0) {
var sy = system.mainStation.shipyard;
// are the default ships in the shipyard already?
for (var i = 0; i < sy.length; i++) {
if (sy[i].shipdata_key == "adder-player" && sy[i].price == 65000) bAdder = true;
if (sy[i].shipdata_key == "cobramk1-player" && sy[i].price == 101100) bCobra = true;
}
}
if (bAdder == false) {
var keyList = ["adder-player", "griff_adder-PLAYER"];
var idx = 0;
var done = false;
do {
if (Ship.shipDataForKey(keyList[idx]).roles == "player") {
system.mainStation.addShipToShipyard({
short_description: "Adder: Standard customer model. Price 65 000 ₢.",
shipdata_key: keyList[idx],
price: 65000,
personality: Math.floor(Math.random() * 32768),
extras: ["EQ_HEAT_SHIELD"]
});
done = true;
} else {
idx += 1;
}
} while (done == false && idx < keyList.length);
}
if (bCobra == false) {
var keyList = ["cobramk1-player", "griff_cobra_Mk1-PLAYER"];
var idx = 0;
var done = false;
do {
if (Ship.shipDataForKey(keyList[idx]).roles == "player") {
system.mainStation.addShipToShipyard({
short_description: "Cobra Mark I: Plus Fuel Scoops. Price 101 100 ₢.",
shipdata_key: keyList[idx],
price: 101100,
personality: Math.floor(Math.random() * 32768),
extras: ["EQ_FUEL_SCOOPS"]
});
done = true;
} else {
idx += 1;
}
} while (done == false && idx < keyList.length);
}
}
// make sure we don't try this again.
delete this.startUpComplete;
} |