JS system.planets, reconstructs on every launch event.
Posted: Sat Jan 10, 2009 6:08 pm
I have been moving planets around a lot lately...
however, I found that every time you launch then system.planets is rearranged.
example... i load a commander... no planets have been added
I write system.planets in the debug console and I get this
I now launch with system redux installed, that in this particular system adds 3 moons, and i add one Planet in my own script..
So far so good, everything is added in the correct order of things..
I then enter my jumpgate, and my script moves planets and moons around, so that everything stays inside the stable precision coordinate system..
then on the other side of the jumpgate, i again type system.planets
and i get this...
As you can see, everything has been rearrenged when i launched from the jumpgate, which is like a station... that however launches you 1 second after docking...
The only possible reason for this is that, the code recontructs system.planets on every launch event... and when planets have been moved around, these are not any longer in the original order. this is cosmetics, but not logical. That elements of an array will get a new place in the array, according to some set distance measurement to either the sun, or the witch point...
I find it a bit wasted CPU time,that the code reconstruct system.planets every time the player is launched, so a few cycles could maybe be saved here...
Of course with my limited insight to the scripting engine, something like this may be needed for some to me unimaginable reason...
There might be other arrays that are reconstructed on every launch event, like system.allShips, all though I have not tested that yet, but from a scripters point of view, I think at least system.planets order, should stay static, and of course expand by 1 every time a new planet/moon is added, and not rearrange its order at any time.
Luckly i had build my own array, and set that to the system.planets array, on the very first launch, and its order stays static. imagine the trouble I would have had with an array, that had a dynamic order...
Cheers Frame....
however, I found that every time you launch then system.planets is rearranged.
example... i load a commander... no planets have been added
I write system.planets in the debug console and I get this
Code: Select all
[Planet ID: 143 position: (0, 0, 340600) type: PLANET_TYPE_GREEN radius: 34.060km]
Code: Select all
[Planet ID: 143 position: (0, 0, 340600) type: PLANET_TYPE_GREEN radius: 34.060km],[Planet ID: 193 position: (23511.5, -97614.9, 406344) type: PLANET_TYPE_GREEN radius: 9.000km],[Planet ID: 192 position: (-64386.9, 52011, 270741) type: PLANET_TYPE_GREEN radius: 7.000km],[Planet ID: 194 position: (65069.1, 9371.3, 244347) type: PLANET_TYPE_GREEN radius: 8.000km],[Planet ID: 195 position: (0, 0, -4.91e+007) type: PLANET_TYPE_GREEN radius: 90.000km]
I then enter my jumpgate, and my script moves planets and moons around, so that everything stays inside the stable precision coordinate system..
then on the other side of the jumpgate, i again type system.planets
and i get this...
Code: Select all
[Planet ID: 195 position: (0, 0, 900000) type: PLANET_TYPE_GREEN radius: 90.000km],[Planet ID: 194 position: (65069.1, 9371.3, 5.02443e+007) type: PLANET_TYPE_GREEN radius: 8.000km],[Planet ID: 192 position: (-64386.9, 52011, 5.02707e+007) type: PLANET_TYPE_GREEN radius: 7.000km],[Planet ID: 143 position: (0, 0, 5.03406e+007) type: PLANET_TYPE_GREEN radius: 34.060km],[Planet ID: 193 position: (23511.5, -97614.9, 5.04063e+007) type: PLANET_TYPE_GREEN radius: 9.000km]
The only possible reason for this is that, the code recontructs system.planets on every launch event... and when planets have been moved around, these are not any longer in the original order. this is cosmetics, but not logical. That elements of an array will get a new place in the array, according to some set distance measurement to either the sun, or the witch point...
I find it a bit wasted CPU time,that the code reconstruct system.planets every time the player is launched, so a few cycles could maybe be saved here...
Of course with my limited insight to the scripting engine, something like this may be needed for some to me unimaginable reason...
There might be other arrays that are reconstructed on every launch event, like system.allShips, all though I have not tested that yet, but from a scripters point of view, I think at least system.planets order, should stay static, and of course expand by 1 every time a new planet/moon is added, and not rearrange its order at any time.
Luckly i had build my own array, and set that to the system.planets array, on the very first launch, and its order stays static. imagine the trouble I would have had with an array, that had a dynamic order...
Cheers Frame....