Oolite Bulletins

For information and discussion about Oolite.
It is currently Wed Aug 16, 2017 5:33 pm

All times are UTC




Post new topic  Reply to topic  [ 59 posts ]  Go to page Previous 1 2 3 4 Next
Author Message
PostPosted: Sun Jul 27, 2014 4:42 pm 
Offline
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
User avatar

Joined: Fri Nov 11, 2011 6:19 pm
Posts: 4008
Quote:
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).

_________________
OXPs: [EliteWiki] New Cargoes, [EliteWiki] Skilled NPCs, [EliteWiki] Curse of the Black Sunspot, and more


Top
   
PostPosted: Sun Jul 27, 2014 4:57 pm 
Offline
---- E L I T E ----
---- E L I T E ----
User avatar

Joined: Mon Apr 06, 2009 12:20 pm
Posts: 6178
Location: Aboard the Pitviper S.E. "Blackwidow"
Quote:
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


Top
   
PostPosted: Sun Jul 27, 2014 5:16 pm 
Offline
---- E L I T E ----
---- E L I T E ----
User avatar

Joined: Sat Jun 11, 2011 6:07 am
Posts: 2161
Location: Western Australia
Quote:
Quote:
Now there's a novel concept.. actually learn the language *before* you start scripting... ;-)
:shock: 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.


Top
   
PostPosted: Sun Jul 27, 2014 5:17 pm 
Offline
---- E L I T E ----
---- E L I T E ----

Joined: Sat May 31, 2014 9:02 pm
Posts: 288
Location: Melbourne, Australia
Quote:
Quote:
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. :-))

- Neelix

_________________
Talaxian Enterprises: [wiki]Vacuum Pump[/wiki] [wiki]Waypoint Here[/wiki]


Top
   
PostPosted: Sun Jul 27, 2014 5:23 pm 
Offline
---- E L I T E ----
---- E L I T E ----
User avatar

Joined: Sat Jun 11, 2011 6:07 am
Posts: 2161
Location: Western Australia
Quote:
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.


Top
   
PostPosted: Sun Jul 27, 2014 5:48 pm 
Offline
---- E L I T E ----
---- E L I T E ----

Joined: Sat May 31, 2014 9:02 pm
Posts: 288
Location: Melbourne, Australia
Quote:
Quote:
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. :-)

- Neelix

_________________
Talaxian Enterprises: [wiki]Vacuum Pump[/wiki] [wiki]Waypoint Here[/wiki]


Top
   
PostPosted: Sun Jul 27, 2014 6:18 pm 
Offline
---- E L I T E ----
---- E L I T E ----
User avatar

Joined: Wed Aug 15, 2012 4:19 am
Posts: 2444
Location: Finland
Quote:
Or a full version of One Hundred Bottles of Beer on the Wall? :twisted:
Heh. Link it to your cargo manifest and after each round substract 1 TC of booze. The song would then be called "One Hundred TCs of Beer in the Hold".


Top
   
PostPosted: Sun Jul 27, 2014 6:25 pm 
Offline
---- E L I T E ----
---- E L I T E ----

Joined: Tue Nov 09, 2010 1:44 pm
Posts: 1393
Quote:
Quote:
Or a full version of One Hundred Bottles of Beer on the Wall? :twisted:
Heh. Link it to your cargo manifest and after each round substract 1 TC of booze. The song would then be called "One Hundred TCs of Beer in the Hold".
LOL ROTFL


Top
   
PostPosted: Sun Jul 27, 2014 6:46 pm 
Offline
Dangerous
Dangerous
User avatar

Joined: Thu Nov 18, 2010 6:08 am
Posts: 85
Location: United States
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...


Top
   
PostPosted: Sun Jul 27, 2014 6:52 pm 
Offline
---- E L I T E ----
---- E L I T E ----
User avatar

Joined: Wed Aug 15, 2012 4:19 am
Posts: 2444
Location: Finland
Quote:
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...
Here you go.


Top
   
PostPosted: Sun Jul 27, 2014 6:54 pm 
Offline
Retired Assassin
Retired Assassin
User avatar

Joined: Tue Feb 09, 2010 11:31 am
Posts: 8272
Location: Disunited Kingdom
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 8)

_________________
Commander Smivs, the friendliest Gourd this side of Riedquat.


Top
   
PostPosted: Sun Jul 27, 2014 7:11 pm 
Offline
---- E L I T E ----
---- E L I T E ----

Joined: Sat May 31, 2014 9:02 pm
Posts: 288
Location: Melbourne, Australia
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.)

The best way to search the boards is using the browser search plugin.

- Neelix

_________________
Talaxian Enterprises: [wiki]Vacuum Pump[/wiki] [wiki]Waypoint Here[/wiki]


Top
   
PostPosted: Sun Jul 27, 2014 7:39 pm 
Offline
---- E L I T E ----
---- E L I T E ----
User avatar

Joined: Sat Jun 11, 2011 6:07 am
Posts: 2161
Location: Western Australia
Quote:
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!")

Is the sort of thing you want.


Top
   
PostPosted: Sun Jul 27, 2014 9:31 pm 
Offline
Dangerous
Dangerous
User avatar

Joined: Thu Nov 18, 2010 6:08 am
Posts: 85
Location: United States
If anyone else is interested in this OXP, I have updated it a little and redubbed it version 0.2.

Changes:
  • It now lists the passenger's name and destination when the passenger speaks (instead of just saying "Passenger: ...")
  • If there is more than one passenger, it randomly selects one to speak.
  • When you leave the station, there is a 1 and 3 chance that a passenger will say, "Off we go!".
  • When a passenger speaks, a distinctive beeping sound is made.
Download it here: Noisy Passengers v0.2


Top
   
PostPosted: Sun Jul 27, 2014 9:54 pm 
Offline
---- E L I T E ----
---- E L I T E ----
User avatar

Joined: Fri May 30, 2014 4:07 pm
Posts: 827
Nice! If I ever get passenger space, I'll be sure to try it :D

_________________
--
Image
Pilot: Mossfoot - Ship ID: Viaticus Rex (Cobra MKII)
Rank: Competent - Status: Clean

http://www.noahchinnbooks.com/


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 59 posts ]  Go to page Previous 1 2 3 4 Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
Powered by phpBB® Forum Software © phpBB Limited