Config/script.js |
this.name = "telescope_StationOptions";
this.author = "cag, Cholmondely";
this.copyright = "2021 cag, Cholmondely";
this.license = "CC BY-NC-SA 4.0";
this.description = "Access Telescope while docked at Station";
this.version = "1.0";
/* jshint elision: true, shadow: true, esnext: true, curly: false, maxerr: 1000, asi: true,
laxbreak: true, undef: true, unused: true, evil: true, forin: true, eqnull: true,
noarg: true, eqeqeq: true, boss: true, loopfunc: true, strict: true, nonew: true, noempty: false
*/
/*jslint indent: 4, white: true, debug: true, continue: true, sub: true, css: false, todo: true,
on: false, fragment: false, vars: true, nomen: true, plusplus: true, bitwise: true,
regexp: true, newcap: true, unparam: true, sloppy: true, eqeq: true, stupid: true
*/
/* global log, player, worldScripts
*/
this.startUp = function startUp() {
var tso = worldScripts.telescope_StationOptions;
var ws = worldScripts.telescope;
var so = worldScripts.station_options;
if( !so ) {
log( "telescope_StationOptions", '\nstartUp, station_options oxp is missing!\n' );
return;
}
if( !ws ) {
log( "telescope_StationOptions", '\nstartUp, telescope oxp is missing!\n' );
return;
}
var version = parseFloat(ws.version);
if( version >= 2.0 ) {
log( "telescope_StationOptions", '\nstartUp, telescope version is ' + ws.version
+ ', aborting. This oxp is only for earlier versions of telescope.\n' );
return;
}
if( version < 1.13 ) { // introduced in 1.13
ws.$TelescopeBrightMassLockBorders = false;
}
tso._loadSavedOptions();
ws.playerWillSaveGame = tso.playerWillSaveGame;
try {
// initialize station options and pass callback functions
so.$O_initStationOptions( ws, // reference to oxp script
'telescope_', // string that begins all keys in missiontext.plist
tso._stnOptionsAllowed, // reference to script function
true, // call playerWillSaveGame? (telescope oxp has none)
tso._reloadFromStn ); // reference to script function
if( tso._stnOptionsAllowed() ) {
// ensure a loaded game will have so's interface set
so.equipmentAdded();
}
} catch( err ) {
log( "telescope_StationOptions", '\nstartUp, ' + err + '\n');
throw err;
}
}
this._stnOptionsAllowed = function _stnOptionsAllowed() {
var ws = worldScripts.telescope;
var ps = player && player.ship;
/*
log("telescope_StationOptions", '_stnOptionsAllowed, equipmentStatus = ' + ps.equipmentStatus( 'EQ_TELESCOPE' )
+ ', TelescopeFixedTel = ' + ws.$TelescopeFixedTel );
*/
return ps && ps.equipmentStatus( 'EQ_TELESCOPE' ) === 'EQUIPMENT_OK'
&& ws.$TelescopeFixedTel !== 1;
}
this._reloadFromStn = function _reloadFromStn( names, pages ) {
log("telescope_StationOptions", '_reloadFromStn, pages = ' + pages + '\n\t names = ' + names );
}
this._loadSavedOptions = function _loadSavedOptions() {
var item, ws = worldScripts.telescope;
if( !ws )
return;
item = missionVariables.$TelescopeAutoScan;
if( item === null )
return; // none were saved
ws.$TelescopeAutoScan = item;
item = missionVariables.$TelescopeAutoScanMaxRange;
if( item !== null )
ws.$TelescopeAutoScanMaxRange = item;
item = missionVariables.$TelescopeAutoLock;
if( item !== null )
ws.$TelescopeAutoLock = item;
item = missionVariables.$TelescopeFarStatus;
if( item !== null )
ws.$TelescopeFarStatus = item;
item = missionVariables.$TelescopeGravLock;
if( item !== null )
ws.$TelescopeGravLock = item;
item = missionVariables.$TelescopeIdentLock;
if( item !== null )
ws.$TelescopeIdentLock = item;
item = missionVariables.$TelescopeLargeLightBalls;
if( item !== null )
ws.$TelescopeLargeLightBalls = item;
item = missionVariables.$TelescopeLightBalls;
if( item !== null )
ws.$TelescopeLightBalls = item;
item = missionVariables.$TelescopeMassLockBorders;
if( item !== null )
ws.$TelescopeMassLockBorders = item;
item = missionVariables.$TelescopeBrightMassLockBorders;
if( item !== null )
ws.$TelescopeBrightMassLockBorders = item;
item = missionVariables.$TelescopeRedAlertDist;
if( item !== null )
ws.$TelescopeRedAlertDist = item;
item = missionVariables.$TelescopeRedAlertLimiter;
if( item !== null )
ws.$TelescopeRedAlertLimiter = item;
item = missionVariables.$TelescopeRing;
if( item !== null )
ws.$TelescopeRing = item;
item = missionVariables.$TelescopeShipLightBalls;
if( item !== null )
ws.$TelescopeShipLightBalls = item;
item = missionVariables.$TelescopeShowVisualQuestionMark;
if( item !== null )
ws.$TelescopeShowVisualQuestionMark = item;
item = missionVariables.$TelescopeShowVisualStation;
if( item !== null )
ws.$TelescopeShowVisualStation = item;
item = missionVariables.$TelescopeShowVisualTarget;
if( item !== null )
ws.$TelescopeShowVisualTarget = item;
item = missionVariables.$TelescopeSniperMinRange;
if( item !== null )
ws.$TelescopeSniperMinRange = item;
item = missionVariables.$TelescopeSniperRange;
if( item !== null )
ws.$TelescopeSniperRange = item;
item = missionVariables.$TelescopeSniperRingSize;
if( item !== null )
ws.$TelescopeSniperRingSize = item;
item = missionVariables.$TelescopeSteering;
if( item !== null )
ws.$TelescopeSteering = item;
item = missionVariables.$TelescopeTargets;
if( item !== null )
ws.$TelescopeTargets = item;
// this was only meant for testing, remove it!
item = missionVariables.$TelescopeThargoids;
if( item !== null ) {
delete missionVariables.$TelescopeThargoids;
ws.$TelescopeThargoids = false;
// ws.$TelescopeThargoids = item;
}
item = missionVariables.$TelescopeVMarkMinDist;
if( item !== null )
ws.$TelescopeVMarkMinDist = item;
item = missionVariables.$TelescopeVMarkShipMinDist;
if( item !== null )
ws.$TelescopeVMarkShipMinDist = item;
item = missionVariables.$TelescopeVPosHUD;
if( item !== null )
ws.$TelescopeVPosHUD = JSON.parse( item );
item = missionVariables.$TelescopeVSize;
if( item !== null )
ws.$TelescopeVSize = item;
item = missionVariables.$TelescopeVZoomSize;
if( item !== null )
ws.$TelescopeVZoomSize = item;
}
this.playerWillSaveGame = function playerWillSaveGame() {
var ws = worldScripts.telescope;
if( !ws )
return;
missionVariables.$TelescopeAutoScan = ws.$TelescopeAutoScan;
missionVariables.$TelescopeAutoScanMaxRange = ws.$TelescopeAutoScanMaxRange;
missionVariables.$TelescopeAutoLock = ws.$TelescopeAutoLock;
missionVariables.$TelescopeFarStatus = ws.$TelescopeFarStatus;
missionVariables.$TelescopeGravLock = ws.$TelescopeGravLock;
missionVariables.$TelescopeIdentLock = ws.$TelescopeIdentLock;
missionVariables.$TelescopeLargeLightBalls = ws.$TelescopeLargeLightBalls;
missionVariables.$TelescopeLightBalls = ws.$TelescopeLightBalls;
missionVariables.$TelescopeMassLockBorders = ws.$TelescopeMassLockBorders;
missionVariables.$TelescopeBrightMassLockBorders = ws.$TelescopeBrightMassLockBorders;
missionVariables.$TelescopeRedAlertDist = ws.$TelescopeRedAlertDist;
missionVariables.$TelescopeRedAlertLimiter = ws.$TelescopeRedAlertLimiter;
missionVariables.$TelescopeRing = ws.$TelescopeRing;
missionVariables.$TelescopeShipLightBalls = ws.$TelescopeShipLightBalls;
missionVariables.$TelescopeShowVisualQuestionMark = ws.$TelescopeShowVisualQuestionMark;
missionVariables.$TelescopeShowVisualStation = ws.$TelescopeShowVisualStation;
missionVariables.$TelescopeShowVisualTarget = ws.$TelescopeShowVisualTarget;
missionVariables.$TelescopeSniperMinRange = ws.$TelescopeSniperMinRange;
missionVariables.$TelescopeSniperRange = ws.$TelescopeSniperRange;
missionVariables.$TelescopeSniperRingSize = ws.$TelescopeSniperRingSize;
missionVariables.$TelescopeSteering = ws.$TelescopeSteering;
missionVariables.$TelescopeTargets = ws.$TelescopeTargets;
// missionVariables.$TelescopeThargoids = ws.$TelescopeThargoids;
missionVariables.$TelescopeVMarkMinDist = ws.$TelescopeVMarkMinDist;
missionVariables.$TelescopeVMarkShipMinDist = ws.$TelescopeVMarkShipMinDist;
missionVariables.$TelescopeVPosHUD = JSON.stringify( ws.$TelescopeVPosHUD );
missionVariables.$TelescopeVSize = ws.$TelescopeVSize;
missionVariables.$TelescopeVZoomSize = ws.$TelescopeVZoomSize;
}
|