Page 1 of 1

[OXP] AutoFuel

Posted: Thu Mar 30, 2017 6:47 am
by byronarn
This tiny OXP (only 2 KB) fills your tank for you whenever you dock at a station, and deducts the cost from your account. If you do not have enough money to purchase the fuel, it gives you a message alerting you of the fact. It automatically does this whenever you dock with a station, so no need to buy any equipment.

The inspiration for this OXP came from the fact that there has been a few times that I have launched from a station having forgotten to buy fuel, and so have had to redock in order to buy the fuel. If there is anyone else who does this, here is the solution!

You can download the OXP using the download manager, or you can download it here.

Feel free to download it and test it out. Comments and suggestions are always welcome!

Re: [OXP] AutoFuel

Posted: Thu Mar 30, 2017 7:17 am
by phkb
Nice job! My only suggestion is a kind of ... well, anyway, I think you should call it AutoRefuel, so it's clear it's not a cheat. AutoFuel sounds a bit like you're going to get something for nothing.

Re: [OXP] AutoFuel

Posted: Thu Mar 30, 2017 9:27 am
by hoqllnq
... so the price of fuel seems to be 4Cr/1LY ...
In places that are not main-stations (Behemoths, Waystations, Navy bases, ...) prices are often higher than normal.
I believe that you can use Station.equipmentPriceFactor to determine how much higher.

Re: [OXP] AutoFuel

Posted: Thu Mar 30, 2017 10:13 am
by Norby
Nice idea, I plan to insert into Addons for Beginners collection when once arive into the package manager.

There is a way to disable fuel in stations, like in an abandoned rock hermit.
The check is in oolite.app/Resources/Scripts/oolite-conditions.js, you can do something similar:

Code: Select all

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)  {
		//ok to refuel
	}
}

Re: [OXP] AutoFuel

Posted: Thu Mar 30, 2017 7:39 pm
by byronarn
Norby wrote: Thu Mar 30, 2017 10:13 am
Nice idea, I plan to insert into Addons for Beginners collection when once arive into the package manager.
How do i go about putting this in the package manager? Also, i put it in the miscellaneous category. Is this the correct category, or should I put it elsewhere?
There is a way to disable fuel in stations, like in an abandoned rock hermit.
The check is in oolite.app/Resources/Scripts/oolite-conditions.js, you can do something similar:

Code: Select all

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)  {
		//ok to refuel
	}
}
I don't want to disable fuel in the stations. Imagine someone docked with a really low credit balance because they spent all their money on the last cargo load. I want them to still be able to buy fuel on the F3 screen once they sell their cargo.

Re: [OXP] AutoFuel

Posted: Thu Mar 30, 2017 8:22 pm
by Norby
byronarn wrote: Thu Mar 30, 2017 7:39 pm
How do i go about putting this in the package manager?
Easy way if you ask somebody to upload who already has rights. Otherwise ask access for yourself when go through the steps listed in The All-in-One Guide to OXZ Packaging and Distribution.

byronarn wrote: Thu Mar 30, 2017 7:39 pm
Also, i put it in the miscellaneous category. Is this the correct category, or should I put it elsewhere?
I think Mechanics is better category for this package. The category descriptions are in the old OXP List page.

byronarn wrote: Thu Mar 30, 2017 7:39 pm
I don't want to disable fuel in the stations.
I mean you give fuel in all stations regardless of it is a custom one in an oxp where the author willfully disabled it, like in a dockable ship or abandoned asteroid. I made the above code for you to check the property of stations where oxp authors can disable fuel access. This mean oolite-barred-equipment key contain EQ_FUEL within scriptInfo of a station in shipdata.plist .

Re: [OXP] AutoFuel

Posted: Thu Mar 30, 2017 9:53 pm
by byronarn
Norby wrote: Thu Mar 30, 2017 8:22 pm
byronarn wrote: Thu Mar 30, 2017 7:39 pm
I don't want to disable fuel in the stations.
I mean you give fuel in all stations regardless of it is a custom one in an oxp where the author willfully disabled it, like in a dockable ship or abandoned asteroid. I made the above code for you to check the property of stations where oxp authors can disable fuel access. This mean oolite-barred-equipment key contain EQ_FUEL within scriptInfo of a station in shipdata.plist .
Oh okay, i understand what you're saying now. I'll work on this either tonight or tomorrow. Thanks for the info!

Re: [OXP] AutoFuel

Posted: Sun Apr 02, 2017 7:13 pm
by byronarn
Norby wrote:
Nice idea, I plan to insert into Addons for Beginners collection when once arive into the package manager.

There is a way to disable fuel in stations, like in an abandoned rock hermit.
The check is in oolite.app/Resources/Scripts/oolite-conditions.js, you can do something similar:

Code: Select all

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)  {
		//ok to refuel
	}
}
phkb wrote: Thu Mar 30, 2017 7:17 am
Nice job! My only suggestion is a kind of ... well, anyway, I think you should call it AutoRefuel, so it's clear it's not a cheat. AutoFuel sounds a bit like you're going to get something for nothing.
I have updated the Original Post with Version 1.0 (the original version was 0.1). Your suggestions have been added and you have been credited in the README.txt file. Thank you! :-)

You can also download it now in the download manager! :-)

Re: [OXP] AutoFuel

Posted: Fri May 24, 2019 3:30 pm
by Cmdr Fleegman
hoqllnq wrote: Thu Mar 30, 2017 9:27 am
... so the price of fuel seems to be 4Cr/1LY ...
... prices are often higher than normal.
In that case I would also suggest checking with the user before filling up with (expensive) fuel - I'd probably choose to wait till I got to the main station.