Join us at the Oolite Anniversary Party -- London, 7th July 2024, 1pm
More details in this thread.

Scripters cove

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

Moderators: winston, another_commander

User avatar
Rorschachhamster
---- E L I T E ----
---- E L I T E ----
Posts: 274
Joined: Sun Aug 05, 2012 11:46 pm
Contact:

Re: Scripters cove

Post by Rorschachhamster »

Thanks!
So, now my freighttrain has a 1 in 10 Chance to fly to the main station... :D
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Re: Scripters cove

Post 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.
User avatar
spara
---- E L I T E ----
---- E L I T E ----
Posts: 2676
Joined: Wed Aug 15, 2012 4:19 am
Location: Finland

Re: Scripters cove

Post 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?
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: Scripters cove

Post 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.
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Re: Scripters cove

Post by JensAyton »

If concurrency is ever added to Oolite scripting, it should be something similar to WebSockets Web Workers – no shared mutable state.
User avatar
spara
---- E L I T E ----
---- E L I T E ----
Posts: 2676
Joined: Wed Aug 15, 2012 4:19 am
Location: Finland

Re: Scripters cove

Post 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 :).
User avatar
spara
---- E L I T E ----
---- E L I T E ----
Posts: 2676
Joined: Wed Aug 15, 2012 4:19 am
Location: Finland

Re: Scripters cove

Post 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?
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2321
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia

Re: Scripters cove

Post 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.
User avatar
spara
---- E L I T E ----
---- E L I T E ----
Posts: 2676
Joined: Wed Aug 15, 2012 4:19 am
Location: Finland

Re: Scripters cove

Post by spara »

Thanks Wildeblood. That clears up things.
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:

Re: Scripters cove

Post 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.)
User avatar
Cody
Sharp Shooter Spam Assassin
Sharp Shooter Spam Assassin
Posts: 16073
Joined: Sat Jul 04, 2009 9:31 pm
Location: The Lizard's Claw
Contact:

Re: Scripters cove

Post 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).
I would advise stilts for the quagmires, and camels for the snowy hills
And any survivors, their debts I will certainly pay. There's always a way!
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: Scripters cove

Post 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).
Switeck
---- E L I T E ----
---- E L I T E ----
Posts: 2411
Joined: Mon May 31, 2010 11:11 pm

Re: Scripters cove

Post 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?
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: Scripters cove

Post 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.
Switeck
---- E L I T E ----
---- E L I T E ----
Posts: 2411
Joined: Mon May 31, 2010 11:11 pm

Re: Scripters cove

Post 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.
Post Reply