Fuel Collector Release 0.06

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: winston, another_commander

User avatar
Frame
---- E L I T E ----
---- E L I T E ----
Posts: 1477
Joined: Fri Mar 30, 2007 8:32 am
Location: Witchspace

Post by Frame »

The code for building a list of planets and moons looks like this

Moons are differentiated between by radius..

Code: Select all

this.buildplanetlist = function()
{ //function very much in developing stages.. 	

	if(!system.sun)
	return;	//sanity check.. no distance measurements to sun, or else we get errors..
		//number planets by posistion in the array.. execpt main planet ofcourse
	
	log("Fuel Collector","number of Globes is "+system.planets.length)
	if(system.planets.length == 1) //nutter might add planets in witchspace
	{
		this.MainPlanetName = system.name //+" 1" //used +1 one for testing..
		return //return from here, there is no more planets in the system
	}
	
	
	//this.temp = new Array();
	this.planetlist = new Array();
	this.moonlist = new Array();	
	
	for(var i = 0;i<=system.planets.length-1;i++)
	{
		
						   
		if(system.planets[i].radius <10000) //presume moon if less than 1000
		{
			this.moonlist.push(system.planets[i])			
		}
			
		else
		{
			this.planetlist.push(system.planets[i])
			
		}
		
	}
	
	this.noofplanets = this.planetlist.length
	this.noofmoons = this.moonlist.length
	
	//log("Fuel Collector","planets n is "+this.noofplanets)
	//log("Fuel Collector","moons n is "+this.noofmoons)
	
	//we dont need a check for planets,its greater than 0
	
	//build a distancelist
	for(var i = 0;i<this.noofplanets;i++)
	{
		this.planetlist[i].name = System.name +" "+(i+1)
		this.planetlist[i].moons = 0;
	}
	for(i = 0;i<this.noofplanets;i++)
	{
		//log("Fuel Collector","name:"+this.planetlist[i].name)
	}
	
	if(this.moonlist)
	{		
		for(i=0;i<this.noofmoons;i++)
		{
			let motherplanet = 0
			let cr = this.moonlist[i].position.distanceTo(planetlist[0])
			
			for(var al=1;al<this.noofplanets;al++)
			{				
				if(cr>this.moonlist[i].position.distanceTo(planetlist[al]))
				{
					
					cr = this.moonlist[i].position.distanceTo(planetlist[al])
					this.planetlist[al].moons;
					motherplanet = al
				}				
			}
			this.planetlist[motherplanet].moons ++;
			this.moonlist[i].name = this.planetlist[motherplanet].name +"´s moon "+this.planetlist[motherplanet].moons
		}
	}	
}
Bounty Scanner
Number 935
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Post by Thargoid »

Hmm, I thought I had 0.3. Obviously I downloaded it and didn't install it, or miscopied things across when I went from 1.71.2 onto 1.72.

As a passing comment/request it makes life a little easier if you include a version number in the folder name of your OXP too, e.g. call it FuelCollector-0.3.oxp or something rather than just each version being called FuelCollector.oxp (ditto BountyScanner too).

I'll update things later on and see if the problem goes away.

PS you can perhaps better differentiate between planets and moons by whether they have an atmosphere or not (<planet entity>.hasAtmosphere = true or false).
User avatar
Frame
---- E L I T E ----
---- E L I T E ----
Posts: 1477
Joined: Fri Mar 30, 2007 8:32 am
Location: Witchspace

Post by Frame »

I´ll put the version numbers in for next releases,however it opens for having multiple versions of the same OXP installed by mistake... cons and pros, there is for everything apparently..

Thanks for the reports, they are much appreciated.

Cheers Frame...
Bounty Scanner
Number 935
User avatar
Frame
---- E L I T E ----
---- E L I T E ----
Posts: 1477
Joined: Fri Mar 30, 2007 8:32 am
Location: Witchspace

Post by Frame »

Thargoid wrote:

PS you can perhaps better differentiate between planets and moons by whether they have an atmosphere or not (<planet entity>.hasAtmosphere = true or false).
Good thinking... i´m going to check if all planets have atmosphere , if yes then that is going to be the check instead of radius....

Thanks again

Frame

.oO{ I really would like my spell checker to be able to plug into explorer... ;-) }
Bounty Scanner
Number 935
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Post by Thargoid »

If they don't please let me know, as that's the route I'm using to differentiate between them in PlanetFall ;)
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Post by Commander McLane »

Frame wrote:
I´ll put the version numbers in for next releases,however it opens for having multiple versions of the same OXP installed by mistake... cons and pros, there is for everything apparently..
No problem, if you put the version number only in the containing folder. So the OXP would still be called just 'FuelCollector.oxp', but it would come, alongside its readMe, in the folder 'FuelCollector 0.4'. The user would open this download folder, and drop the OXP into his Addons, where it still would automatically overwrite the old version.
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Post by Thargoid »

Not sure I'd quite agree there, as only files within the thing that have the same name will get over-written. There is some potential if filenames get changed that some legacy files end up laying around.

Personally I find it easier to install OXPs then scan down the folder list to see if there's any duplicate OXPs with different versions and then have a tidy-up as needed, but as Frame said, it's all pro's and con's, and personal taste...

