I am currently going through an interactive Javascript tutorial through CodeAcademy so that I know what I am doing. I have programmed in many different languages so it seems pretty easy so far. Then I will take your skeleton script and make it into something you can be proud of!
You'll probably find [wiki]Oolite_JavaScript_object_model[/wiki] useful as well, if you've not seen it yet - API reference for all in-game JS objects and events.
Things to watch compared with C++: variable scoping, the meaning of the "this" variable not always being quite what you might expect (in callback functions, especially).
Now there's a novel concept.. actually learn the language before you start scripting..
That's what they call "being logical"..
Logic
log·ic [loj-ik]
noun
1. A system for going wrong, with confidence.
Most games have some sort of paddling-pool-and-water-wings beginning to ease you in: Oolite takes the rather more Darwinian approach of heaving you straight into the ocean, often with a brick or two in your pockets for luck. ~ Disembodied
Now there's a novel concept.. actually learn the language *before* you start scripting...
Can you actually do that!
Yeah. Murphy was always trying to encourage me to actually learn about javascript, but I valiantly resisted. I was always asking him to indent properly, which he equally resisted.
Now there's a novel concept.. actually learn the language before you start scripting..
That's what they call "being logical"..
Logic
log·ic [loj-ik]
noun
1. A system for going wrong, with confidence.
hrm... *shrugs* I think I do well enough at that on my own... (most recently with the pre-release version of Waypoint Here, I was trying to compare two Vector3Ds with the comparison operator in the waypoint removal code. it took me a fair amount of time and troubleshooting before I twigged as to why the conditional never executed. )
I was trying to compare two Vector3Ds with the comparison operator in the waypoint removal code. it took me a fair amount of time and troubleshooting before I twigged as to why the conditional never executed. )
Go on, tell us why the conditional never executed. We know you want to. I was outclassed as soon as you wrote Vector3D.
I was trying to compare two Vector3Ds with the comparison operator in the waypoint removal code. it took me a fair amount of time and troubleshooting before I twigged as to why the conditional never executed. )
Go on, tell us why the conditional never executed. We know you want to. I was outclassed as soon as you wrote Vector3D.
It was because I was comparing two different objects, and was testing if they were the same object, (which of course they were not) rather than testing if the two objects had the same values (which in some cases they did)
It's like writing numbers on two slips of paper, then checking if they are both on the same piece of paper, instead of checking if the same numbers are written on both.
Luckily there's already a handy dandy function which calculates the distance (difference) between the two, so it was an easy fix once I knew what I was doing wrong. My point though was that I was completely confident that my code should have worked... so was somewhat mystified when it didn't.
Does anyone know where I can post questions about Oolite-specific functions? I think I got the javascript part of it down well enough (Being a programmer already, its not too difficult for me to pick up a new language), but there's somethings I don't know about the Javascript API. The reference provided above helps a bit, but I can't figure out how to get your passengers name. I thought it may be under the Mission class, but that definitely wasn't the case...
Does anyone know where I can post questions about Oolite-specific functions? I think I got the javascript part of it down well enough (Being a programmer already, its not too difficult for me to pick up a new language), but there's somethings I don't know about the Javascript API. The reference provided above helps a bit, but I can't figure out how to get your passengers name. I thought it may be under the Mission class, but that definitely wasn't the case...
Probably the Expansions Pack forum. Just start a new thread with a clear title. I'm always asking (often daft) questions there - it can be educational for others
Commander Smivs, the friendliest Gourd this side of Riedquat.
I tend to use the search box on the left of the wiki page and search for (for this example) "JavaScript passenger"
Then check out all the javascript reference pages that get returned for what I'm looking for.
If that doesn't help searching the forums sometimes does. (I found an excellent example of a condition script in the middle of the Scripters Cove thread for example.)
Does anyone know where I can post questions about Oolite-specific functions? I think I got the javascript part of it down well enough (Being a programmer already, its not too difficult for me to pick up a new language), but there's somethings I don't know about the Javascript API. The reference provided above helps a bit, but I can't figure out how to get your passengers name. I thought it may be under the Mission class, but that definitely wasn't the case...
You should have noticed player.ship.passengers in the shipLaunchedFromStation function.
player.consoleMessage(player.ship.passengers[1].name + ": I want to get off!")