Back to Index Page generated: Nov 12, 2024, 11:02:03 PM

Expansion AutoRefuel

Content

Warnings

  1. Information URL mismatch between OXP Manifest and Expansion Manager string length at character position 0

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description Automatically refills your fuel tank when you dock, subtracting the cost from your credits. Automatically refills your fuel tank when you dock, subtracting the cost from your credits.
Identifier oolite.oxp.ByronArn.AutoRefuel oolite.oxp.ByronArn.AutoRefuel
Title AutoRefuel AutoRefuel
Category Mechanics Mechanics
Author ByronArn ByronArn
Version 1.0 1.0
Tags
Required Oolite Version
Maximum Oolite Version
Required Expansions
Optional Expansions
Conflict Expansions
Information URL n/a
Download URL https://wiki.alioth.net/img_auth.php/e/e3/AutoRefuelV1.0.oxz n/a
License CC BY-NC-SA 4.0 CC BY-NC-SA 4.0
File Size n/a
Upload date 1610873494

Documentation

Also read http://wiki.alioth.net/index.php/AutoRefuel

README.txt

AutoRefuel
----------
by ByronArn

This OXP automatically refuels your ship when you dock with a station that allows refueling.

As pointed out by forum user Norby, some OXP stations and other dockables do not allow for refueling, and he wrote the part of the code that tests for this.

The suggestion to rename this OXP from AutoFuel to AutoRefuel was from forum user phkb.

Any comments or suggestions about this OXP can be directed to forum user ByronArn.

Equipment

This expansion declares no equipment. This may be related to warnings.

Ships

This expansion declares no ships. This may be related to warnings.

Models

This expansion declares no models. This may be related to warnings.

Scripts

Path
Config/script.js
this.name           = "AutoRefuel";
this.author         = "ByronArn";
this.copyright      = "(C) 2016 ByronArn.";
this.licence        = "CC BY-NC-SA 4.0";
this.description    = "Automatically refills your fuel tank when you dock, subtracting the cost from your credits.";
this.version        = "1.0";

"use strict"

// Code for the conditional to see if the the dockable allows refuelng was written by Oolite forum user Norby.
// Suggestion to change name of OXP from AutoFuel to AutoRefuel was from Oolite forum user phkb.

this.shipDockedWithStation = function(station) {
	if (player.ship.fuel < 7) {
		var ds = player.ship.dockedStation;
		if (ds) {
			var barred = false;
			var si = ds.scriptInfo;
			if (si) barred = si["oolite-barred-equipment"];
			if (!barred || barred.indexOf("EQ_FUEL") == -1)  {
				var amount = 7-player.ship.fuel;
				var price = 24/7;
				var total = amount*price;
				if (total < player.credits) {
					player.ship.fuel = 7;
					player.credits-=total;
					player.consoleMessage("Fuel tank filled! "+total.toFixed(1)+"Cr deducted from your account!", 10);
				} else player.consoleMessage("AutoRefuel Error: Not enouch credits to refuel!");
			} else player.consoleMessage("AutoRefuel Error: Station does not allow refueling!");
		}
	}
}