Question: is it possible to access a variable from another OXP's world-script?
If so, what is the syntax for doing this? (could someone perhaps give me an example?)
Besides the the global and mission variables, mentioned by Redspear, there is another way. To use it variable that you want to access should be property of "this" of the world-script:
Note: If you're going to be accessing multiple variables, or do it frequently, then it probably makes sense to store the script object once instead of retrieving it each time.
Lave, for example, is ID #7 and so should trigger the first but it triggers the third instead
It works if I swap ID for economy for example (with different numbers of course).
That it triggers at all suggest that my use of '.ID' is ok but why no discrimination upon calling the value (of ID)?
Lave, for example, is ID #7 and so should trigger the first but it triggers the third instead
It works if I swap ID for economy for example (with different numbers of course).
That it triggers at all suggest that my use of '.ID' is ok but why no discrimination upon calling the value (of ID)?
Any advice please?
System.infoForSystem returns a dictionary from planetinfo.plist, not a System object. The dictionary does not have an ID property, so the result is undefined. Is undefined lesser than 86? JS thinks not. Is undefined lesser than 171? Same, so the third branch is being executed.
Why are you even trying to get an ID through the system information if you already have one? You can just use it like this:
1. Is it possible to somehow use scriptedAI along with PriorityAI?
2. Is there a handler that gets called when the cargo in cargo hold is destroyed? Or how else to track it?
3. How to find out if a certain OXP is installed if it doesn't have any worldscript? More specifically, I'm want to check retexture OXPs, addition versions. The only way I see is to use Ship.shipDataForKey, but maybe I'm missing something obvious?
The questions are not related to each other, I'm just asking them in bulk.
3. How to find out if a certain OXP is installed if it doesn't have any worldscript? More specifically, I'm want to check retexture OXPs, addition versions. The only way I see is to use Ship.shipDataForKey, but maybe I'm missing something obvious?
This is a bit clunky, but it seems to do the job. I'm using Griff's Fer-de-Lance as an example.
I've been thinking about adding a wiki page regarding things in "regular" Javascript that are NOT available in Oolite Javascript. I've run across a handful. They're mainly string methods: includes, startsWith, endsWith, replaceAll. Also some techniques for deep copying don't seem to be implemented.
So…
1. Worthwhile or a waste of time & space?
2. If worthwile- do you know of any moar? And please correct me if I'm wrong about those I listed. Also, if someone has already done this somewhere, point me to it.
3. How to find out if a certain OXP is installed if it doesn't have any worldscript? More specifically, I'm want to check retexture OXPs, addition versions. The only way I see is to use Ship.shipDataForKey, but maybe I'm missing something obvious?
This is a bit clunky, but it seems to do the job. I'm using Griff's Fer-de-Lance as an example.
const oxzList = oolite.resourcePaths
for (let kowntr = 0; kowntr < oxzList.length; kowntr++)
if (oxzList [kowntr].indexOf ("oolite.oxp.Griff.Ferdelance.oxz") > -1)
log (name, oxzList [kowntr] + " is installed")
Forgot one thing- you might want to add a "break" at the end of the IF statement since oxzList tends to be lengthy.
I keep a lot of older versions of OXPs and OXZs.
To keep track of them, I often rename the original files from "Whatever.oxz" to "Whatever v1.2.oxz" (in the case of version 1.2).
Would your logic still work with the renamed files?
I've been thinking about adding a wiki page regarding things in "regular" Javascript that are NOT available in Oolite Javascript. I've run across a handful. They're mainly string methods: includes, startsWith, endsWith, replaceAll. Also some techniques for deep copying don't seem to be implemented.
So…
1. Worthwhile or a waste of time & space?
2. If worthwile- do you know of any moar? And please correct me if I'm wrong about those I listed. Also, if someone has already done this somewhere, point me to it.
Definitely worthwhile! - if you have the time. I for one would appreciate it greatly, because I've frequently run across methods from my 'standard javascript manual' that don't work at all in 'Oolite JS'.
3. How to find out if a certain OXP is installed if it doesn't have any worldscript? More specifically, I'm want to check retexture OXPs, addition versions. The only way I see is to use Ship.shipDataForKey, but maybe I'm missing something obvious?
This is a bit clunky, but it seems to do the job. I'm using Griff's Fer-de-Lance as an example.
const oxzList = oolite.resourcePaths
for (let kowntr = 0; kowntr < oxzList.length; kowntr++)
if (oxzList [kowntr].indexOf ("oolite.oxp.Griff.Ferdelance.oxz") > -1)
log (name, oxzList [kowntr] + " is installed")
Forgot one thing- you might want to add a "break" at the end of the IF statement since oxzList tends to be lengthy.
Thank you! It seems like it can only be fully relied upon for managed OXPs, but it's still useful to have such a method even for others as a last resort.
I keep a lot of older versions of OXPs and OXZs.
To keep track of them, I often rename the original files from "Whatever.oxz" to "Whatever v1.2.oxz" (in the case of version 1.2).
Would your logic still work with the renamed files?
Sure- as long as the oxz has a valid filename and is loaded by Oolite. "Whatever v1.2.oxz" is fine. On the other hand, "Whatever v1.2.wip" won't be loaded and therefore not included in the resourcePaths property.
Definitely worthwhile! - if you have the time. I for one would appreciate it greatly, because I've frequently run across methods from my 'standard javascript manual' that don't work at all in 'Oolite JS'.
Cool- I'll comb thru my notes to see if I logged any others. You obviously have felt the same frustration I have in finding just the right method only to have Oolite thumb its nose when you try to use it. Anyway, I'll put up the page sometime in the next few days- the bulk of my "Oolite time" is currently spent on LitF+.
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.