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

Expansion Ore Processor

Content

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description Don't accept lousy pay for mined minerals! The Ore Processor extracts any valuable material from scooped asteroid splinters. The equipment is sold at high tech shipyards and is every miner's dream. Don't accept lousy pay for mined minerals! The Ore Processor extracts any valuable material from scooped asteroid splinters. The equipment is sold at high tech shipyards and is every miner's dream.
Identifier oolite.oxp.spara.ore_processor oolite.oxp.spara.ore_processor
Title Ore Processor Ore Processor
Category Equipment Equipment
Author Ark, Dr. Nil, Eric Walch, Kaks, spara Ark, Dr. Nil, Eric Walch, Kaks, spara
Version 2.2.4 2.2.4
Tags
Required Oolite Version
Maximum Oolite Version
Required Expansions
Optional Expansions
Conflict Expansions
Information URL http://wiki.alioth.net/index.php/Ore_Processor n/a
Download URL https://wiki.alioth.net/img_auth.php/0/0e/Ore_processor_2.2.4.oxz n/a
License CC-BY-NC-SA 4.0 CC-BY-NC-SA 4.0
File Size n/a
Upload date 1718666463

Documentation

Also read http://wiki.alioth.net/index.php/Ore%20Processor

ReadMe.old

Ore Processor equipment for Giles William's Oolite
By Dr. Nil.

The Ore Processor costs 3500 Cr and can be found at shipyards of tech level 12 or higher.

It attaches to the fuel scoop and instantly extracts valuable materials from mined asteroid splinters.

Processing the ore costs a certain amount of energy.


Thanks to Little Bear, Cmdr Wyvern, Griff and DaddyHoggy for creative input and bugsquashing.

Special Thanks to Ark for updating this OXP to v.1.5 and to Kaks for finally ironing out the terrible edible killer asteroid bug by making the Ore Processor work differently in different versions of Oolite.

Since version v.1.53 the updating is done by Eric Walch.


----------------------

Version info

v.1.59

- Raised minimum Oolite to 1.74 and removed all the code to stay compatible with older versions.
- Changed the way of awarding processed ore, so you already get a 'hold-full' message when scooping the splinter to be processed instead of ejecting a mineral when the hold seems full after extracting.

v.1.58

- Added code so the ore processor also works with splinters from grifts asteroids.
- Fixed a casing bug that would generate errors in Oolite versions after 1.74.2

v.1.57

- Fixed a bug with sound staying on after processing.
- Fixed a bug on 1.74 were the last ton in the hold could not be processed.

v.1.56

- Prepared for the even newer cargo handling in Oolite 1.74 (rev 3091+).

v.1.55

- Prepared for the new cargo handling in Oolite 1.74.

v.1.54

- The processor does not try to add processed goods when the hold was filled during processing. Instead they are ejected now when there is no storing room available after processing.

v.1.53

Update by Eric:
- Gave all barrels a js script. These scripts are used by Oolite 1.70+. scripts now can differentiate between singular and plural form in messages, based on actual quantity after quantity randomisation.
- Older oolite versions will use the old script_action code. Here I deliberately let the Gem splinters award gold in the script_action because the windows version of pre 1.70 Oolites had a bug that it gave food instead of gems. This way a condition is avoided.
- Added new textures for different splinters. (used by Oolite 1.70+.)
- Extracting ore now uses 64 units of energy. (= about one energy bank) On low energy situations no extraction takes place.
- Extraction now takes 5 seconds per splinter.
- Added extraction sound.
 
v.1.52

Update by Kaks:
- Bugfix.

v.1.51

Update by Kaks:
- The Ore Processer now works differently with Oolite 1.65 and Oolite 1.70 up. Gem stones only available in 1.70 up to stop splinters from awarding food.

v.1.5

- Price has been increased

update by Ark:
- Scripted messages tell the player what material has been extracted.
- The Ore Processor can now extract gem stones
- code has been optimized

v.1.03

No more rock candy. Seriously

v.1.02

Edible asteroids have been removed :o)

