Page 68 of 115

Re: Scripters cove

Posted: Sun Mar 17, 2013 11:14 am
by Rorschachhamster
Thanks!
So, now my freighttrain has a 1 in 10 Chance to fly to the main station... :D

Re: Scripters cove

Posted: Sun Mar 17, 2013 11:38 am
by Eric Walch
cim wrote:
Rorschachhamster wrote:
Does "setTargetToRandomStation" choose the main station as well?
Only if there are no other non-carrier dockables in the system range, which is generally rare.
I corrected that for you. :wink:
Yes, the random station was to let ships select an other station than the mainStation. Originally introduced to let pirates dock at non-mainStations to sell their loot. The main station is now only an option if no other is found in range. When you want to include the main station with higher probability, you must indeed use the "rollD: xx" command.

Re: Scripters cove

Posted: Tue May 14, 2013 5:33 am
by spara
I have a question about concurrency in javascript. In station validator I have a public function that is meant to be called by station spawn scripts. In that function I do a for loop to search items from an array and possibly manipulate that array if that item is found. In result the arrays length changes. Is there a concurrency issue here? Is that function being run simultaneously by the spawn scripts?

Re: Scripters cove

Posted: Tue May 14, 2013 6:24 am
by cim
spara wrote:
Is that function being run simultaneously by the spawn scripts?
The Oolite world simulation code is single-threaded, so no. Only one script will ever be running at any one time, and it will completely finish and return from whatever event handler set it going before any other event handlers run.

Re: Scripters cove

Posted: Tue May 14, 2013 6:32 am
by JensAyton
If concurrency is ever added to Oolite scripting, it should be something similar to WebSockets Web Workers – no shared mutable state.

Re: Scripters cove

Posted: Tue May 14, 2013 7:50 am
by spara
Thanks, that simplifies things quite a lot. I've been lately programming NXT robots with my students and my head is spinning with concurrency issues :).

Re: Scripters cove

Posted: Mon May 27, 2013 2:43 pm
by spara
Been pondering the station_validator oxp a bit. What would happen if I extend it to stop the native stations from spawning?

Scenarios:

1. Coriolis (current main station) is destroyed. What will happen, if the next time visiting the system, that station is removed from existence? What will break? Does some other station just be the "main station?" Is it possible to save at such a substitute station? Asteroid storm oxp seems to remove every station from the system, including the current main station. Is that to overcome some problem?

2. Hermit is destroyed. What will happen and what will break, if it is removed from the existence the next time it is spawned?

Re: Scripters cove

Posted: Mon May 27, 2013 3:39 pm
by Wildeblood
spara wrote:
Coriolis (current main station) is destroyed. What will happen, if the next time visiting the system, that station is removed from existence? What will break?
Not much.
spara wrote:
Does some other station just be the "main station?"
Yes.
spara wrote:
Is it possible to save at such a substitute station?
Yes.

It's also possible to specify any station role in the normal main station position, using e.g.:-

system.info.station = "SothisTC"
spara wrote:
Hermit is destroyed. What will happen and what will break, if it is removed from the existence the next time it is spawned?
Hermits are spawned as "rock clusters" - the rock hermit along with some nearby asteroids and a mining ship. (Or several ships?) If you remove the hermit, you probably ought to remove everything in scanner range of it, too.

Re: Scripters cove

Posted: Mon May 27, 2013 5:58 pm
by spara
Thanks Wildeblood. That clears up things.

Re: Scripters cove

Posted: Thu Jun 06, 2013 11:04 am
by Commander McLane
Wildeblood wrote:
spara wrote:
Does some other station just be the "main station?"
Yes.
spara wrote:
Is it possible to save at such a substitute station?
Yes.
To specify a little:

Once the main station gets destroyed, Oolite instantly elevates the closest dockable entity it can find to main station status (this includes giving it save-load capability). In case there is no other dockable entity in the whole system (which is quite likely in the "vanilla" setting, where Rock Hermits are the only other dockables, and lots of systems don't have Rock Hermits; but becomes less likely, the more secondary-station-adding OXPs the player installs; however, the new main station could be at the other end of the system if there is no closer dockable), there will be no main station (and therefore no load-save/market/equipment/etc. facilities) in the system, which may not be expected by scripts. Therefore there is a possibility that something will break. (This possibility is the reason why main stations are deliberately indestructible by weapons during normal game play. The capability of destroying/removing a main station by script—which is the only way to destroy/remove one—is sort of a hack, and should be used with caution.)

Note that the closest dockable entity does not need to be a station. It can also be a carrier (Behemoth, Dredger, even Thargoid Carrier), if that just happens to be closer to the removed main station than any other dockable. This may not be a wanted effect, but cannot be prevented, except by removing the carrier as well, which will elevate the dockable entity closest to its last position to main station status. And so forth. (Note: this is for instance the reason why Thargoid Carriers never attack main stations, but only secondary stations.)

Re: Scripters cove

Posted: Thu Jun 06, 2013 11:10 am
by Cody
Commander McLane wrote:
.. and lots of systems don't have Rock Hermits;
All systems have at least one rock hermit now (I think).

Re: Scripters cove

Posted: Thu Jun 06, 2013 11:30 am
by cim
Cody wrote:
Commander McLane wrote:
.. and lots of systems don't have Rock Hermits;
All systems have at least one rock hermit now (I think).
Yes, as of 1.77, unless it gets blown up.
Commander McLane wrote:
Note that the closest dockable entity does not need to be a station. It can also be a carrier
I think - I'd have to check - that as of 1.77 carriers cannot become the main station. There's quite a bit of stuff around "what is a main station" that I want to tidy up - the main station gets a bunch of separate properties all of which should not necessarily be unique to a single station (and many of which make no sense whatsoever when applied to an originally non-main station).

Re: Scripters cove

Posted: Fri Jun 14, 2013 11:13 am
by Switeck
cim wrote:
Cody wrote:
Commander McLane wrote:
.. and lots of systems don't have Rock Hermits;
All systems have at least one rock hermit now (I think).
Yes, as of 1.77, unless it gets blown up.
As a regular asteroid miner, this greatly increases the profitability of a system to me...perhaps too much. Is there an easy way to adjust system populator not add a Rock Hermit to some systems?

Re: Scripters cove

Posted: Fri Jun 14, 2013 11:23 am
by cim
Switeck wrote:
cim wrote:
Cody wrote:
All systems have at least one rock hermit now (I think).
Yes, as of 1.77, unless it gets blown up.
As a regular asteroid miner, this greatly increases the profitability of a system to me...perhaps too much. Is there an easy way to adjust system populator not add a Rock Hermit to some systems?
Not yet, but there will be. You can always remove it and its nearby asteroids after population has happened, of course.

That said, for a system in 1.77 that would not have had a hermit in 1.76, the hermit is positioned some way outside the orbital plane, well away from the spacelanes. They're not easy to find (well, unless you have a rock hermit locator...) except by getting a pirate to show you where it is, or visually scanning space for a tiny grey dot. The odds of on-lane hermits are (more-or-less) unchanged.

Re: Scripters cove

Posted: Fri Jun 14, 2013 12:02 pm
by Switeck
Ok, so long as they're off the beaten path that's not so much a problem. By placing them sometimes well away from the main shipping lanes, systems are a little more realistic and interesting.

Rock Hermits were mainly valuable to me because they were often along my quick route to main station, so a quick stop at them meant I could stock up on a small amount of cheap precious metals...and sell off any Liquors/Wines I happened to be carrying.