OXP to Debug Console communication

General discussion for players of Oolite.

Moderators: another_commander, winston

User avatar
hiran
---- E L I T E ----
---- E L I T E ----
Posts: 1008
Joined: Fri Mar 26, 2021 1:39 pm
Location: a parallel world I created for myself. Some call it a singularity...

Re: OXP to Debug Console communication

Post by hiran »

phkb wrote: Tue Jan 25, 2022 5:09 am
hiran wrote: Thu Dec 23, 2021 11:25 am So how could I install an OXP automatically? How would OoliteCommunicator find the Addons folder at runtime to inject the OXP just before Oolite gets started? Or can I do such stunts via the debug console?
There is currently no JS interface to disable or enable an OXP, unless the OXP gives you one itself. I've done this in a couple of mine - having a $disabled flag or some such to quickly turn things on or off. So, if you're looking for a way to harmonise two player's game worlds, the facilities aren't currently available to do this programmatically. You might be stuck with some manual intervention, I'm afraid.

However, you can check to see if an OXP is installed using worldScripts or worldScriptNames.
This would at least allow at runtime to check if preconditions are met. My intention was to make it dead easy for users to run my addon.

Thank you for the response anyway. :-)
I have not failed. I've just found 10,000 ways that won't work. [Thomas Edison]
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6322
Joined: Wed Feb 28, 2007 7:54 am

Re: OXP to Debug Console communication

Post by another_commander »

You can get a list of installed OXPs using oolite.resourcePaths. You can then parse this string to check if a particular OXP is included or not.
User avatar
montana05
---- E L I T E ----
---- E L I T E ----
Posts: 1163
Joined: Mon May 30, 2016 3:54 am
Location: lurking in The Devils Triangle (G1)

Re: OXP to Debug Console communication

Post by montana05 »

phkb wrote: Tue Jan 25, 2022 5:09 am However, you can check to see if an OXP is installed using worldScripts or worldScriptNames.
I might be wrong, but as much as I remember, there are multiple OXP's without a worldScript. :?
Scars remind us where we've been. They don't have to dictate where we're going.
User avatar
phkb
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 3492
Joined: Tue Jan 21, 2014 10:37 pm
Location: Between SDL and a hard place…

Re: OXP to Debug Console communication

Post by phkb »

montana05 wrote: Tue Jan 25, 2022 8:36 am
phkb wrote: Tue Jan 25, 2022 5:09 am However, you can check to see if an OXP is installed using worldScripts or worldScriptNames.
I might be wrong, but as much as I remember, there are multiple OXP's without a worldScript. :?
So a_c’s advice is probably better then - use Oolite.resourcePaths.
User avatar
hiran
---- E L I T E ----
---- E L I T E ----
Posts: 1008
Joined: Fri Mar 26, 2021 1:39 pm
Location: a parallel world I created for myself. Some call it a singularity...

Re: OXP to Debug Console communication

Post by hiran »

phkb wrote: Tue Jan 25, 2022 9:31 am
montana05 wrote: Tue Jan 25, 2022 8:36 am
phkb wrote: Tue Jan 25, 2022 5:09 am However, you can check to see if an OXP is installed using worldScripts or worldScriptNames.
I might be wrong, but as much as I remember, there are multiple OXP's without a worldScript. :?
So a_c’s advice is probably better then - use Oolite.resourcePaths.
Yes, I am aware of resource paths. However that at most tells me the directory to search in, and I'd still have to check what version that OXP is.
I was hoping for more but that does not exist.
montana05 wrote: Tue Jan 25, 2022 8:36 am
phkb wrote: Tue Jan 25, 2022 5:09 am However, you can check to see if an OXP is installed using worldScripts or worldScriptNames.
I might be wrong, but as much as I remember, there are multiple OXP's without a worldScript. :?
You are dead right there. On the other hand it is not an issue as I would not be checking for any OXP but for the one I wrote - and that one has a world script. So if it is missing I would know and have to act by injecting it into one of the AddOns folders. If it exists I would know where it is and could check the version, upgrading it if necessary. All this 'I would' obviously carried out by the OoliteCommunicator - or the new name Nexus.
I have not failed. I've just found 10,000 ways that won't work. [Thomas Edison]
Post Reply