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
}
}
}