Help with a Javascript exception
Posted: Wed Mar 23, 2016 6:34 pm
I'm trying to hack an existing script, namely script.js from extra planets. My goal is to add a parameter for oxpConfig that allows the user to have the moons farther away from the planet, because they are too often unbelievably close to the planet in my opinion.
I've added three lines:
In the logs, I get the exception:
I've added three lines:
Code: Select all
this.oxpcSettings = {
Info: {Name:"System Redux",EarlyCall:true,EarlySet:true,Notify:true,
InfoE:"Exclude systems. If set SystemRedux is bypassed in these systems.\nChanges may require restart / reload."
},
SInt0: {Name:"max_moons",Def:0x3,Max:0x4,Desc:"Max number of moons"},
SInt1: {Name:"max_planets",Def:0x4,Max:0x4,Desc:"Max number of planets"},
SInt2: {Name:"orbit_mul", Def:0x1, Max:0x4, Desc:"Base moon orbits"}, /* <---- THIS ONE */
EInt0: {Name:"exSys",Def:0x0,Max:0x7,Desc:["Lave","Diso","Tianve"]}
};
Code: Select all
this.startUp = function() {
//4 moons are currently defined in the planetdata.
this.max_moons = 3;//max number of moons around a planet. There's no limit here.
this.max_planets = 4;//maximum number of extra planets per system. extra planets might have moon. There's no limit here.
this.extraPlanetMoonsProbability = 0.1;//the probablitity for an extra planet to have moons.
this.orbit_mul=1; // Scale for orbit radius (moons) // <----- THIS ONE
this.exSys = 0;//for oxp config
this.excl = [[],[],[],[],[],[],[],[]];//excluded systems
this.systemDone = false;//flag so that system gets populated only once
this.runOnce = true;//controls the sorting of the pools
}
Code: Select all
function addMoons(planet_position, planet_radius, seed) {
//number of moon sizes defined in planetinfo.plist
var moonSizes = 4;
//number of moons to be added. extremes have probability weight of 0.5, others 1.
var numberOfMoons = Math.round(system.scrambledPseudoRandomNumber(seed) * max_moons);
//orbits. lowest is 2.5 * planet radius. station is usually at 2 * planet radius.
var moonOrbits = new Array();
for (var i = 0; i < max_moons; i++) moonOrbits.push(i);
var baseMoonOrbit = planet_radius * (2.5 * this.orbit_mul); // <----- THIS ONE (well, I only changed that one)
var moonOrbitDifference = 30000;
I of course don't have a clue about what I did wrong. The new setting appears correctly in OXP config, except it shows a bad default value; but I believe it is because it's not present in the saved parameters yet.19:18:28.208 [script.javaScript.exception.unexpectedType]: ***** JavaScript exception (System Redux 0.7): TypeError: this.orbit_mul is undefined