Page 1 of 1

java script trouble ... SOLVED

Posted: Sat Feb 20, 2010 1:15 pm
by Lestradae
I'm not getting what I am doing wrong here, I have this in my hack of System redux script:

Code: Select all

system.legacy_addShipsAt('coriolis', 1, 'spp', [-8 0 -8]);
... and am getting that error message in the log:
[script.javaScript.exception.bracketAfterList]: ../AddOns/Oolite Extended V0.83.oxp/Scripts/SystemRedux.js, line 92: system.legacy_addShipsAt('coriolis', 1, 'spp', [-8 0 -8]);
The brackets are a problem? How do I have to write this? I do not understand this error, hope for help with it.

Posted: Sat Feb 20, 2010 1:22 pm
by Commander McLane
JS generally expects values seperated by commas, not spaces. Therefore [-8, 0, -8] will do.

..

Posted: Sat Feb 20, 2010 1:25 pm
by Lestradae
Thanks, good, that's simple.

..

Posted: Sat Feb 20, 2010 1:57 pm
by Lestradae
:(

Still not working ... though now the brackets work.

I modified the systemredux js to create up to four additional planets with stations and beacons - two inside the main planets' orbit and two outside.

The main planet has been shoved to about 30 planetary diametres outwards via farsun (triple normal distance).

My code looks like this:

Code: Select all

this.addPlanets = function()
{
        var sys_info = this.system_info[galaxyNumber * 256 + system.ID + 1] & (0xF0 >> (4 - this.max_planets));

        if (sys_info & 0x10) {
                system.addPlanet("planet1");
                system.legacy_addShipsAt('coriolis', 1, 'spp', [-8, 0, -8]);
                system.legacy_addShipsAt('planetarybuoy', 1, 'spp', [-8.1, 0, -8.1]);
        }
        if (sys_info & 0x20) {
                system.addPlanet("planet2");
                system.legacy_addShipsAt('dodecahedron', 1, 'spp', [16, 0, 16]);
                system.legacy_addShipsAt('planetarybuoy', 1, 'spp', [16.1, 0, 16.1]);
        }
        if (sys_info & 0x40) {
                system.addPlanet("planet3");
                system.legacy_addShipsAt('rockhermit', 1, 'spp', [-61, 0, 61]);
                system.legacy_addShipsAt('planetarybuoy', 1, 'spp', [-61.1, 0, 61.1]);
        }
        if (sys_info & 0x80) {
                system.addPlanet("planet4");
                system.legacy_addShipsAt('SIRF-YARD', 1, 'spp', [101, 0, -101]);
                system.legacy_addShipsAt('planetarybuoy', 1, 'spp', [101.1, 0, -101.1]);
        }
}
... but for some reason, it's not working.

What I changed from original system redux are the positions of the up to four additional planets, and added stations and a beacon to these new positions, too. Everything else I left the way it is.

Can somebody point out what might be going wrong here, while keeping in mind that my idea of js is rather limited?

Posted: Sat Feb 20, 2010 3:00 pm
by Kaks
It looks as though it should work... what does your latest.log say?

Posted: Sat Feb 20, 2010 3:08 pm
by Commander McLane
Also, it wouldn't be a too far-fetched idea for you to be a little more specific than "it's not working".

You know, there is a difference in "not working" between (1) the planets are all created, but in the wrong places, or (2) there are no planets created at all, or (3) the planets and stations are created, but the buoys are placed in the wrong direction, or (4)-(99) whatever.

It would be much easier to help if you would let us know what exactly is wrong.

Posted: Sat Feb 20, 2010 5:21 pm
by Eric Walch
Kaks wrote:
It looks as though it should work... what does your latest.log say?
I'm sure it works in the way the stations are added. The beacon is probably pointing to the location,

but, I am also sure they are not added near the intended planets because a different coordinate system is used. In redux is defined:

Code: Select all

	planet1 = {
		position = "pwm -4000000 500000 -200000";
		radius = 16000;
		orientation = "0.0 1.0 0.0 1.0";
		texture = "planet1.png";
		seed = "1 2 3 4 5 6";
		"polar_color_factor" = "0.0";
		"rotational_velocity" = "0.002";
		"percent_cloud" = "50.0";
	};
So the station should be added in that area. e.g.:
"pwm -4032000 500000 -200000"
This coordinates places it 32000 meter away from the planet in the x-direction. That is 2 planet radii, what is the standard distance for Oolite stations.

..

Posted: Sat Feb 20, 2010 6:22 pm
by Lestradae
Hi all,

After a few trials and errors I think I found the reason for things not working as intended.

Turns out that in the quest to make the sun and planets bigger & more distant, I overlooked some peculiarities so as the planet radius used as length scale in the "SPP" coordinate system also made my distances much larger, and that the source of my coordinate system "s", lying in the center of the sun, meant that "8 0 8" planetary radii from sun's center might well mean my innermost planet to reside inside the sun ...

Concerning the planets in planetinfo.plist, I did change their values so as to be close to the stations and planetary beacons.

After taking all of the above into consideration and experimenting a bit I soon saw my first additional planet with station and beacon roughly where they were planned to be.

Thanks everyone, it's appreciated! :)

Posted: Sat Feb 20, 2010 9:44 pm
by JazHaz
How far away from a release are you with this? Been hoping for a new system redux for some time, especially as the old one has been broken and unavailable for some time (in fact since before I joined the commOonity, and so have never had it on my install).

..

Posted: Sat Feb 20, 2010 10:02 pm
by Lestradae
JazHaz wrote:
How far away from a release are you with this?
I sadly have to say, quite far.

System Redux is not my oxp and I am developing this for my now rather personal Oolite version, the Oolite Extended meta-oxp. Yes I continue developing it, but it will probably have to come out as a game fork of Oolite - and I will have to ask a lot of people and hope that they can accept this at least as a game fork, and I will probably wait for the no-longer-mythical next stable release before attempting to fork and even start asking.

But, what I can offer in more short term, is that when I have finished tweaking this solar system stuff until it works, that I publish my script hacks here, then others can do the same if they want to.

If interested in my personal OE hack, drop me a PM. And keep in mind this can't be distributed until all licensing issues are resolved.

Regards,

L

Posted: Sun Feb 21, 2010 1:35 am
by Kaks
JazHaz, I'm surprised system redux is broken for you. It seems to be working ok in 1.73.4 & in trunk... (ok, if you were to run trunk you'd get quite a few deprecation warnings, but it still works here...)

Could you elaborate on what's broken?

Posted: Sun Feb 21, 2010 1:57 am
by JazHaz
Kaks wrote:
JazHaz, I'm surprised system redux is broken for you. It seems to be working ok in 1.73.4 & in trunk... (ok, if you were to run trunk you'd get quite a few deprecation warnings, but it still works here...)
LOL! I was thinking of another OXP! :)