but should that not be oolite-priorityai (dash instead of underscore)
I did try that, but got a different error about trying to subtract something. Looking in the oolite-priorityai.js file, there is a line that reads:this.ship.AIScript.oolite_priorityai = this;, so I think the underscore is correct.
but should that not be oolite-priorityai (dash instead of underscore)
I did try that, but got a different error about trying to subtract something. Looking in the oolite-priorityai.js file, there is a line that reads:this.ship.AIScript.oolite_priorityai = this;, so I think the underscore is correct.
No comment about the problem at hand, but FYI when you get the "can't subtract" error use this notation:- this.ship.AIScript["oolite-priorityai"]
Cim, I'm really sorry. I'm a programmer and I should be able to work this out, but I mustn't have enough caffeine in my system, or I've eaten too many dark side cookies, or something, because I can't work this out.
The problem is that ship.AIScript.oolite_priorityai won't be defined until the AI has initialised (after the AIScript'saiStarted is called). So shipSpawned is probably too early to do this.
There are two ways out of this:
1) Call it later. Set a 0.25 second timer (or a one-frame frame callback) in shipSpawned, which updates the AI.
2) Rather than updating the AI, update the AI library. Advantage: no timing issues, only needs doing once. Disadvantage: updates it for everything including non-assassin OXP AIs so you really need to document that you've done this.
In your this.startUp, do
Is it possible with JS to add a parcel contract to the Parcel Contracts screen? I know I can add a contract to the player via player.ship.addParcel, but can I add it to the station so the player sees the contract in the normal place?
EDIT: I think I just figured it out. Would I use worldScripts["oolite-contracts-parcels"]._addParcelToSystem?
If I set the script on a ship using setScript, does that replace any script the ship already has, or can it be in addition to any script the ship has? For instance, if I wanted to add a single handler to a ship that already has a script, say shipDockedWithStation, can I do this without upsetting any existing script?
If I set the script on a ship using setScript, does that replace any script the ship already has, or can it be in addition to any script the ship has?
Yes, using setScript replaces the whole existing script with the contents of a specified JS file.
phkb wrote:
For instance, if I wanted to add a single handler to a ship that already has a script, say shipDockedWithStation, can I do this without upsetting any existing script?
Yes.
If you have a reference to the ship (hereinafter "theShip"), you can just add theShip.script.whatever to its existing script. e.g.
Is it possible to pull up a random ship class name? Eg. "Python" or "Cobra MkIII" or "Sidewinder Scout Ship".
Not very straight forward, but you can work some magic with keysForRole and shipDataForKey. Don't know your context, but also pulling ship class names from ships spawned to the system retrieved with entitiesWithScanClass (or something else that gives you a list of entities in system) might do the trick.
Question: what is the official rate at which ships can be launched from a station? 2 per minute? 3 per minute?
Give it enough docks and you can launch them as fast as you like.
Any individual dock can't launch more than one ship every six seconds, and it may be slower in practice as it needs the ships which have launched to have cleared the area in front of the dock.
Ok, this is driving me up the proverbial and possibly literal wall, if I can find a wall handy.
I'm trying to tinker with some oxps to improve my overall Oolite feel; the two in question are the original Constores 3.0 (the last version with the box constores) and HOopy Casinos. My goal with HOopy is to only have them present in Corporate systems-- it makes no sense to me to have them in Commie or Dictator systems even if the description says 'famed for their hoopy casinos'. Anyhow, making /any/ change to the populator script, even changing a single number without moving anything else, or erasing anything else, or changing the formatting, breaks the populator entirely. It won't load and the log shows the following:
Keep in mind I'm changing nothing else in this file except a couple of numbers and I am /not/ using notepad, because I know that messes up the formatting. (I've tried both wordpad and MS Word and they both have this same result.)
Next issue, with Constores 3.0, using the old box store models. I can use the current script for the constores to remove the shipyard/refueling per the 4.x updates, but doing so makes the constores ignore the commodities listings from the custom list, or breaks the nav/witchspace beacon billboards, but does not apparently generate any log messages to explain why.
What am I doing wrong here? Why does changing one or two numbers in the HOopy populator somehow destroy the formatting even if nothing else is moved and no spacings are changed? I'm lost here, and I'd really appreciate any advice on how this is supposed to work.
Reports of my death have been greatly underestimated.
It's actually a pretty simple mistake, and one I often make:
Layne wrote:
system.government = 7
should read as system.government == 7. In Javascript, the "=" sign on its own is used for assigning values (ie. var x = 1;) In an "If" statement, you need to use "==" or "===". Either should do the trick.
It also looks like you're missing a bracket at the end of the if clauses.