Scripters cove

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

Moderators: winston, another_commander

Switeck
---- E L I T E ----
---- E L I T E ----
Posts: 2411
Joined: Mon May 31, 2010 11:11 pm

Re: Scripters cove

Post by Switeck »

I'm having a problem with Bit Operators (from http://wiki.alioth.net/index.php/Javascript_Operators ).
I wish to use a bitmask to add something to every other system, but apparently this doesn't work:
If( (system.ID & 1) == 0) {

This error message in Latest.log doesn't help me much either:

Code: Select all

08:22:56.140 [script.javaScript.exception.semiBeforeStmnt]: ***** JavaScript exception (WIP.anon-script): SyntaxError: missing ; before statement
08:22:56.140 [script.javaScript.exception.semiBeforeStmnt]:       ../AddOns/WIP.oxp/Config/script.js, line 34: 	If( (system.ID & 1) == 0) {
08:22:56.140 [script.javaScript.load.failed]: ***** Error loading JavaScript script ../AddOns/WIP.oxp/Config/script.js -- compilation failed
Can anyone shed light on how I need to correct my syntax?
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 »

The condition-testing keyword in Javascript is if not If. Other than that the code you've posted looks fine.
Switeck
---- E L I T E ----
---- E L I T E ----
Posts: 2411
Joined: Mon May 31, 2010 11:11 pm

Re: Scripters cove

Post by Switeck »

Wow, simple capitalization mistake on my part...and Oolite complains about a missing ;
I got my code to work after replacing "If" with "if".
Thanks cim. :)

Now has addShips changed since v1.76?
...because this line:

Code: Select all

system.addShips("workcom", 1, Math.random()*0.8);
(Note: I'd edited Commies OXP in the past, so this line isn't in the original!)

Generates this message:
08:51:24.906 [script.javaScript.exception.ooliteDefined]: ***** JavaScript exception (communist_population 2.11): Error: System.addShips: Invalid arguments (0.5895650011952548) -- expected vector.

I could replace such and similar lines with this:

Code: Select all

system.addShipsToRoute("workcom", 1, Math.random()*0.8);
or this:

Code: Select all

system.addGroupToRoute("workcom", 1, Math.random()*0.8);
...but it seems such a chore.

Also seeing this...which probably isn't good:
08:58:14.718 [station.launchShip.failed]: Cancelled launch for a Cobra Mark III with role trader, as it is too large for the docking port of the TransHab Station.
08:58:14.734 [station.launchShip.failed]: Cancelled launch for a Cobra Mark III with role trader, as it is too large for the docking port of the TransHab Station.
08:58:14.734 [station.launchShip.failed]: Cancelled launch for a Cobra Mark I with role sunskim-trader, as it is too large for the docking port of the TransHab Station.


I've seen that on other stations as well, so I'm not sure it's a TransHab Station problem.
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 »

Switeck wrote:
Wow, simple capitalization mistake on my part...and Oolite complains about a missing ;
I got my code to work after replacing "If" with "if".
Because If isn't a keyword, then the Javascript interpreter sees that it's a something with something else in brackets after it, which generally means it's a function being called. A function call is a statement, and statements end in ;. But this statement doesn't - it goes straight into a { instead. So the complaint is that there's a missing ; . With that, it would be valid syntax, though it would fail if you tried to run it because there's no function called "If" either. But syntax check errors always come first.
Switeck wrote:
Now has addShips changed since v1.76?
No. The format has always been system.addShips(role, number, positionVector, radius)
Switeck wrote:
08:58:14.718 [station.launchShip.failed]: Cancelled launch for a Cobra Mark III with role trader, as it is too large for the docking port of the TransHab Station.
08:58:14.734 [station.launchShip.failed]: Cancelled launch for a Cobra Mark III with role trader, as it is too large for the docking port of the TransHab Station.
08:58:14.734 [station.launchShip.failed]: Cancelled launch for a Cobra Mark I with role sunskim-trader, as it is too large for the docking port of the TransHab Station.


I've seen that on other stations as well, so I'm not sure it's a TransHab Station problem.
The TransHab does have a smaller docking bay than most stations, but I'm surprised it can't launch a Cobra I. I'll take a look at it when I get a moment.
Switeck
---- E L I T E ----
---- E L I T E ----
Posts: 2411
Joined: Mon May 31, 2010 11:11 pm

Re: Scripters cove

Post by Switeck »

So 2 false alarms out of 3 so far...and the jury's still out on the 3rd. :oops:
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Re: Scripters cove

Post by Eric Walch »

Switeck wrote:
Now has addShips changed since v1.76?
The change was from 1.74 -> 1.75 where the new Java engine was added. Before both System and system could be used, so you probably had code from those days.

About the 'If': Wen you use a code editor that supports JavaScript, it will colorise all keywords, so that such errors are spotted immediately on typing.
User avatar
Gouanaco
Competent
Competent
Posts: 47
Joined: Sun Oct 06, 2013 8:21 am
Location: Aus

Re: Scripters cove

Post by Gouanaco »

Hey Im abit new here, and i would really like to start making oxps or start learning how to.
I looked around and didnt see any really helpful tutorials some of them were incomplete and few in number.

So could someone point me in the right derection or supplie me with something :D
Im looking forward to making some oxps.

(Just to let you know)
I dont know any java-script and i dont know any XML :/ ( i know a small amount of some other languages though)
I'm ok at sound/music.
I have some moderate skill in modelling. ( i think)
etc

And thanks in advance here's 4@ credits.
Commander: Gouanaco
Ship: { Cobra Mark III }
Galaxy: [1]
Legal Status: Clean
Rating: Average (63)
Career: Trader/Bounty Hunter
Cash: 12 956.4@ (credits)
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 »

Hi, yes the current tutorial is way out of date and shouldn't be relied on.
The Wiki OXP HowTo page is a good place to start. OXPs consist of a series of folders (Config, Models, Scripts etc) which are self-explanatory really. Models need to be in a .dat format, textures should be .png files and the rest are property lists (plists) which these days are written in openStep (rather than the old XML) which is a nice easy human-friendly format. Scripts are in javascript (not Java!) and there is a reference here for them. Use .ogg for sounds.
The best way to learn is to look at a few existing OXPs to see how they work - try to find up to date ones which are maintained though as drawing on older ones may lead you astray :(
And feel free to ask here if you have any questions. Good luck with it all :)
Commander Smivs, the friendliest Gourd this side of Riedquat.
User avatar
Gouanaco
Competent
Competent
Posts: 47
Joined: Sun Oct 06, 2013 8:21 am
Location: Aus

Re: Scripters cove

Post by Gouanaco »

Thanks :D
I have heaps of oxps installed so i should be able to find some and tinker with them until i know how to make my own.
But really someone should post a oxp guide :)
Would be really helpful.
Last edited by Gouanaco on Mon Oct 07, 2013 12:49 pm, edited 1 time in total.
Commander: Gouanaco
Ship: { Cobra Mark III }
Galaxy: [1]
Legal Status: Clean
Rating: Average (63)
Career: Trader/Bounty Hunter
Cash: 12 956.4@ (credits)
User avatar
Cody
Sharp Shooter Spam Assassin
Sharp Shooter Spam Assassin
Posts: 16081
Joined: Sat Jul 04, 2009 9:31 pm
Location: The Lizard's Claw
Contact:

Re: Scripters cove

Post by Cody »

Gouanaco wrote:
And thanks in advance here's 4@ credits.
Gouanaco wrote:
But really someone should post a oxp guide Would be really helpful.
<chortles> What do you expect for four credits?
I would advise stilts for the quagmires, and camels for the snowy hills
And any survivors, their debts I will certainly pay. There's always a way!
User avatar
Gouanaco
Competent
Competent
Posts: 47
Joined: Sun Oct 06, 2013 8:21 am
Location: Aus

Re: Scripters cove

Post by Gouanaco »

Cody wrote:
Gouanaco wrote:
And thanks in advance here's 4@ credits.
Gouanaco wrote:
But really someone should post a oxp guide Would be really helpful.
<chortles> What do you expect for four credits?
haha lol... wait what?
I was serious about the guide :P
Commander: Gouanaco
Ship: { Cobra Mark III }
Galaxy: [1]
Legal Status: Clean
Rating: Average (63)
Career: Trader/Bounty Hunter
Cash: 12 956.4@ (credits)
User avatar
Gouanaco
Competent
Competent
Posts: 47
Joined: Sun Oct 06, 2013 8:21 am
Location: Aus

Re: Scripters cove

Post by Gouanaco »

I need some elp!...

When i want to start writing scripts for OXPs.

Can all of the scripts just be written in openStep which i think is actually called GNUstep?

Because JavaScript i have no experience in...

If i can do all the scripts in just GNU/OpenStep then ill should be able to start making oxps very soon.

:D
Commander: Gouanaco
Ship: { Cobra Mark III }
Galaxy: [1]
Legal Status: Clean
Rating: Average (63)
Career: Trader/Bounty Hunter
Cash: 12 956.4@ (credits)
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 »

openStep is used for the property lists (plists) not scripting. The scripts use javascript (js). Best thing is to look at examples - try the game's in-built scripts first - then go to the js reference pages
Commander Smivs, the friendliest Gourd this side of Riedquat.
User avatar
Norby
---- E L I T E ----
---- E L I T E ----
Posts: 2577
Joined: Mon May 20, 2013 9:53 pm
Location: Budapest, Hungary (Mainly Agricultural Democracy, TL10)
Contact:

Re: Scripters cove

Post by Norby »

Gouanaco wrote:
Because JavaScript i have no experience in...
It is an easy language, check a tutorial without the html-related parts. I used functions often from a few objects only: Array, Math and String.

The larger part is to learn the Oolite specific usage from the Scripting Oolite with JavaScript wiki pages which would be new in any language so you are not so behind the new OXPers with good js knowledge.
Just read through all of these and then ask about the "dark side". ;)
User avatar
Gouanaco
Competent
Competent
Posts: 47
Joined: Sun Oct 06, 2013 8:21 am
Location: Aus

Re: Scripters cove

Post by Gouanaco »

Norby wrote:
Gouanaco wrote:
Because JavaScript i have no experience in...
It is an easy language, check a tutorial without the html-related parts. I used functions often from a few objects only: Array, Math and String.

The larger part is to learn the Oolite specific usage from the Scripting Oolite with JavaScript wiki pages which would be new in any language so you are not so behind the new OXPers with good js knowledge.
Just read through all of these and then ask about the "dark side". ;)

ok cool thx lol :D
Hopefully i can learn enough soon enough to be able to make something worthy :)
Commander: Gouanaco
Ship: { Cobra Mark III }
Galaxy: [1]
Legal Status: Clean
Rating: Average (63)
Career: Trader/Bounty Hunter
Cash: 12 956.4@ (credits)
Post Reply