Page 69 of 117
Re: Scripters cove
Posted: Thu Jun 20, 2013 1:29 pm
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?
Re: Scripters cove
Posted: Thu Jun 20, 2013 1:33 pm
by cim
The condition-testing keyword in Javascript is if
not If
. Other than that the code you've posted looks fine.
Re: Scripters cove
Posted: Thu Jun 20, 2013 2:33 pm
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.
Re: Scripters cove
Posted: Thu Jun 20, 2013 2:49 pm
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.
Re: Scripters cove
Posted: Thu Jun 20, 2013 3:15 pm
by Switeck
So 2 false alarms out of 3 so far...and the jury's still out on the 3rd.
Re: Scripters cove
Posted: Sat Jun 22, 2013 2:10 pm
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.
Re: Scripters cove
Posted: Mon Oct 07, 2013 10:26 am
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
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.
Re: Scripters cove
Posted: Mon Oct 07, 2013 10:57 am
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
Re: Scripters cove
Posted: Mon Oct 07, 2013 12:44 pm
by Gouanaco
Thanks
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.
Re: Scripters cove
Posted: Mon Oct 07, 2013 12:47 pm
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?
Re: Scripters cove
Posted: Mon Oct 07, 2013 12:52 pm
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
Re: Scripters cove
Posted: Thu Oct 10, 2013 12:48 pm
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.
Re: Scripters cove
Posted: Thu Oct 10, 2013 1:11 pm
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
Re: Scripters cove
Posted: Thu Oct 10, 2013 1:45 pm
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".
Re: Scripters cove
Posted: Thu Oct 10, 2013 1:53 pm
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
Hopefully i can learn enough soon enough to be able to make something worthy