It seems like it can only be fully relied upon for managed OXPs…
Do you mean that it doesn't work for OXPs in the AddOns dir? I have my Station Bulletins OXP in AddOns, and it's picked up. I also have another OXP in there which is deliberately disabled and doesn't show up.
It will work, as Switeck noted, as long as the filename remains the same as in the code: if I check for the presence of the substring "Whatever v1.0.oxp", but the file with the OXP will be named something else, for example "whatever v1.2 (1).oxp", it will not notice it, even though it is a valid name and the OXP will be loaded.
However, we probably can just ask the end user to leave the OXP name recognizable enough for the code if they change it, and now it's their problem whether they notice it or not.
The missionVariables can only store numbers and strings, so to store an array or object, it need to be converted to a string on write and back on read. The simplest way to do this would be to use JSON:
Trying to achieve a very simple effect but not sure how to go about it.
Upon exiting a wormhole/entering a system, I'd like the player ship to have an initial heading approximating that of the local star/sun instead of that of the main planet.
A little bit of randomisation thrown in so that it's always somewhere in the vicinity of rather than ever directly aimed at the star.
The the player would then both have to use the compass to target the planet and also get some sense of the system they'd just arrived in.
There's performFaceDestination but I want the player ship to be aligned immediately upon arrival, just like they currently are with regards to the planet.
Trying to achieve a very simple effect but not sure how to go about it.
Upon exiting a wormhole/entering a system, I'd like the player ship to have an initial heading approximating that of the local star/sun instead of that of the main planet.
A little bit of randomisation thrown in so that it's always somewhere in the vicinity of rather than ever directly aimed at the star.
The the player would then both have to use the compass to target the planet and also get some sense of the system they'd just arrived in.
There's performFaceDestination but I want the player ship to be aligned immediately upon arrival, just like they currently are with regards to the planet.
You can directly set the player's ship orientation:
this.shipExitedWitchspace = function () {
if (!system.sun)
return;
var rotationToSun = system.sun.position.direction().rotationTo([0, 0, 1]);
// Rotation to the main planet from witchpoint is the identity quaternion (no rotation)
// But the player ship has some random initial rotation
// By multiplication we add this rotation to the rotation to the star
var ps = player.ship;
ps.orientation = ps.orientation.multiply(rotationToSun);
};
If you want a more customization, you can add some randomisation manually:
Is there a way to distinguish if a player is entering a witchspace by their own hyperdrive or through someone else's wormhole? (Preferably on a ship's "playerWillEnterWitchspace" event)
Is there a way to distinguish if a player is entering a witchspace by their own hyperdrive or through someone else's wormhole? (Preferably on a ship's "playerWillEnterWitchspace" event)
You could try adding a non-visible piece of equipment if playerStartedJumpCountdown, testing for its presence on shipWillEnterWitchspace then doing whatever you need to do, before removing when either shipWillExitWitchspace or playerCancelledJumpCountdown occurs.
Is there a way to distinguish if a player is entering a witchspace by their own hyperdrive or through someone else's wormhole? (Preferably on a ship's "playerWillEnterWitchspace" event)
You could try adding a non-visible piece of equipment if playerStartedJumpCountdown, testing for its presence on shipWillEnterWitchspace then doing whatever you need to do, before removing when either shipWillExitWitchspace or playerCancelledJumpCountdown occurs.
It should work, but I'll change this solution a bit to use a world script variable instead of a piece of equipment.
Thank you!
Do like I do -- find an existing OXP that uses a worldscript and stuff it there, with bonus points if there's already a playerStartedJumpCountdown section in it.
Do like I do -- find an existing OXP that uses a worldscript and stuff it there, with bonus points if there's already a playerStartedJumpCountdown section in it.
The Oolite AddonScanner generates index pages for all expansion on the expansion manager. I think it also marks up scripts found in these expansions.
So finding a suitable OXP might just be a one line grep command.