Re: Scripters cove
Posted: Sat Jan 19, 2013 11:49 pm
Here... have a cookie!CommRLock78 wrote:What I have seems to work...
For information and discussion about Oolite.
https://bb.oolite.space/
Here... have a cookie!CommRLock78 wrote:What I have seems to work...
Boolean Yes. Also galaxyNumber is a global variable, no need to find it in system.info.galaxyID.CommRLock78 wrote:What I have seems to work (so far ) - I'm not sure how to implement system.isInterstellarSpace as it is Boolencim wrote:Yes, thoughCommRLock78 wrote:system.ID = -1 for interstellar, right?system.isInterstellarSpace
is perhaps a better test.
Code: Select all
if (!system.isInterstellarSpace && system.ID === 138 && galaxyNumber === 0 && system.planets.length < 5)
Thanks for clearing that up Wildeblood. I think I'll implement that bit of code .Wildeblood wrote:Boolean Yes. Also galaxyNumber is a global variable, no need to find it in system.info.galaxyID.
Code: Select all
if (!system.isInterstellarSpace && system.ID === 138 && galaxyNumber === 0 && system.planets.length < 5)
system.isInstellarSpace
were true) I'd just leave out the '!' ? (i.e., no '!'
in system.isInstellarSpace
)Yes again, but in this case I don't think you need to be checking it at all. As you said, in interstellar space system.ID will be -1, not 138. Thargoid's advice was to make sure you're in system space before checking system.planets.length - you're already doing that.CommRLock78 wrote:Thanks for clearing that up Wildeblood. I think I'll implement that bit of code .Wildeblood wrote:Boolean Yes. Also galaxyNumber is a global variable, no need to find it in system.info.galaxyID.
Code: Select all
if (!system.isInterstellarSpace && system.ID === 138 && galaxyNumber === 0 && system.planets.length < 5)
It appears that '!' is 'false' or 'not', so if I were to be checking to see if I was in interstellar space (i.e. testing if the codesystem.isInstellarSpace
were true) I'd just leave out the '!' ? (i.e., no'!'
insystem.isInstellarSpace
)
Code: Select all
if (system.ID === 138 && galaxyNumber === 0 && system.planets.length < 5)
Thanks for the advice , and I'd like to thank you, Cmd. Cheyd, Thargoid, and Cim for my first lesson in javascript, I have a new respect for OXP creators that write these scripts - JS is quite a bit different from anything my limited knowledge is used to (essentially BASIC and Matlab ).Wildeblood wrote:Yes again, but in this case I don't think you need to be checking it at all. As you said, in interstellar space system.ID will be -1, not 138. Thargoid's advice was to make sure you're in system space before checking system.planets.length - you're already doing that.
My theory with these multi-part conditional tests, which I got from Capt. Murphy, is that they are most efficient if you test the most likely failures first. Hence check system.ID, which only has a 1/256 chance of passing, before galaxyNumber, which has a 1/8 chance (and don't check anything you don't really need to).
Code: Select all
if (system.ID === 138 && galaxyNumber === 0 && system.planets.length < 5)
Code: Select all
this.shipWillLaunchFromStation = function (station) {
delete this.shipWillLaunchFromStation;
/* Rest of your code here. */
...
};
Thargoid, thanks for the answer. Ok, so I guess I have to live with priming it before I can use it. After all, it's a though space out there.Thargoid wrote:Not without a change to the trunk code, no.
Code: Select all
if (player.ship.cargoSpaceAvailable > reserveSpace)
{
// Find something to buy.
}
if (player.ship.cargoSpaceAvailable < reserveSpace + 1)
{
// Find something to sell.
}
Wildeblood wrote:How can I position an object on a direct line between two other objects? Let's say I have objects playerShip, enemyShip and mysteryAsteroid, how do I position mysteryAsteroid so it is obscuring the player's view of enemyShip?
Code: Select all
mysteryAsteroidPosition = Vector3D.interpolate(player.ship.position, enemyShip.position, 0.5);
system.addShips("mysteryAsteroidRole", 1, mysteryAsteroidPosition, 0)
Have a look at theWildeblood wrote:- but what can I use instead of cargoSpaceAvailable for the safe?
this._hasSpaceFor
function in Resources/Scripts/oolite-contracts-cargo.js