Anyway I updated to v0.3 last night, and things are ok now (at least once I editted the script to change player.<command> to player.ship.<command>, I presume that's why the upcoming v0.4 is due?).
User avatar
Frame
---- E L I T E ----
---- E L I T E ----
Posts: 1477
Joined: Fri Mar 30, 2007 8:32 am
Location: Witchspace

Post by Frame »

New Version

version 0.05, solves a lot read top post for more

Compatible with 1.71, 1.72, 1.72.1

download here

http://www.box.net/shared/clvme0ze8g
Bounty Scanner
Number 935
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Post by Commander McLane »

Hi Frame!

The way your script checks for the fuel collector is buggy. I get messages like "Fuel Collector activated" or "Fuel Collector deactivated" even with old save games that do not have a fuel collector.

For instance a check like this is problematic:

Code: Select all

if(!this.theplayer.hasEquipment("EQ_FRAME_FUEL_COLLECTOR") && !this.theplayer.hasEquipment("EQ_FUEL_SCOOPS"))
It means that the code below will only be executed if neither of the items is present. (If the player doesn't have a fuel collector AND the player doesn't have fuel scoops.) What if he has fuel scoops, but no fuel collector? Or if he has a fuel collector, but no scoops? Then the code below will not be executed. Thus having only one of the items is treated by your code equally to having both of them.

There are a couple of checks like this. Please have a look at them again and check if they really reflect what you want them to do.

Other than that: I wouldn't know anymore how to live without the Fuel Collector! :D

PS: There are a couple of orthographic inconsistencies and typos as well. For instance, sometimes in the commsMessages and consoleMessages you capitalize 'Fuel Collector', and sometimes not. Oh, and it's 'too close to planet'.
User avatar
Frame
---- E L I T E ----
---- E L I T E ----
Posts: 1477
Joined: Fri Mar 30, 2007 8:32 am
Location: Witchspace

Post by Frame »

Commander McLane wrote:
Hi Frame!

The way your script checks for the fuel collector is buggy. I get messages like "Fuel Collector activated" or "Fuel Collector deactivated" even with old save games that do not have a fuel collector.

For instance a check like this is problematic:

Code: Select all

if(!this.theplayer.hasEquipment("EQ_FRAME_FUEL_COLLECTOR") && !this.theplayer.hasEquipment("EQ_FUEL_SCOOPS"))
It means that the code below will only be executed if neither of the items is present. (If the player doesn't have a fuel collector AND the player doesn't have fuel scoops.) What if he has fuel scoops, but no fuel collector? Or if he has a fuel collector, but no scoops? Then the code below will not be executed. Thus having only one of the items is treated by your code equally to having both of them.

There are a couple of checks like this. Please have a look at them again and check if they really reflect what you want them to do.

Other than that: I wouldn't know anymore how to live without the Fuel Collector! :D

PS: There are a couple of orthographic inconsistencies and typos as well. For instance, sometimes in the commsMessages and consoleMessages you capitalize 'Fuel Collector', and sometimes not. Oh, and it's 'too close to planet'.
Thanks for the heads up on the logical department, I'm not sure what i was thinking when I wrote the code in question.

I corrected the orthographic inconsistencies and typos.. And will release a new version shortly when I have rewritten the derelict role check function..

Cheers Frame...
Bounty Scanner
Number 935
User avatar
ClymAngus
---- E L I T E ----
---- E L I T E ----
Posts: 2514
Joined: Tue Jul 08, 2008 12:31 am
Location: London England
Contact:

Post by ClymAngus »

In the mean time I'm downloading this baby and giving it a road test. Thank you for your due diligence Mr Frame!
User avatar
Frame
---- E L I T E ----
---- E L I T E ----
Posts: 1477
Joined: Fri Mar 30, 2007 8:32 am
Location: Witchspace

Post by Frame »

Edited again: new version:
Warning Next Version will be incompatible with Oolite versions prior to 1.72 unless some very serious bug is found..

anyway Version 0.06 is found here...

http://www.box.net/shared/6r8hqn6zas
---------
fixes...

fixed some bugs in regard to damaged Equipement, also fixed a yet undiscovered bug regarding hacking reconnectivity. Timers behaves differently now i presume.

Added DeepSpaceDredger Derelict ships to the list of possible Fuel extraction targets.

Added an array with legit roles that can be modified by the player if he wishes more ships from which there can be extracted fuel... Note that it does not make sense to try to extract fuel from a vessel that always has 0 ly of fuel onboard

Orthographic´s in regard to text should now be consistent
typo in messages corrected


Compatible with 1.70.x, 1.71.x, 1.72.1 + 1.72.2
Bounty Scanner
Number 935
Switeck
---- E L I T E ----
---- E L I T E ----
Posts: 2411
Joined: Mon May 31, 2010 11:11 pm

Post by Switeck »

While this still works with v1.74.2 ...the warning messages logger tosses up certainly crowds out other messages.
Any chance for a new version?
Zireael
---- E L I T E ----
---- E L I T E ----
Posts: 1396
Joined: Tue Nov 09, 2010 1:44 pm

Post by Zireael »

I was going to write the same. My latest log was chock-full of deprecation errors caused by the Fuel Collector. Any chance of getting it updated?
pkin
Mostly Harmless
Mostly Harmless
Posts: 2
Joined: Fri Nov 12, 2010 9:51 am

Post by pkin »

Hi

I'm not sure the original owner of thisOXP is still around. I think I have the errors fixed and I'm testing at the moment.
Post Reply