Is it as the latest.log says, this script is probably OK but what is it called - it would appear that the script which is calling this - is looking for "solarTankderDies.js" could it actually be called 'solarTankerDies.js'.
Just a thought.
Ironfist
LOL!!!!! You are so correct. My worst enemy in all this in my lousy typing. I'll change that and see if it makes a difference.
Okti, umm, not too sure how to put this delicately, but umm, well, here you go.
Take an idea from one person and twist or modify it in a different way as a return suggestion so another person can see a part of it that can apply to the oxp they are working on.
I have a question about ordering when checking multiple conditions in an if() statement.
In if(a || b || !c){return false;} does the JS engine skip the checks for b and !c if a returns true, so that these kind of checks should be arranged to that the first value checked is the one that's most often going to be true for speedier scripts? Or is the whole of (a || b || !c) evaluated before deciding whether to {return false;}, in which case it may be better to do if(a){return false;};if(b){return false;};if(!c){return false;}; especially if there are lots of conditions to be checked and a is more likely to be true than b and in turn !c.
Sometimes an oxp would like to make an NPC jump to another system. However, the NPC might well be blocked by a nearby mass, since it's not always obvious how far away from the station you can safely jump, here's a way to find the minimum distance from any station in order to hopefully jump successfully at the first attempt. It's a combination of AI.plist and ship script, I'm afraid...
NB: I'm using squared distance because it's faster to calculate than distance.
Would I be right in thinking that if you want to avoid the player.ship.mass blocking another entity's jump that this would be a valid check for an appropriate distance.....the +50 is a 'buffer'.
In if(a || b || !c){return false;} does the JS engine skip the checks for b and !c if a returns true, so that these kind of checks should be arranged to that the first value checked is the one that's most often going to be true for speedier scripts?
In if(a || b || !c){return false;} does the JS engine skip the checks for b and !c if a returns true?
Yes, the JavaScript engine does (which in reality means any given implementation of a JS engine should) use short circuit evaluation in combined conditional checking and will stop checking if it sees that a returns true.
Capt. Murphy wrote:
these kind of checks should be arranged so that the first value checked is the one that's most often going to be true?
Correct.
Flying a Cobra Mk I Cobbie 3 with nothing but Explorers Club.OXP and a beam laser 4 proper lasers for company Dropbox referral link 2GB of free space online + 500 Mb for the referral: good for securing work-in-progress.
Okay, here I go again. The scripts given to me for this oxp seem like they should work, and are NOT raising any warning flags, but, they are also not producing the UFOship, in conjunction with thargoid ships that I hoped for. I tried messing with the script, because it seemed to me that the number of thargoid ships in system should be considered BEFORE UFOships are considered, in order to add the correct number of UFOships to that of thargoid ships. Here is what I did. Haven't tried it yet, and thought I would first ask if this is even a valid script. Thanks.
// Standard attributes
this.name = "UFOship.js";
this.author = "mandoman";
this.copyright = "This script is hereby placed in the public domain.";
this.version = "1.0.1";
this.description = "Script to spawn equal number of UFOships as number of Thargoid ships if player ship with score 512, or higher exits Witchspace."
// will run as player exits witchspace, and after game engine has populated the system
this.shipExitedWitchSpace = function()
{
var thargoidCounter = system.countShipsWithPrimaryRole("thargoid"); // count how may thargoid ships are in the system.
if (player.score < 512 || thargoidCounter > 0){return;} // do nothing if player kills is less than 512 or there are already UFOships in the ooniverse.
var thargoidCounter = system.countShipsWithPrimaryRole("thargoid"); // counts how many thargoids there are
if (player.score >= 512 ++ thargoidCounter> 0) // if more than 0 then spawn equal number of UFOships.
{
system.addShips("UFOship", thargoidCounter, player.ship.position, 20000);
}
}
this.shipExitedWitchSpace = function()
{
var thargoidCounter = system.countShipsWithPrimaryRole("thargoid"); // count how may thargoid ships are in the system.
Judging by the comment on the next line, this should probably be countShipsWithPrimaryRole("UFOship") instead.
if (player.score < 512 || thargoidCounter > 0){return;} // do nothing if player kills is less than 512 or there are already UFOships in the ooniverse.
var thargoidCounter = system.countShipsWithPrimaryRole("thargoid"); // counts how many thargoids there are
if (player.score >= 512 ++ thargoidCounter> 0) // if more than 0 then spawn equal number of UFOships.