java script trouble ... SOLVED

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

Moderators: winston, another_commander

Post Reply
User avatar
Lestradae
---- E L I T E ----
---- E L I T E ----
Posts: 3095
Joined: Tue Apr 17, 2007 10:30 pm
Location: Vienna, Austria

java script trouble ... SOLVED

Post 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.
Last edited by Lestradae on Sat Feb 20, 2010 6:22 pm, edited 1 time in total.
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 »

JS generally expects values seperated by commas, not spaces. Therefore [-8, 0, -8] will do.
User avatar
Lestradae
---- E L I T E ----
---- E L I T E ----
Posts: 3095
Joined: Tue Apr 17, 2007 10:30 pm
Location: Vienna, Austria

..

Post by Lestradae »

Thanks, good, that's simple.
User avatar
Lestradae
---- E L I T E ----
---- E L I T E ----
Posts: 3095
Joined: Tue Apr 17, 2007 10:30 pm
Location: Vienna, Austria

..

Post 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?
User avatar
Kaks
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 3009
Joined: Mon Jan 21, 2008 11:41 pm
Location: The Big Smoke

Post by Kaks »

It looks as though it should work... what does your latest.log say?
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
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 »

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.
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Post 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.
User avatar
Lestradae
---- E L I T E ----
---- E L I T E ----
Posts: 3095
Joined: Tue Apr 17, 2007 10:30 pm
Location: Vienna, Austria

..

Post 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! :)
User avatar
JazHaz
---- E L I T E ----
---- E L I T E ----
Posts: 2991
Joined: Tue Sep 22, 2009 11:07 am
Location: Enfield, Middlesex
Contact:

Post 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).
JazHaz

Gimi wrote:
drew wrote:
£4,500 though! :shock: <Faints>
Cheers,
Drew.
Maybe you could start a Kickstarter Campaign to found your £4500 pledge. 8)
Thanks to Gimi, I got an eBook in my inbox tonight (31st May 2014 - Release of Elite Reclamation)!
User avatar
Lestradae
---- E L I T E ----
---- E L I T E ----
Posts: 3095
Joined: Tue Apr 17, 2007 10:30 pm
Location: Vienna, Austria

..

Post 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
User avatar
Kaks
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 3009
Joined: Mon Jan 21, 2008 11:41 pm
Location: The Big Smoke

Post 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?
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
User avatar
JazHaz
---- E L I T E ----
---- E L I T E ----
Posts: 2991
Joined: Tue Sep 22, 2009 11:07 am
Location: Enfield, Middlesex
Contact:

Post 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! :)
Last edited by JazHaz on Sun Feb 21, 2010 2:01 am, edited 1 time in total.
JazHaz

Gimi wrote:
drew wrote:
£4,500 though! :shock: <Faints>
Cheers,
Drew.
Maybe you could start a Kickstarter Campaign to found your £4500 pledge. 8)
Thanks to Gimi, I got an eBook in my inbox tonight (31st May 2014 - Release of Elite Reclamation)!
Post Reply