ore_processor_readme_&_license.txt

Ore Processor OXP ver 2.2.3 (02/07/2019)

Author: spara (Mika SpÄra) upgrading work by Dr. Nil & Eric Walch

_Description_

This oxp is an update to the original Ore Processor oxp by Dr. Nil & Eric Walch to better fit into Oolite with different rock texturing oxps installed. It also changes the behaviour of the equipment from automatic to primable and adds a short range scanning function.

* By default valuables are randomly put into any splinter from any splinter set installed. Optionally the original textured scripted custom splinters from the previous version can be mixed in by renaming the file shipdata.plist_ to shipdata.plist.
* Toughness of the splinters is varied. Some splinters take more time to process than others.
* Equipment has to be manually operated. Scoop a splinter or splinters. Start processing them by priming the equipment with shift-n and pressing n. Processing can be aborted by pressing n again. An upgrade to equipment is available to make it automatic.
* Processing can be resumed after aborting.
* With an upgrade the equipment can make a short range scan of a targeted splinter for valuables. Prime equipment, target a splinter and press b. Scan takes a few moments and some energy. Scanning can be aborted by pressing b while scan is active.

_Installing_

Install the OXP by copying ore_processor.oxp to your AddOns-folder.

_Credits_

* Original oxp by Dr. Nil & Eric Walch. See ReadMe.old for details.

