Back to Index Page generated: Dec 20, 2024, 7:22:10 AM

Expansion Glare Filter

Content

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description Paint your ship with electroactive polymer solution that filters sun glare. Three levels of filtering are possible by conducting electricity to the hull of the ship. When used, the coating gradually degrades and needs to be replaced. Paint your ship with electroactive polymer solution that filters sun glare. Three levels of filtering are possible by conducting electricity to the hull of the ship. When used, the coating gradually degrades and needs to be replaced.
Identifier oolite.oxp.spara.glare_filter oolite.oxp.spara.glare_filter
Title Glare Filter Glare Filter
Category Equipment Equipment
Author spara spara
Version 1.0 1.0
Tags
Required Oolite Version
Maximum Oolite Version
Required Expansions
Optional Expansions
Conflict Expansions
Information URL http://aegidian.org/bb/viewtopic.php?f=4&t=16533 n/a
Download URL https://wiki.alioth.net/img_auth.php/2/27/Glare_filter_1.0.oxz n/a
License CC-BY-NC-SA 3.0 CC-BY-NC-SA 3.0
File Size n/a
Upload date 1610873255

Documentation

Also read http://wiki.alioth.net/index.php/Glare%20Filter

Equipment

Name Visible Cost [deci-credits] Tech-Level
Glare Filter yes 300 2+
Glare Filter yes 300 2+

Ships

This expansion declares no ships.

Models

This expansion declares no models.

Scripts

Path
Config/script.js
this.name           = "glare_filter";
this.author         = "spara";
this.copyright      = "2014 Mika Spåra";
this.description    = "Filter to diminish sun glare";
this.version        = "1.0";
this.licence    	= "CC BY-NC-SA 3.0";

//filter burns 2 * filter level in one second.
//0.6 -> 120 seconds (2 mins)
//0.4 -> 180 seconds (3 mins)
//0.2 -> 300 seconds (5 mins)
//duration in seconds at 0.5 level
this.$fullFilterDuration = 144;

this.startUpComplete = function() {
	//set up timer
	if (player.ship.equipmentStatus("EQ_GLARE_FILTER") === "EQUIPMENT_OK") {
		this.$initFilter();
		if (missionVariables.glareFilter)
			this.$filterDuration = missionVariables.glareFilter;
	}
	//three levels of filtering
	this.$filterLevels = [0.2, 0.4, 0.6];
	//current filter level
	this.$filterPointer = 1;
	//state of the equipment
	this.$filterOn = false;
}

this.playerBoughtEquipment = function(equipment) {
	if (equipment === "EQ_GLARE_FILTER") {
		this.$initFilter();
	}
	if (equipment === "EQ_GLARE_FILTER_REPLACE") {
		player.ship.awardEquipment("EQ_GLARE_FILTER");
		player.ship.removeEquipment("EQ_GLARE_FILTER_REPLACE");
		this.$initFilter();
	}
}

this.playerBoughtNewShip = function() {
	player.ship.removeEquipment("EQ_GLARE_FILTER");
}

this.playerWillSaveGame = function() {
	if (player.ship.equipmentStatus("EQ_GLARE_FILTER") === "EQUIPMENT_OK")
		missionVariables.glareFilter = this.$filterDuration;
}

//turn the filter off when docking or witchspacing
this.shipWillDockWithStation = this.shipWillEnterWitchSpace = function() {
	if (this.$filterOn) this.$toggleOnOff();
}

this.$toggleOnOff = function() {
	if (this.$filterOn) {
		this.$filterTimer.stop();
		this.$filterOn = false;
		player.ship.sunGlareFilter = 0;
		player.consoleMessage("Glare Filter: Off.");
	}
	else {
		player.consoleMessage("Glare Filter: On.");
		this.$filterOn = true;
		player.ship.sunGlareFilter = this.$filterLevels[this.$filterPointer];
		this.$filterTimer.start();
	}
}

this.$adjustFilter = function() {
	//change filter level first locally
	var filterPointer = this.$filterPointer + 1;
	//over the top
	if (filterPointer > 2) filterPointer = 0;
	
	//for console
	var filterLevels = ["Low", "Medium", "High"];
	
	//set the filter
	if (this.$filterOn)
		player.ship.sunGlareFilter = this.$filterLevels[filterPointer];
	//print out the message
	player.consoleMessage("Glare Filter: " + filterLevels[filterPointer]+".");

	//update the global filter level pointer
	this.$filterPointer = filterPointer;	
}

//start the timer and reset the duration counter
this.$initFilter = function() {
	if (!this.$filterTimer)
		this.$filterTimer = new Timer(this, this.$burnFilter, 1, 1);
	this.$filterTimer.stop();
	this.$filterDuration = this.$fullFilterDuration;
}

//the actual burning function
this.$burnFilter = function() {
	//there's filter left and filter is active.
	if (this.$filterDuration > 0 && this.$filterOn) {
		//burn filter.
		this.$filterDuration = this.$filterDuration - player.ship.sunGlareFilter * 2;
		var percentageLeft = Math.round((this.$filterDuration / this.$fullFilterDuration) * 100);
		//print messages at 10, 20, ..., 90 %
		if (percentageLeft % 10 === 0 && percentageLeft !== 100 && percentageLeft !== 0)
			player.consoleMessage("Glare Filter: " + percentageLeft + " % left.");
		return;
	}
	//filter burned out
	if (this.$filterDuration <= 0){
		player.ship.removeEquipment("EQ_GLARE_FILTER");
		player.consoleMessage("Glare Filter: Burned out.");
		player.ship.sunGlareFilter = 0;
		this.$filterOn = false;
		this.$filterTimer.stop();
	}
}
Scripts/glare_filter.js
this.name           = "glare_filter_equipment";
this.author         = "spara";
this.copyright      = "2014 Mika Spåra";
this.description    = "Filter equipment";
this.version        = "1.0";
this.licence    	= "CC BY-NC-SA 3.0";

//equipment activation n
this.activated = function() {
	worldScripts.glare_filter.$toggleOnOff();
};

//equipment activation b
this.mode = function() {
	worldScripts.glare_filter.$adjustFilter();
};

//equipment can only be added by script
this.allowAwardEquipment = function(eqKey, ship, context) {
	if (worldScripts.glare_filter.$filterDuration === worldScripts.glare_filter.$fullFilterDuration) return false;
	return true;
};