Is There A Comprehensive Guide/List Of Java Script Commands?
Moderators: winston, another_commander
Is There A Comprehensive Guide/List Of Java Script Commands?
I need to get my brain around Java Script in Oolite, and the main thing I'm having difficulty with is the commands which define conditions, create reactions, figure number variables, etc... Is there a guide for this? I SEE what others have done with "if", "else", "var", "Math.floor. Math.random, Math.abs", but I don't seem to be putting them together as a valid Java Script. I've gotten past the "Setup Actions", at lest to some degree, though not perfectly, but I need a way to use the commands I have listed, and any others I haven't listed because I don't know about. I feel like I'm just on the verge of understanding, but there is a block I have not been able to get through. Anyone know of such a guide, or list? Thanks.
- PhantorGorth
- ---- E L I T E ----
- Posts: 647
- Joined: Wed May 20, 2009 6:48 pm
- Location: Somewhere off the top left of Galaxy 1 map
Re: Is There A Comprehensive Guide/List Of Java Script Comma
Not that detailed but a great starting point is:
http://www.w3schools.com/js/
It should cover the answers to most of the the questions you are posing, but remember that it is written from the point of view of a web developer not for some other use of a JS engine. For instance the window object is provided by all JS supporting browsers but that object doesn't exist in Oolite. For the special Oolite objects such as player, ship, mission, etc see the wiki starting here.
http://www.w3schools.com/js/
It should cover the answers to most of the the questions you are posing, but remember that it is written from the point of view of a web developer not for some other use of a JS engine. For instance the window object is provided by all JS supporting browsers but that object doesn't exist in Oolite. For the special Oolite objects such as player, ship, mission, etc see the wiki starting here.
Chat and relax with other commanders in the [url=irc://irc.oftc.net/oolite]DS's Seedy Space Bar[/url]. The Coolest Bar in the Eight.
Phantor's OXPs: GalCop Rewards and Safe Docking
Phantor's OXPs: GalCop Rewards and Safe Docking
Re: Is There A Comprehensive Guide/List Of Java Script Comma
Thank you. That does help.PhantorGorth wrote:Not that detailed but a great starting point is:
http://www.w3schools.com/js/
It should cover the answers to most of the the questions you are posing, but remember that it is written from the point of view of a web developer not for some other use of a JS engine. For instance the window object is provided by all JS supporting browsers but that object doesn't exist in Oolite. For the special Oolite objects such as player, ship, mission, etc see the wiki starting here.
- JensAyton
- Grand Admiral Emeritus
- Posts: 6657
- Joined: Sat Apr 02, 2005 2:43 pm
- Location: Sweden
- Contact:
Re: Is There A Comprehensive Guide/List Of Java Script Comma
And for reference documentation for built-in JavaScript objects and functions (like
Math
), as well as syntax like if
statements, see the Mozilla Developer Network.E-mail: [email protected]
- SandJ
- ---- 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: Is There A Comprehensive Guide/List Of Java Script Comma
For generic JavaScript, you can do a lot worse than see what books your public library has. I got half a dozen out at once a couple of years ago when trying to learn it myself.mandoman wrote:I need to get my brain around Java Script in Oolite, and the main thing I'm having difficulty with is the commands which define conditions, create reactions, figure number variables, etc... Is there a guide for this?
Meanwhile:
- Wikipedia JavaScript syntax;
- a list of JavaScript reference sites.
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.
Dropbox referral link 2GB of free space online + 500 Mb for the referral: good for securing work-in-progress.
Re: Is There A Comprehensive Guide/List Of Java Script Comma
I just found that site yesterday, (because of wikipedia userscript/css) and it is nice, has nifty little this and that, among them a really nice colour-listing / picker.PhantorGorth wrote:
- PhantorGorth
- ---- E L I T E ----
- Posts: 647
- Joined: Wed May 20, 2009 6:48 pm
- Location: Somewhere off the top left of Galaxy 1 map
Re: Is There A Comprehensive Guide/List Of Java Script Comma
I am surprised people don't find that place straight away; it's the second non-ad entry on a google search of "javascript".snork wrote:I just found that site yesterday, (because of wikipedia userscript/css) and it is nice, has nifty little this and that, among them a really nice colour-listing / picker.PhantorGorth wrote:
I find that it's not bad for getting you started and for reminding yourself of various function syntaxes, but it doesn't cover complex stuff like scope and closures.
Chat and relax with other commanders in the [url=irc://irc.oftc.net/oolite]DS's Seedy Space Bar[/url]. The Coolest Bar in the Eight.
Phantor's OXPs: GalCop Rewards and Safe Docking
Phantor's OXPs: GalCop Rewards and Safe Docking
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
Re: Is There A Comprehensive Guide/List Of Java Script Comma
I am surprised its also the second result on a google search on the dutch google site. Al other pages in the top 5 being in dutch language, its surprising that an english page is that high.PhantorGorth wrote:I am surprised people don't find that place straight away; it's the second non-ad entry on a google search of "javascript".
A big google flaw is that number one in the google results is the dutch site about Java! (No relation with javaScript)
UPS-Courier & DeepSpacePirates & others at the box and some older versions
Re: Is There A Comprehensive Guide/List Of Java Script Comma
Have to admit that I never tried a Google search. I had the understanding that Java Script in Oolite is not quite the same as Java Script in general. I guess it's true, because I can't get this dang script to even be recognized AS a Java Script. I swear, I'm going to starting chewing on nails pretty soon. It LOOKS like what i have written is following the principles I have been reading in the Oolite oxpHowToWiki, and now also with the suggested sight, but all I get in return in Latest.log is "such, and such is a nonScript, ignoring". Keeps telling me I have a semi colon in the wrong place, or it's needed where the examples I have looked at show no indication of putting one. Frustrating. I'll just keep at it, I guess.
- PhantorGorth
- ---- E L I T E ----
- Posts: 647
- Joined: Wed May 20, 2009 6:48 pm
- Location: Somewhere off the top left of Galaxy 1 map
Re: Is There A Comprehensive Guide/List Of Java Script Comma
Oolite uses the SpiderMonkey JS engine from Mozilla. The same one used in Firefox. The any differences are therefore not syntactic, they are instead down to available objects exposed by the program it's embedded in and how you add JS to Oolite over how you add it to a webpage. Your problems sound more like you are not writing valid Javascript, but without looking at your code I can not comment on the issues you are getting.mandoman wrote:Have to admit that I never tried a Google search. I had the understanding that Java Script in Oolite is not quite the same as Java Script in general. I guess it's true, because I can't get this dang script to even be recognized AS a Java Script. I swear, I'm going to starting chewing on nails pretty soon. It LOOKS like what i have written is following the principles I have been reading in the Oolite oxpHowToWiki, and now also with the suggested sight, but all I get in return in Latest.log is "such, and such is a nonScript, ignoring". Keeps telling me I have a semi colon in the wrong place, or it's needed where the examples I have looked at show no indication of putting one. Frustrating. I'll just keep at it, I guess.
Chat and relax with other commanders in the [url=irc://irc.oftc.net/oolite]DS's Seedy Space Bar[/url]. The Coolest Bar in the Eight.
Phantor's OXPs: GalCop Rewards and Safe Docking
Phantor's OXPs: GalCop Rewards and Safe Docking
Re: Is There A Comprehensive Guide/List Of Java Script Comma
Okay, here it is. You're right about it not being a valid script, as Oolite keeps telling me the same thing. All I wanted for this ship, which is a non-player ship, was to have it exit Witchspace in situations where three or more Thargoid ships are invading a system, in equal numbers to Thargoids present, and attack the Thargoids until either they, or my UFOships are destroyed.. Whether it's an all out military battle, or not. Can't seem to figure out how to pull it off. Non-script:
Code: Select all
// Standard attributes
this.name = "UFOship.js";
this.author = "Smivs";
this.copyright = "This script is hereby placed in the public domain.";
this.version = "1.0.1";
this.description = "Script to make equal number of UFOships as number of Thargoid ships, appear at any battle with Thargoids, when Thargoids number more than 2."
this.startUp = function()
{
I had a more up to date version of this last night, but now I can't find it. I doubt it was much better anyway.
this.ship = "UFOship";
}
{
this.thargoid = ["thargoid battleship", "thargoid carrier", "thargoid cruiser", "thargoid tharglet", "thargoid terroriser"];
this.thargoidShipList = this.ship.thargoidRoles.concat(); // this is the "working" list of roles, which shortens as roles are picked for spawning.
}
this.ship = "roles";
{
this.role1 = "UFOship will exit witchspace";
this.role2 = "UFOship will attack thargoid ships";
this.role3 = "UFOship will attack any aggressor";
this.role4 = "UFOship will enter witchspace"; // these are all the rolls of the UFOship, dependant on conditions.
}
this.role1 = function()
{
if(thargoid.shiplist)
{
var number = Math.floor(Math.abs()*>=3.0); // more than 2 thargoid ships present.
for(var i=3; i>=number; i++) this.thargoidShipList(this.thargoidshiplist(), =3); //UFOship will equal same number as there are thargoids present.
};
}
this.role2 = function()
{
if(thargoid.shiplist)
{
var number = Math.floor(Math.abs()*>=3.0); //Three or more thargoids present.
};
}
this.role3 = function()
{
if(this.ship is attacked by any aggressor)
}
this.role4 = function()
{
if(this.thargoidshiplist)
{
var number = Math.floor(Math.abs()=0.0);
};
}
- Smivs
- Retired Assassin
- Posts: 8408
- Joined: Tue Feb 09, 2010 11:31 am
- Location: Lost in space
- Contact:
Re: Is There A Comprehensive Guide/List Of Java Script Comma
Just to put the record straight, I don't remember authoring that particular script!
Commander Smivs, the friendliest Gourd this side of Riedquat.
Re: Is There A Comprehensive Guide/List Of Java Script Comma
No, I know that, and certainly don't hold anyone but myself to account for it. The way you wrote it worked for how you had it, but it was not the ultimate goal for which I have set for that ship. I don't want to just spawn it every time I jump into a system, I want Oolite to spawn it when certain conditions are met. It can exit Witchspace any time there are 3 or more Thargoids present, and there needs to be the same number of UFOships spawned as there are Thargoids present. I don't understand why that is so difficult to achieve, but for me it sure seems to be. Last night I had used a combination ofSmivs wrote:Just to put the record straight, I don't remember authoring that particular script!
Code: Select all
this.startUp = function()
{
this.ship = "UFOship";
}
{
this.thargoid = ["thargoid battleship", "thargoid carrier", "thargoid cruiser", "thargoid tharglet", "thargoid terroriser"];
this.thargoidShipList = this.ship.thargoidRoles.concat();
this.shipWillExitWitchspace = function()
{
if(system.isInterstellarSpace)
{
var number = Math.floor(Math.abs()*Math.abs()*3);
if(this.thargoidshiplist.length >= number) this.thargoidshiplist = this.thargoid.concat;
for(var u>=3; u>=number; u++) system.legacy_addships(this.ship(), 3);
- PhantorGorth
- ---- E L I T E ----
- Posts: 647
- Joined: Wed May 20, 2009 6:48 pm
- Location: Somewhere off the top left of Galaxy 1 map
Re: Is There A Comprehensive Guide/List Of Java Script Comma
Oh my. I hate to say this but there are more things wrong than right.
It would be too much to discuss in here so I am willing to discuss it in PMs.
What I suggest though is to start simpler. See if you can write a simple OXP that say just spawns a UFOship near the witchpoint on the player arrival in the system and does nothing else. Read the W3Schools site. Read the wiki's JS scripting reference pages to find out how to spawn a ship. Look at the where braces, brackets, semicolons, etc are used in other people's code.
Get that simple OXP right first then start to build from there.
It would be too much to discuss in here so I am willing to discuss it in PMs.
What I suggest though is to start simpler. See if you can write a simple OXP that say just spawns a UFOship near the witchpoint on the player arrival in the system and does nothing else. Read the W3Schools site. Read the wiki's JS scripting reference pages to find out how to spawn a ship. Look at the where braces, brackets, semicolons, etc are used in other people's code.
Get that simple OXP right first then start to build from there.
Chat and relax with other commanders in the [url=irc://irc.oftc.net/oolite]DS's Seedy Space Bar[/url]. The Coolest Bar in the Eight.
Phantor's OXPs: GalCop Rewards and Safe Docking
Phantor's OXPs: GalCop Rewards and Safe Docking
Re: Is There A Comprehensive Guide/List Of Java Script Comma
Okay. I thought that's what I was doing. Maybe I just don't have the brains for this, or talent, but I'm willing to keep trying. If I can learn it even a little, it will be one step forward for me. Did you want me to PM you, or the other way around?PhantorGorth wrote:Oh my. I hate to say this but there are more things wrong than right.
It would be too much to discuss in here so I am willing to discuss it in PMs.
What I suggest though is to start simpler. See if you can write a simple OXP that say just spawns a UFOship near the witchpoint on the player arrival in the system and does nothing else. Read the W3Schools site. Read the wiki's JS scripting reference pages to find out how to spawn a ship. Look at the where braces, brackets, semicolons, etc are used in other people's code.
Get that simple OXP right first then start to build from there.