_Version History_
V2.2.4
- Fixed issue where a respray of a ship could result in losing the "Hardwire Ore Processor".
- Added Library Config option to turn on custom splinters (so you don't have to rename shipdata files to do it).

v2.2.3
- Commodity name now generated using core function. Updated commodity type to use core names (ie "gem_stones" instead of "Gem-Stones").
- Splinter array cleared when docking.
- Made energy drain values into centralised variables for easy tweaking.

------

This work is licensed under the Creative Commons Attribution-Noncommercial-Share Alike 4.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/

Equipment

Name Visible Cost [deci-credits] Tech-Level
Hardwire Ore Processor no 200 1+
Ore Processor yes 35000 12+
Ore Scanner yes 4250 12+
Undo Hardwiring from Ore Processor no 200 1+

Ships

Name
op_alloys
op_alloys2
op_alloys3
op_alloys4
op_gems
op_gems2
op_gems3
op_gems4
op_gold
op_gold2
op_gold3
op_gold4
op_minerals3
op_minerals4
op_platinum
op_platinum2
op_platinum3
op_platinum4
op_radioactives
op_radioactives2
op_radioactives3
op_radioactives4
Splinter
Splinter

Models

This expansion declares no models.

Scripts

Path
Config/script.js
"use strict";
this.name = "oreProcessor";
this.author = "Eric, spara";
this.copyright = "Creative Commons: attribution, non-commercial, sharealike.";
this.description = "Ore processor main";

//2.2.4 Custom splinters can now be turned on/off via library config.
//2.2.3 set ranges into dictionary, moved to core game commodity names, using core function for display names
//2.2.1 Gem-Stones bug fix for Oolite 1.81
//2.2 scanner is now a separate equipment/upgrade. Failure chance is removed.
//2.1.1 added support for manifest_mfd
//2.1 added support for griff's additional shipset splinters
//2.1 added the possibility to hard-wire the processor to work without activation

this._splinter = new Array(); // array that will hold a list of splinter records

this._config = {
	useCustomSplinters: false,
};

this._opConfig = {
	Name: this.name,
	Alias: "Ore Processor",
	Display: "General settings",
	Alive: "_opConfig",
	Bool: {
		B0: { Name: "_config.useCustomSplinters", Def: false, Desc: "Use custom splinters" },
		Info: "0: Use custom splinter models"
	},
};

this.startUp = function () {
	this._oreTimer = new Timer(this, this.$processOre.bind(this), 5, 0.5);
	this._oreTimer.stop();
	this._scanTimer = new Timer(this, this.$scanForMinerals.bind(this), 1, 1);
	this._scanTimer.stop();
	this._mySound = new SoundSource;
	this._scanSound = new SoundSource;
	this._mySound.sound = "op_process.ogg";
	this._mySound.loop = false;
	this._powerDrain = 6.4;
	this._scanDrain = 3.2;
	this._spec = {
		"300": {type:"alloys", quantity:1, message:"@1t alloys extracted"},
		"315": {type:"gem_stones", quantity:-5, message:"@1g gem-stones extracted"},
		"330": {type:"gem_stones", quantity:-7, message:"@1g gem-stones extracted"},
		"346": {type:"gem_stones", quantity:-10, message:"@1g gem-stones extracted"},
		"386": {type:"gold", quantity:-2, message:"@1kg gold extracted"},
		"396": {type:"gold", quantity:-3, message:"@1kg gold extracted"},
		"406": {type:"gold", quantity:-6, message:"@1kg gold extracted"},
		"421": {type:"platinum", quantity:-2, message:"@1kg platinum extracted"},
		"444": {type:"platinum", quantity:-3, message:"@1kg platinum extracted"},
		"452": {type:"platinum", quantity:-6, message:"@1kg platinum extracted"},
		"592": {type:"radioactives", quantity:1, message:"@1t radioactives extracted"},
		"-99": {type:"minerals", quantity:1, message:"@1t raw minerals extracted"},
	};
	if (missionVariables.OreProcessor) {
		this._opConfig = JSON.parse(missionVariables.OreProcessor);
	}
}

this.startUpComplete = function() {
	// register our settings, if Lib_Config is present
	if (worldScripts.Lib_Config) {
		var lib = worldScripts.Lib_Config;
		lib._registerSet(this._opConfig);
	}
}

this.playerWillSaveGame = function() {
	missionVariables.OreProcessor = JSON.stringify(this._opConfig);
}

this.shipDockedWithStation = function (station) {
	this._splinter.length = 0; // cleanup
}

this.playerBoughtEquipment = function (equipment) {
	if (equipment === "EQ_UNDO_HARDWIRE_ORE_PROCESSOR") {
		player.ship.removeEquipment("EQ_HARDWIRE_ORE_PROCESSOR");
		player.ship.removeEquipment("EQ_UNDO_HARDWIRE_ORE_PROCESSOR");
	}
}

// Add scooped splinter to splinter array.
this.shipScoopedOther = function (whom) {
	// Check that the scooped item is a splinter, contains minerals and is not scripted
	if ((whom.primaryRole !== "splinter" && whom.primaryRole !== "griff_splinter") || whom.commodity !== "minerals" || whom.script.name !== "oolite-default-ship-script") return;
	// Check that the splinter is not already added to prevent double booking. This happens when scooping, dumping, scooping...
	for (var i = 0; i < this._splinter.length; i++) {
		if (this._splinter[i] === whom)
			this._splinter.splice(i, 1);
	}
	// Add valuables to the scooped splinter
	this.$addValuablesToSplinter(whom);
	// Add unprocessed scooped splinter to the list of unprocessed splinters
	if (whom.$oreProcessor.count > 0) this._splinter.push(whom);
	// Automagically start processing if the processor has been hardwired
	if (player.ship.equipmentStatus("EQ_HARDWIRE_ORE_PROCESSOR") === "EQUIPMENT_OK" && player.ship.equipmentStatus("EQ_ORE_PROCESSOR") === "EQUIPMENT_OK" && this._splinter.length > 0 && !this._oreTimer.isRunning) {
		this.$extract();
	}
}

this.$processOre = function $processOre() {
	// remove lost splinters from the array and stop processing if we run out splinters
	while (this._splinter[0].status !== "STATUS_IN_HOLD") {
		// remove dumped splinter from process array
		this._splinter.shift();
		// stop processing if out of splinters
		if (this._splinter.length === 0) {
			this._oreTimer.stop();
			this._mySound.stop();
			return;
		}
	}
	// busy processing splinter
	if (parseInt(this._splinter[0].$oreProcessor.count) > 0 && player.ship.energy > this._powerDrain) {
		player.consoleMessage("Processing ore.");
		this._splinter[0].$oreProcessor.count--;
		player.ship.energy -= this._powerDrain;
	} else {
		if (this.toggle) this.toggle = false;
		else this.toggle = true; // to avoid identical message suppression.
		if (parseInt(this._splinter[0].$oreProcessor.count) === 0) {
			// process splinter
			if (this._splinter[0].status === "STATUS_IN_HOLD") {
				player.consoleMessage(expandDescription(this._splinter[0].$oreProcessor.message) + (this.toggle ? "" : " "));
				this._splinter[0].setCargo(this._splinter[0].$oreProcessor.type, this._splinter[0].$oreProcessor.quantity);
				this._splinter[0].displayName = "Processed Splinter (" + displayNameForCommodity(this._splinter[0].$oreProcessor.type) + ")";
				this._splinter.shift(); // remove the processed splinter from the unprocessed splinter array.
				// notify manifest_mfd about content cargo change
				if (worldScripts["manifest_mfd"])
					worldScripts["manifest_mfd"].notifyCargoChange();
			}
		} else {
			// stop processing if out of energy
			player.consoleMessage("Not enough energy, processing aborted!!");
			this._oreTimer.stop();
			this._mySound.stop();
			return;
		}
		// restart the sound for next splinter
		if (this._splinter.length > 0) this._mySound.play(10);
		else {
			// last splinter processed, lets stop
			this._oreTimer.stop();
			this._mySound.stop();
		}
	}
}

// Add contents to splinters
this.$addValuablesToSplinter = function $addValuablesToSplinter(ship) {
	// Check if the splinter has already been handled
	if (!ship.$oreProcessor) {
		var type, quantity, message;
		// handle custom splinters
		if (ship.scriptInfo.cargotype) {
			type = ship.scriptInfo.cargotype;
			quantity = parseInt(ship.scriptInfo.quantity);
			message = ship.scriptInfo.message;
		}
		// handle regular splinters
		else {
			var randomOre = Math.floor(992 * Math.random()); //0 - 991
			var ranges = Object.keys(this._spec);
			var found = false;
			for (var i = 0; i < ranges.length; i++) {
				if (randomOre < parseInt(ranges[i])) {
					var range = this._spec[ranges[i]];
					type = range.type;
					quantity = range.quantity;
					message = range.message;
					found = true;
					break;
				}
			}
			if (found === false) {
				type = this._spec["-99"].type;
				quantity = this._spec["-99"].quantity;
				message = this._spec["-99"].message;
			}
		}
		if (quantity < 0) quantity = Math.ceil(Math.random() * (-quantity)); // only negative values are randomised.
		ship.$oreProcessor = {
			message: message.replace("@1", quantity),
			type: type,
			quantity: quantity,
			// randomize hardness of the splinter
			count: 5 + Math.random() * 15
		};
	}
}

//Activate/deactivate the ore processor
this.$extract = function $extract() {
	// Start processing
	if (!this._oreTimer.isRunning) {
		if (player.ship.energy > this._powerDrain) {
			var process = false;
			// check that there is a splinter to process in the hold. If unprocessed splinter has been dumped or it is destroyed, it cannot be processed, thus the record is removed.
			for (var i = this._splinter.length - 1; i >= 0; i--) {
				if (this._splinter[i].status === "STATUS_IN_HOLD") {
					process = true;
					break;
				} else this._splinter.pop();
			}
			// found something to process, let's go
			if (process) {
				this._oreTimer.start();
				if (!this._mySound.isPlaying) this._mySound.play(10);
			}
			// nothing to process, let's not go
			else player.consoleMessage("No unprocessed splinters to process.");
		} else player.consoleMessage("Not enough energy to start processing.");
	}
	// Stop processing
	else {
		this._oreTimer.stop();
		this._mySound.stop();
		player.consoleMessage("Processing aborted.");
	}
}

// Activate scan
this.$activateScan = function $activateScan() {
	if (!this._scanTimer.isRunning) {
		if (player.ship.energy > this._scanDrain) {
			this.$pass = 0;
			this.$originalTarget = player.ship.target;
			//randomize the time that a scan will take.
			//this.$scanRounds = 5 + Math.round(Math.random() * 5);
			this._scanTimer = new Timer(this, this.$scanForMinerals.bind(this), 0);
		} else player.consoleMessage("Not enough energy to start scanning.");
	} else {
		this._scanTimer.stop();
		this._scanSound.stop();
		player.consoleMessage("Scanning aborted.");
	}
}

// The actual scanning function
this.$scanForMinerals = function $scanForMinerals() {
	var target = player.ship.target;
	// notify sound
	this._scanSound.sound = "[@boop]";
	// No target
	if (!target) {
		this._scanSound.play();
		player.consoleMessage("No target to scan.");
		return;
	}
	// Target switched while scanning
	if (this.$originalTarget !== target) {
		this._scanSound.play();
		player.consoleMessage("Target lost, scan aborted");
		return;
	}
	// Target is not a splinter
	if (target.primaryRole !== "splinter" && target.primaryRole !== "griff_splinter") {
		this._scanSound.play();
		player.consoleMessage("Target is not a splinter.");
		return;
	}
	// Target is too far
	if (player.ship.position.distanceTo(target) > 2500) {
		this._scanSound.play();
		player.consoleMessage("Target is too far for scanning.");
		return;
	}
	// Valuables are already detected
	if (target.displayName.indexOf("(") !== -1) {
		this._scanSound.play();
		player.consoleMessage("Minerals already detected.");
		return;
	}
	// If enough energy, scan
	if (player.ship.energy > this._scanDrain) {
		this._scanSound.sound = "op_scan.ogg";
		this._scanSound.play();
		if (this.$pass < 9 /*this.$scanRounds*/ ) {
			player.consoleMessage("Scanning for minerals.");
			player.ship.energy -= this._scanDrain;
			this.$pass++;
			this._scanTimer = new Timer(this, this.$scanForMinerals.bind(this), 0.5);
			return;
		} else {
			this.$addValuablesToSplinter(target);
			if (target.$oreProcessor.type !== "minerals") {
				this.$addValuablesToSplinter(target);
				player.consoleMessage(displayNameForCommodity(target.$oreProcessor.type) + " detected.");
				target.displayName = target.name + " (" + displayNameForCommodity(target.$oreProcessor.type) + ")";
				return;
			}
		}
	}
	// Energy low, abort
	else {
		this._scanSound.play();
		player.consoleMessage("Not enough energy, scan aborted.");
		return;
	}
	// No valuables found
	player.consoleMessage("No valuable minerals detected.");
	target.displayName = target.name + " (Common Minerals)";
}
Scripts/ore_processor_conditions.js
"use strict";
this.name = "OreProcessor_Conditions";
this.author = "phkb";
this.copyright = "CC-BY-SA-NC 4.0";
this.description = "Condition script";

//-------------------------------------------------------------------------------------------------------------
// ship condition script
this.allowSpawnShip = function(shipKey) {
    var ws = worldScripts.oreProcessor;
    if (ws._config.useCustomSplinters) return true;
    return false;
}
Scripts/ore_processor_equipment.js
"use strict";
this.name = "ore_processor_equipment";
this.author = "spara";
this.copyright = "2014 Mika Spara";
this.licence = "CC BY-NC-SA 3.0";
this.description = "Equipment activation script for ore processor";
this.version = "2.2";

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

// equipment activation b
this.mode = function () {
	if (player.ship.equipmentStatus("EQ_ORE_SCANNER") === "EQUIPMENT_OK" && player.ship.equipmentStatus("EQ_ORE_PROCESSOR") === "EQUIPMENT_OK")
		worldScripts.oreProcessor.$activateScan();
}

// hard-wiring can be bought from hermits only
this.allowAwardEquipment = function (equipKey, ship, context) {
	if (context == "scripted") return true;
	if (player.ship.dockedStation.primaryRole === "rockhermit") {
		return true;
	}
	return false;
}