Here... have a cookie!CommRLock78 wrote:What I have seems to work...
Scripters cove
Moderators: winston, another_commander
- Cody
- Sharp Shooter Spam Assassin
- Posts: 16081
- Joined: Sat Jul 04, 2009 9:31 pm
- Location: The Lizard's Claw
- Contact:
Re: Scripters cove
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!
And any survivors, their debts I will certainly pay. There's always a way!
- Wildeblood
- ---- E L I T E ----
- Posts: 2453
- Joined: Sat Jun 11, 2011 6:07 am
- Location: Western Australia
- Contact:
Re: Scripters cove
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)
- CommRLock78
- ---- E L I T E ----
- Posts: 1138
- Joined: Sat Apr 07, 2012 7:35 pm
- Location: US
- Contact:
Re: Scripters cove
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 code
system.isInstellarSpace
were true) I'd just leave out the '!' ? (i.e., no '!'
in system.isInstellarSpace
)"I'll laser the mark all while munching a fistful of popcorn." - Markgräf von Ededleen, Marquess, Brutal Great One, Assassins' Guild Exterminator
---------------------------
At the helm of the Caduceus Omega, 'Murderous Morrígan'
---------------------------
At the helm of the Caduceus Omega, 'Murderous Morrígan'
- Wildeblood
- ---- E L I T E ----
- Posts: 2453
- Joined: Sat Jun 11, 2011 6:07 am
- Location: Western Australia
- Contact:
Re: Scripters cove
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
)
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)
- CommRLock78
- ---- E L I T E ----
- Posts: 1138
- Joined: Sat Apr 07, 2012 7:35 pm
- Location: US
- Contact:
Re: Scripters cove
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)
"I'll laser the mark all while munching a fistful of popcorn." - Markgräf von Ededleen, Marquess, Brutal Great One, Assassins' Guild Exterminator
---------------------------
At the helm of the Caduceus Omega, 'Murderous Morrígan'
---------------------------
At the helm of the Caduceus Omega, 'Murderous Morrígan'
- Tricky
- ---- E L I T E ----
- Posts: 821
- Joined: Sun May 13, 2012 11:12 pm
- Location: Bradford, UK. (Anarchic)
Re: Scripters cove
I would also delete the shipWillLaunchFromStation event function. One less event to fire in your OXP. Deleting it will also stop any code that resets variables and such like from occuring more than once when you launch from the station then re-dock (maybe you forgot something) and then re-launching.
Note: That event (and all other events) will be redefined when you start a new game or load a new commander. In other words, all scripts are re-loaded.
Code: Select all
this.shipWillLaunchFromStation = function (station) {
delete this.shipWillLaunchFromStation;
/* Rest of your code here. */
...
};
easy way to auto-prime equipment?
I'm using the great missile spoof.oxp. I really like it, it's awesome, but it works a little bit "too well" for my taste. So in order to slightly increase the difficulty, I would like to have to launch the ECM and the spoof myself - the missile-spoof currently does all this automatically.
Since it is not easily possible to determine which ship launched an ECM, and therefore not easy to write a script that launches the missile spoof if it was the player who activated the ECM, I thought about making the missile spoof a primable equipment instead. But switching through 10 or more primable equipments in the heat of combat while a missile is inbound is perhaps to much of a rise in difficulty So I thought it would be nice if it was possible to auto-prime / automatically select the missile spoof as soon as a missile is launched upon the player's ship, and perhaps reset it to the previously selected equipment when the danger has been averted.
Is there a clean and easy way to achieve this?
Since it is not easily possible to determine which ship launched an ECM, and therefore not easy to write a script that launches the missile spoof if it was the player who activated the ECM, I thought about making the missile spoof a primable equipment instead. But switching through 10 or more primable equipments in the heat of combat while a missile is inbound is perhaps to much of a rise in difficulty So I thought it would be nice if it was possible to auto-prime / automatically select the missile spoof as soon as a missile is launched upon the player's ship, and perhaps reset it to the previously selected equipment when the danger has been averted.
Is there a clean and easy way to achieve this?
忍 knowing that enough is enough, you'll always have enough.
Running Oolite 1.77 on Ubuntu Linux 12.04 LTS
Running Oolite 1.77 on Ubuntu Linux 12.04 LTS
Re: Scripters cove
Not without a change to the trunk code, no.
My OXPs via Boxspace or from my Wiki pages .
Thargoid TV
Dropbox Referral Link
Thargoid TV
Dropbox Referral Link
Re: Scripters cove
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.
忍 knowing that enough is enough, you'll always have enough.
Running Oolite 1.77 on Ubuntu Linux 12.04 LTS
Running Oolite 1.77 on Ubuntu Linux 12.04 LTS
- Wildeblood
- ---- E L I T E ----
- Posts: 2453
- Joined: Sat Jun 11, 2011 6:07 am
- Location: Western Australia
- Contact:
Re: Scripters cove
How can I find if there is space in the ship's safe to buy the sub-tonne precious cargoes? Using this will turn over the cargo in the hold:-
- but what can I use instead of cargoSpaceAvailable for the safe?
Code: Select all
if (player.ship.cargoSpaceAvailable > reserveSpace)
{
// Find something to buy.
}
if (player.ship.cargoSpaceAvailable < reserveSpace + 1)
{
// Find something to sell.
}
- Wildeblood
- ---- E L I T E ----
- Posts: 2453
- Joined: Sat Jun 11, 2011 6:07 am
- Location: Western Australia
- Contact:
Re: Scripters cove
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?
- Tricky
- ---- E L I T E ----
- Posts: 821
- Joined: Sun May 13, 2012 11:12 pm
- Location: Bradford, UK. (Anarchic)
Re: Scripters cove
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)
Re: Scripters cove
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
Yes, there are separate safes for all three cargoes, and you can't use space in one to store the others.
- Wildeblood
- ---- E L I T E ----
- Posts: 2453
- Joined: Sat Jun 11, 2011 6:07 am
- Location: Western Australia
- Contact:
Re: Scripters cove
Thank you, Tricky. Thank you, cim.
Re: Scripters cove
Quick question, I'm trying to use the new allowOfferShip function to make a ship only available if a mission variable is set to a specific value and the player is in an anarchy system. Is this even possible?
Desktop PC: CPU: Intel i7-4790K Quad Core 4.4GHz (Turbo-Charged) GPU: Nvidia GeForce GTX 1080Ti RAM: 32GB DDR3
Laptop PC: CPU: Intel i5-10300H Quad Core 4.5GHz (Turbo-Charged) GPU: Nvidia GeForce GTX 1650 RAM: 32GB DDR4
Laptop PC: CPU: Intel i5-10300H Quad Core 4.5GHz (Turbo-Charged) GPU: Nvidia GeForce GTX 1650 RAM: 32GB DDR4