Page 1 of 3

System Redux

Posted: Sun May 25, 2008 8:43 am
by krombart
Running System Redux I get those error messages (I works anyway) Would be cool if that could be fixed.

2008-05-25 10:37:03.670 oolite[5402] [script.javaScript.warning.162]: ----- JavaScript warning: reference to undefined property system_info[galaxyNumber * 256 + system.ID]
2008-05-25 10:37:03.670 oolite[5402] [script.javaScript.warning.162]: /home/ebw/.Oolite/AddOns/System_Redux.oxp/Config/script.js, line 53.
2008-05-25 10:37:03.670 oolite[5402] [script.javaScript.warning.162]: ----- JavaScript warning: reference to undefined property system_info[galaxyNumber * 256 + system.ID]
2008-05-25 10:37:03.671 oolite[5402] [script.javaScript.warning.162]: /home/ebw/.Oolite/AddOns/System_Redux.oxp/Config/script.js, line 71.
2008-05-25 10:37:03.671 oolite[5402] [script.javaScript.warning.162]: ----- JavaScript warning: reference to undefined property system_info[galaxyNumber * 256 + system.ID]
2008-05-25 10:37:03.671 oolite[5402] [script.javaScript.warning.162]: /home/ebw/.Oolite/AddOns/System_Redux.oxp/Config/script.js, line 89.
2008-05-25 10:37:22.835 oolite[5402] [script.javaScript.warning.162]: ----- JavaScript warning: reference to undefined property system_info[galaxyNumber * 256 + system.ID]
2008-05-25 10:37:22.836 oolite[5402] [script.javaScript.warning.162]: /home/ebw/.Oolite/AddOns/System_Redux.oxp/Config/script.js, line 53.
2008-05-25 10:37:22.836 oolite[5402] [script.javaScript.warning.162]: ----- JavaScript warning: reference to undefined property system_info[galaxyNumber * 256 + system.ID]
2008-05-25 10:37:22.836 oolite[5402] [script.javaScript.warning.162]: /home/ebw/.Oolite/AddOns/System_Redux.oxp/Config/script.js, line 71.
2008-05-25 10:37:22.836 oolite[5402] [script.javaScript.warning.162]: ----- JavaScript warning: reference to undefined property system_info[galaxyNumber * 256 + system.ID]
2008-05-25 10:37:22.837 oolite[5402] [script.javaScript.warning.162]: /home/ebw/.Oolite/AddOns/System_Redux.oxp/Config/script.js, line 89.

Posted: Sun May 25, 2008 10:22 am
by krombart
I played a little bit and found that the code

this.addMoons = function()
{
LogWithClass("script.javaScript.warning.162","Trying to access system_info " + galaxyNumber * 256 + system.ID);
LogWithClass("script.javaScript.warning.162","system.ID " + system.ID);
LogWithClass("script.javaScript.warning.162","galaxyNumber " + galaxyNumber);
}

produced the output

2008-05-25 12:20:58.852 oolite[6050] [script.javaScript.warning.206]: ----- JavaScript warning: LogWithClass() is deprecated, use log() instead.
2008-05-25 12:20:58.853 oolite[6050] [script.javaScript.warning.162]: Trying to access system_info 593927
2008-05-25 12:20:58.853 oolite[6050] [script.javaScript.warning.206]: ----- JavaScript warning: LogWithClass() is deprecated, use log() instead.
2008-05-25 12:20:58.853 oolite[6050] [script.javaScript.warning.162]: system.ID 7
2008-05-25 12:20:58.853 oolite[6050] [script.javaScript.warning.206]: ----- JavaScript warning: LogWithClass() is deprecated, use log() instead.
2008-05-25 12:20:58.854 oolite[6050] [script.javaScript.warning.162]: galaxyNumber 232

which seems a little bit absurd. galaxyNumber is definitely buggy.

BTW: How Do I do correct logging?

Posted: Sun May 25, 2008 11:43 am
by krombart
This occurred on oolite 1.72

Posted: Sun May 25, 2008 12:46 pm
by JensAyton
BTW: How Do I do correct logging?
Instead of:

Code: Select all

LogWithClass("script.javaScript.warning.162","galaxyNumber " + galaxyNumber);
write:

Code: Select all

log("galaxyNumber " + galaxyNumber);
// or
log("myTest.galaxyNumber", "galaxyNumber: " + galaxyNumber);
I can’t do anything about the bad galaxyNumber values at the moment since I’m not at home.

Posted: Mon May 26, 2008 7:50 am
by JensAyton
I can’t recreate this under either Mac OS X or Linux. Exactly where are you calling your test function?

Posted: Mon May 26, 2008 10:06 am
by krombart
I simply changed the addMoon function from script.js from SystemRedux.

Posted: Mon May 26, 2008 10:45 am
by CaptKev
krombart wrote:
I simply changed the addMoon function from script.js from SystemRedux.
Why did you change the AddMoon function?

I've been using System Redux beta ever since JavaScript was added and have never experienced the galaxyNumber problem. :?

Posted: Mon May 26, 2008 10:56 am
by Commander McLane
I've come across something else: If I misjump with System_Redux installed, the JS-console shows the following entries (I don't understand the reference to strict mode, I don't play in strict mode; System_Redux wouldn't do anything in strict mode, would it?):

Code: Select all

Warning (strict mode): reference to undefined property system_info[galaxyNumber * 256 + system.ID]
    Active script: "System Redux 1.1 beta" 1.1
    script.js, line 63:
    	var sys_info = system_info[galaxyNumber * 256 + system.ID] & (0x0F >> (4 - this.max_moons));
