Back to Index Page generated: May 8, 2024, 6:16:03 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.2 2.2.2
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/e/e4/Ore_processor_2.2.2.oxz n/a
License CC-BY-NC-SA 4.0 CC-BY-NC-SA 4.0
File Size n/a
Upload date 1610873499

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.2 (26.12.2015)

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 upgrate the tquipment 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.

------

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

This expansion declares no ships.

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.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 hardwire the processor to work without activation

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

this.startUp = function () {
	this.oreTimer = new Timer(this, this.processOre, 5, 0.5);
	this.oreTimer.stop();
	this.$scanTimer = new Timer(this, this.$scanForMinerals, 1, 1);
	this.$scanTimer.stop();
	this.mySound = new SoundSource;
	this.$scanSound = new SoundSource;
	this.mySound.sound = "op_process.ogg";
	this.mySound.loop = false;
}

this.processOre = function () {
	//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 > 6.4) {
		player.consoleMessage("Processing ore.");
        this.splinter[0].$oreProcessor.count--;
		player.ship.energy -= 6.4;
	}
	else {
        if (this.toggle) this.toggle=false; else this.toggle = true; // to avoid identical message supression.
		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?"":" "));
				//1.81 fix
				if (this.splinter[0].$oreProcessor.type === "Gem-Stones" && oolite.compareVersion("1.80") === -1)
					this.splinter[0].setCargo("gem_stones", this.splinter[0].$oreProcessor.quantity);
				else
					this.splinter[0].setCargo(this.splinter[0].$oreProcessor.type.toLowerCase(), this.splinter[0].$oreProcessor.quantity);
				this.splinter[0].displayName = "Processed Splinter ("+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(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
			if (randomOre < 300) {
				type = "Alloys";
				quantity = 1;
				message = "@1 ton of Alloys extracted.";
			}
			else if (randomOre < 315) {
				type = "Gem-Stones";
				quantity = -5;
				message = "Extracted @1 gr of Gems from the splinter!!";
			}
			else if (randomOre < 330) {
				type = "Gem-Stones";
				quantity = -7;
				message = "Extracted @1 gr of Gems from the splinter!!";
			}
			else if (randomOre < 346) {
				type = "Gem-Stones";
				quantity = -10;
				message = "Extracted @1 gr of Gems from the splinter!!";
			}
			else if (randomOre < 386) {
				type = "Gold";
				quantity = -2;
				message = "@1 kilogram of Gold extracted.";
			}
			else if (randomOre < 396) {
				type = "Gold";
				quantity = -3;
				message = "@1 kilogram of Gold extracted.";
			}
			else if (randomOre < 406) {
				type = "Gold";
				quantity = -6;
				message = "@1 kilogram of Gold extracted.";
			}
			else if (randomOre < 421) {
				type = "Platinum";
				quantity = -2;
				message = "@1 kilogram of Platinum extracted.";
			}
			else if (randomOre < 444) {
				type = "Platinum";
				quantity = -3;
				message = "@1 kilogram of Platinum extracted.";
			}
			else if (randomOre < 452) {
				type = "Platinum";
				quantity = -6;
				message = "@1 kilogram of Platinum extracted.";
			}
			else if (randomOre < 592) {
				type = "Radioactives";
				quantity = 1;
				message = "@1 ton of Radioactives extracted.";
			}
			else {
				type = "Minerals";
				quantity = 1;
				message = "@1 ton of Common Minerals.";
			}
		}
		if (quantity < 0) 
			quantity= Math.ceil(Math.random()*(-quantity)); // only negative values are randomised.
		if (quantity > 1) {
			message = message.replace("gr ", "grs ");
			message = message.replace("kilogram ", "kilograms ")
		}
		ship.$oreProcessor = {	message: message.replace("@1", quantity), 
								type: type,
								quantity: quantity,
								//randomize hardness of the splinter
								count: 5 + Math.random() * 15};
   }
}

//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();
	}
}

//Activate/deactivate the ore processor
this.$extract = function() {
	//Start processing
	if (!this.oreTimer.isRunning) {
		if (player.ship.energy > 6.4) {
			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; i > 0; i--) {
				if (this.splinter[i-1].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() {
	if (!this.$scanTimer.isRunning) {
		if (player.ship.energy > 3.2) {
			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, 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() {
	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 > 3.2) {
		this.$scanSound.sound = "op_scan.ogg";
		this.$scanSound.play();
		if (this.$pass < 9/*this.$scanRounds*/) {
			player.consoleMessage("Scanning for minerals.");
			player.ship.energy -= 3.2;
			this.$pass++;
			this.$scanTimer = new Timer(this, this.$scanForMinerals, 0.5);
			return;
		}
		else {
			this.$addValuablesToSplinter(target);
			if (target.$oreProcessor.type !== "Minerals") {
				this.$addValuablesToSplinter(target);
				player.consoleMessage(target.$oreProcessor.type+" detected.");
				target.displayName = target.name+" ("+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)";
}

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");
	}
}
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();
}

//hardwiring can be bought from hermits only
this.allowAwardEquipment = function() {
	if (player.ship.dockedStation.primaryRole === "rockhermit") {
		return true;
	}
	return false;
}