Scripters cove

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: winston, another_commander

User avatar
mandoman
---- E L I T E ----
---- E L I T E ----
Posts: 1385
Joined: Thu Apr 28, 2011 3:17 pm

Re: Scripters cove

Post by mandoman »

Ironfist wrote:
mandoman,

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. :lol:

Okti, I'll get right on it. Thanks. :)
Mandotech Industries Wiki Page.

http://wiki.alioth.net/index.php/User:Mandoman
User avatar
Okti
---- E L I T E ----
---- E L I T E ----
Posts: 700
Joined: Sun Sep 26, 2010 1:51 pm
Location: A GH shop, near witchpoint to Oresrati in Galaxy 8

Re: Scripters cove

Post by Okti »

Time to sleep over here, so you have plenty time. I will be busy with Work tomorrow but I will try to help you when I have time.
My OXP's
And Latest Mission Coyote's Run
User avatar
mandoman
---- E L I T E ----
---- E L I T E ----
Posts: 1385
Joined: Thu Apr 28, 2011 3:17 pm

Re: Scripters cove

Post by mandoman »

Okti wrote:
Time to sleep over here, so you have plenty time. I will be busy with Work tomorrow but I will try to help you when I have time.
Okay, thanks. :)
Mandotech Industries Wiki Page.

http://wiki.alioth.net/index.php/User:Mandoman
User avatar
CommonSenseOTB
---- E L I T E ----
---- E L I T E ----
Posts: 1397
Joined: Wed May 04, 2011 10:42 am
Location: Saskatchewan, Canada

Re: Scripters cove

Post by CommonSenseOTB »

Okti, umm, not too sure how to put this delicately, but umm, well, here you go. :P

Image

:lol:
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.


CommonSense 'Outside-the-Box' Design Studios Ltd.
WIKI+OXPs
User avatar
Fatleaf
Intergalactic Spam Assassin
Intergalactic Spam Assassin
Posts: 1988
Joined: Tue Jun 08, 2010 5:11 am
Location: In analysis mode on Phaelon
Contact:

Re: Scripters cove

Post by Fatleaf »

Don't do that :shock:
That's my lunch :D
Find out about the early influences of Fatleaf here. Also his OXP's!
Holds the Ooniversal record for "Thread Necromancy"
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Re: Scripters cove

Post by Smivs »

<Smivs chuckles>
Commander Smivs, the friendliest Gourd this side of Riedquat.
User avatar
Capt. Murphy
Commodore
Commodore
Posts: 1127
Joined: Fri Feb 25, 2011 8:46 am
Location: UK South Coast.

Re: Scripters cove

Post by Capt. Murphy »

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.
[EliteWiki] Capt. Murphy's OXPs
External JavaScript resources - W3Schools & Mozilla Developer Network
Win 7 64bit, Intel Core i5 with HD3000 (driver rev. 8.15.10.2696 - March 2012), Oolite 1.76.1
User avatar
Capt. Murphy
Commodore
Commodore
Posts: 1127
Joined: Fri Feb 25, 2011 8:46 am
Location: UK South Coast.

Re: Scripters cove

Post by Capt. Murphy »

Kaks wrote:
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.

Code: Select all

this.minimumJumpSquaredDistance = function(other) {
   // internal Oolite constants used: K = 0.1, SCANNER_MAX_RANGE = 25600
   let dist=other.mass * 0.1;
   return (dist > 655360000 ? 655360000 : dist); // 25600 * 25600
}
.........................
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'.

dist = Math.sqrt(player.ship.mass * 0.1)+50
[EliteWiki] Capt. Murphy's OXPs
External JavaScript resources - W3Schools & Mozilla Developer Network
Win 7 64bit, Intel Core i5 with HD3000 (driver rev. 8.15.10.2696 - March 2012), Oolite 1.76.1
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: Scripters cove

Post by cim »

Capt. Murphy wrote:
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?
This way.
User avatar
SandJ
---- E L I T E ----
---- E L I T E ----
Posts: 1048
Joined: Fri Nov 26, 2010 9:08 pm
Location: Help! I'm stranded down here on Earth!

Re: Scripters cove

Post by SandJ »

Capt. Murphy wrote:
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 :D
Dropbox referral link 2GB of free space online + 500 Mb for the referral: good for securing work-in-progress.
User avatar
mandoman
---- E L I T E ----
---- E L I T E ----
Posts: 1385
Joined: Thu Apr 28, 2011 3:17 pm

Re: Scripters cove

Post by mandoman »

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.

Code: Select all

// 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);
}
}
Mandotech Industries Wiki Page.

http://wiki.alioth.net/index.php/User:Mandoman
User avatar
Okti
---- E L I T E ----
---- E L I T E ----
Posts: 700
Joined: Sun Sep 26, 2010 1:51 pm
Location: A GH shop, near witchpoint to Oresrati in Galaxy 8

Re: Scripters cove

Post by Okti »

Code: Select all

 if (player.score >= 512 ++ thargoidCounter> 0) // if more than 0 then spawn equal number of UFOships.
Try && instead of ++.
My OXP's
And Latest Mission Coyote's Run
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: Scripters cove

Post by cim »

mandoman wrote:

Code: Select all

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.
mandoman wrote:

Code: Select all

  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.
Minor typo: should be && rather than ++
mandoman wrote:

Code: Select all

{
    system.addShips("UFOship", thargoidCounter, player.ship.position, 20000);
}
}
Otherwise that looks okay to me.
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Re: Scripters cove

Post by Commander McLane »

The function is called shipExitedWitch[b][color=#FF0000]s[/color][/b]pace.

Small 's'.
User avatar
Okti
---- E L I T E ----
---- E L I T E ----
Posts: 700
Joined: Sun Sep 26, 2010 1:51 pm
Location: A GH shop, near witchpoint to Oresrati in Galaxy 8

Re: Scripters cove

Post by Okti »

+1 on Commander McLanes Post,

Mandoman, I think it will be better to explain what you are trying to achieve in plain English. More comments on the JS File will explain more.
My OXP's
And Latest Mission Coyote's Run
Post Reply