Warning (strict mode): reference to undefined property system_info[galaxyNumber * 256 + system.ID]
    Active script: "System Redux 1.1 beta" 1.1
    script.js, line 81:
    	var sys_info = system_info[galaxyNumber * 256 + system.ID] & (0xF0 >> (4 - this.max_planets));
Exception: TypeError: system.mainPlanet has no properties
    Active script: "System Redux 1.1 beta" 1.1
    script.js, line 101:
    		system.mainPlanet.setTexture('home_planet' + (((system_info[galaxyNumber * 256 + system.ID] & 0xF000) >> 12) + 1) + '.png');
I think it basically comes down to the fact that System_Redux isn't meant for planetNumber -1. So perhaps you should add another condition that prevents the script from being executed if in interstellar space.

EDIT: corrected "interplanetary" to "interstellar". What was I thinking when I wrote this??? Thanks, Frame!

Posted: Mon May 26, 2008 12:37 pm
by Frame
Commander McLane wrote:
being executed if in interplanetary space.
Thats interstellar space ^^.

interplanetary is between planets, further out between stars that is interstellar.

just so you dont confuse Krombart or CaptKev

Posted: Mon May 26, 2008 1:40 pm
by CaptKev
Commander McLane wrote:
I've come across something else: If I misjump with System_Redux installed, the JS-console shows the following entries (I don't understand the reference to strict mode, I don't play in strict mode; System_Redux wouldn't do anything in strict mode, would it?)
There's a strict mode? :roll:

Regarding interstellar space, I'll add 1 to the planetNumber and an extra zero as the first element for each galaxy in the array.
Frame wrote:
just so you dont confuse Krombart or CaptKev
It doesn't take much :wink:

Posted: Mon May 26, 2008 5:41 pm
by JensAyton
Commander McLane wrote:
I've come across something else: If I misjump with System_Redux installed, the JS-console shows the following entries (I don't understand the reference to strict mode, I don't play in strict mode; System_Redux wouldn't do anything in strict mode, would it?
That’s the JavaScript parser’s strict mode. Oolite always sets SpiderMonkey to strict mode because it catches more potential bugs.

In this case, it’s an out-of-range array index. Your diagnosis is correct.

Posted: Tue May 27, 2008 7:25 am
by Commander McLane
CaptKev wrote:
Regarding interstellar space, I'll add 1 to the planetNumber and an extra zero as the first element for each galaxy in the array.
Wouldn't it be cleaner just to add an extra condition that prevents System_Redux from doing anything in interstellar space? In legacy scripting that would be a

Code: Select all

conditions = (planet_number greaterthan -1);
do =(
     {
      Rest of your code
     }
);
as the outer function. Don't know the JS-syntax.

Posted: Tue May 27, 2008 9:08 am
by CaptKev

Code: Select all

/*    001     002     003     004     005     006     007     008     009     010
this.system_info = new Array(
	0, 0x21A5, 0x2100, 0x1118, 0x8181, 0x3168, 0xD110, 0x2105, 0x0735, 0xC103, 0x7110...
	0, 0xC1A0, 0x2138, 0x0148, 0x1108, 0x1102, 0x6108, 0x11A0, 0xA1A0, 0x71F3, 0x4101...
	0, 0x2100, 0x7161, 0x7144, 0x6109, 0x0194, 0x81A2, 0x2144, 0xB180, 0x2199, 0x2153...
	0, 0x5180, 0x5103, 0x2142, 0x4122, 0x2116, 0x31C0, 0x3102, 0xC193, 0x0108, 0x1120...
	0, 0x0161, 0x212D, 0x8120, 0xA108, 0xC144, 0xA181, 0x4105, 0xD140, 0x2124, 0x9100...
	0, 0x1130, 0xF108, 0x5100, 0x0142, 0x31C0, 0x1104, 0x5104, 0xE100, 0x8141, 0x5102...
	0, 0xE173, 0x3150, 0x2148, 0x91B8, 0x1102, 0x0111, 0x6180, 0xF108, 0x9108, 0x1113...
	0, 0x4116, 0xD102, 0xA125, 0x5180, 0x0111, 0x6180, 0xF108, 0x1120, 0xA100, 0x1101...
);

this.homePlanet = function()
{
	if (!this.system_info[galaxyNumber * 256 + system.ID+1]) return;

	system.mainPlanet.setTexture('home_planet' + (((this.system_info[galaxyNumber * 256 + system.ID+1] & 0xF000) >> 12) + 1) + '.png');
}
This way allows for the planet texture to be turned off for particular system, which might be useful in the future.

Re: System Redux

Posted: Sat Jul 16, 2011 7:31 pm
by Svengali
With CaptKevs permission a update to v1.2.1 is available.

-> http://www.box.net/shared/bdzr8ornxmjcyhc8r65j (7.6 KB)

The zip contains only the new script, planetinfo.plist and readme for the update.

Re: System Redux

Posted: Fri Dec 02, 2011 7:42 pm
by Okti

Code: Select all

this.changeSystems = function(ar)
{
	if(ar){
		for(var i=0;i<ar.length;i++){
			for(var j=0;j<ar[i].length;j++){
				system_info[(i*256)+1+ar[i][j]] = 0;
			}
		}
	} else this.system_info = this.org_system_info;
	return;
}
I think there must be a this. before system_info otherwise it does not seem to work.

The code must be as follows

Code: Select all

this.changeSystems = function(ar)
{
	if(ar){
		for(var i=0;i<ar.length;i++){
			for(var j=0;j<ar[i].length;j++){
				this.system_info[(i*256)+1+ar[i][j]] = 0;
			}
		}
	} else this.system_info = this.org_system_info;
	return;
}