Join us at the Oolite Anniversary Party -- London, 7th July 2024, 1pm
More details in this thread.

Talking to passengers

An area for discussing new ideas and additions to Oolite.

Moderators: another_commander, winston

User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: Talking to passengers

Post by cim »

byronarn wrote:
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).
User avatar
Diziet Sma
---- E L I T E ----
---- E L I T E ----
Posts: 6311
Joined: Mon Apr 06, 2009 12:20 pm
Location: Aboard the Pitviper S.E. "Blackwidow"

Re: Talking to passengers

Post by Diziet Sma »

Neelix wrote:
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
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2290
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia

Re: Talking to passengers

Post by Wildeblood »

Smivs wrote:
Neelix wrote:
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.
Neelix
---- E L I T E ----
---- E L I T E ----
Posts: 288
Joined: Sat May 31, 2014 9:02 pm
Location: Melbourne, Australia

Re: Talking to passengers

Post by Neelix »

Diziet Sma wrote:
Neelix wrote:
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]
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2290
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia

Re: Talking to passengers

Post by Wildeblood »

Neelix wrote:
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.
Neelix
---- E L I T E ----
---- E L I T E ----
Posts: 288
Joined: Sat May 31, 2014 9:02 pm
Location: Melbourne, Australia

Re: Talking to passengers

Post by Neelix »

Wildeblood wrote:
Neelix wrote:
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]
User avatar
spara
---- E L I T E ----
---- E L I T E ----
Posts: 2676
Joined: Wed Aug 15, 2012 4:19 am
Location: Finland

Re: Talking to passengers

Post by spara »

mossfoot wrote:
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".
Zireael
---- E L I T E ----
---- E L I T E ----
Posts: 1396
Joined: Tue Nov 09, 2010 1:44 pm

Re: Talking to passengers

Post by Zireael »

spara wrote:
mossfoot wrote:
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
User avatar
byronarn
Dangerous
Dangerous
Posts: 85
Joined: Thu Nov 18, 2010 6:08 am
Location: United States

Re: Talking to passengers

Post by byronarn »

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...
User avatar
spara
---- E L I T E ----
---- E L I T E ----
Posts: 2676
Joined: Wed Aug 15, 2012 4:19 am
Location: Finland

Re: Talking to passengers

Post by spara »

byronarn wrote:
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.
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Re: Talking to passengers

Post by Smivs »

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

Re: Talking to passengers

Post by Neelix »

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]
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2290
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia

Re: Talking to passengers

Post by Wildeblood »

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

Re: Talking to passengers

Post by byronarn »

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
User avatar
mossfoot
---- E L I T E ----
---- E L I T E ----
Posts: 827
Joined: Fri May 30, 2014 4:07 pm
Contact:

Re: Talking to passengers

Post by mossfoot »

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/
Post Reply