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

Manipulating the interface through key presses and events

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

Moderators: winston, another_commander

Post Reply
unteer
Average
Average
Posts: 8
Joined: Mon Oct 19, 2009 5:53 am
Location: Mombasa, Kenya
Contact:

Manipulating the interface through key presses and events

Post by unteer »

Hello Everybody,

My first post/thread has gone so well in under 24 hours, that I have decided to start another one, slightly related, but different enough to warrant a new topic.

My research into the inner workings of Oolite has been minimal in the grand scheme of things, but I want to clarify some of my findings, so anyone willing to help would be greatly appreciated.

First off, are we unable to handle key press events in the javascript engine? I have poured over certain areas of the documentation to no avail, and sadly google is also of little help. Basically, is there a way to trigger a script based simply on a keypress such as hitting the ENTER key. I can understand why this might be difficult and conflict with the key events already in place.

If this is not the case, how are interface manipulating scripts handled. I know that the HyperRadio OXP scripts in a listener for a dance between F7 and F1. Must all listeners be this way, triggered by obscure dance maneuvers over key presses that log global events?

Is it possible to modify the keyconfig plist and construct new events for which your script can listen?

I would like to take a crack at the oolite source code, but my internet connection (being in africa) does not allow such luxury as downloading large (>3 MB) files. Maybe later.

Thoughts?

Cheers!
"Any sufficiently advanced technology is indistinguishable from magic." -Arthur C. Clarke's Third Law of Prediction
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6570
Joined: Wed Feb 28, 2007 7:54 am

Post by another_commander »

Brief answer is that no, we cannot handle keypress events from within Oolite's JavaScript API. I believe the best that can be done is check for some specific keypresses indirectly, using the switch screens events, in a way similar to what you refer to as keyboard dance. I think there could also be some security related concerns if we somehow allow keypress events to be triggered. Anyway, the current SpiderMonkey does not give us this capability.
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Post by Commander McLane »

Hi, unteer! And first of all welcome to the boards, and of course to this great game! :D

And let me take this opportunity to extend a special welcome to another East African resident! :D :D :D (I am located roughly 900 km west-north-west from you).

To your question: No, there is currently no way to detect keypresses by script, and AFAIK there are no plans into that direction. (EDIT: a_c beat e to that one.) Only the engine itself can handle keypresses. One reason is that so many of us scripters would like to get our hands on keypress-listening, but who would decide to which new functions the (rare) spare keys would be assigned? And who would sign the "Sorry, your request for a keypress was the 15th, but we have only 14 keys at our disposal."-letters?

Therefore there are only workarounds. One used by some scripts is to create a pylon-mounted special equipment, which, if fired like a missile, causes the script to do what you want. Drawback: Each of this quasi-keypresses costs the player one of his valuable missile pylons.

The other workaround is more elegant: convince the developers to include your functionality into the next release of Oolite itself (has happened before, in case of the Advanced Navigational Array; or with the yaw-keys). :wink: Although that ain't easy, of course.
unteer
Average
Average
Posts: 8
Joined: Mon Oct 19, 2009 5:53 am
Location: Mombasa, Kenya
Contact:

Post by unteer »

thanks everyone again for being so helpful. I have been pleasantly suprised by the friendliness of the folks on these boards and in the cOomunity. I just won't mention operating systems here because that seems to evoke ire in even the best of us on the web, no matter the circumstances.

So Oolite runs Spidermonkey eh? A complete version of it or modularized? Duly noted :)

On the note of the missiles, and sorry that this is a total newb question, but can you select which missile to fire? I am not completely opposed to this method, but in general i don't think my system is going to work anyways if there is zero way to intercept key presses.
"Any sufficiently advanced technology is indistinguishable from magic." -Arthur C. Clarke's Third Law of Prediction
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Post by Commander McLane »

unteer wrote:
On the note of the missiles, and sorry that this is a total newb question, but can you select which missile to fire?
Yes, if you have bought the Multi Targeting System (vanilla Oolite equipment item).
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6570
Joined: Wed Feb 28, 2007 7:54 am

Post by another_commander »

unteer wrote:
So Oolite runs Spidermonkey eh? A complete version of it or modularized? Duly noted :)
A complete version of SpiderMonkey 1.7 is used, with the following specifications:
1) JS_C_STRINGS_ARE_UTF8 is defined.
2) MOZILLA_1_8_BRANCH is not defined.
3) JS_THREADSAFE is not defined.
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"

Post by Diziet Sma »

unteer wrote:
I just won't mention operating systems here because that seems to evoke ire in even the best of us on the web, no matter the circumstances.
Hi unteer, and welcome to the boards! So far as operating systems go, we have Macintosh, WinPC and Linux users all happily co-existing and, surprising as it may seem, actively co-operating and assisting each other.. so feel free to mention OS if you see fit... :D
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
Disembodied
Jedi Spam Assassin
Jedi Spam Assassin
Posts: 6883
Joined: Thu Jul 12, 2007 10:54 pm
Location: Carter's Snort

Post by Disembodied »

Diziet Sma wrote:
So far as operating systems go, we have Macintosh, WinPC and Linux users all happily co-existing and, surprising as it may seem, actively co-operating and assisting each other.. so feel free to mention OS if you see fit... :D
Yes, it's the Commodore 64 – ZX Spectrum feuds you've got to watch out for! :D
User avatar
DaddyHoggy
Intergalactic Spam Assassin
Intergalactic Spam Assassin
Posts: 8512
Joined: Tue Dec 05, 2006 9:43 pm
Location: Newbury, UK
Contact:

Post by DaddyHoggy »

unteer wrote:
thanks everyone again for being so helpful. I have been pleasantly suprised by the friendliness of the folks on these boards and in the cOomunity. I just won't mention operating systems here because that seems to evoke ire in even the best of us on the web, no matter the circumstances.

So Oolite runs Spidermonkey eh? A complete version of it or modularized? Duly noted :)

On the note of the missiles, and sorry that this is a total newb question, but can you select which missile to fire? I am not completely opposed to this method, but in general i don't think my system is going to work anyways if there is zero way to intercept key presses.
Quite the contrary here - Oolite started on a Mac and was ported to Linux and PC - lots of people discover quirks in Oolite caused by one OS/Platform but not found in the others (tricky for one OS oxp developers) and different OS users usually dive in to beta test for OXP creators.

Me, I run Oolite on XP, Vista, Ubuntu (Gutsy and Jaunty) - in my 3 years on the board (ok, I had a year off in the middle!) I've never seen any flaming concerning OS or platform and even the vaguest of trolling is done in jest or is very quickly squished.

So fear not, the only things that get BBQ'd here are trumbles and spammers.
Selezen wrote:
Apparently I was having a DaddyHoggy moment.
Oolite Life is now revealed here
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"

Post by Diziet Sma »

Disembodied wrote:
Diziet Sma wrote:
So far as operating systems go, we have Macintosh, WinPC and Linux users all happily co-existing and, surprising as it may seem, actively co-operating and assisting each other.. so feel free to mention OS if you see fit... :D
Yes, it's the Commodore 64 – ZX Spectrum feuds you've got to watch out for! :D
Not to mention the "BBC: the original and the best" proponents! 8)
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
Kaks
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 3009
Joined: Mon Jan 21, 2008 11:41 pm
Location: The Big Smoke

Post by Kaks »

<OT>
Disembodied wrote:
Yes, it's the Commodore 64 – ZX Spectrum feuds you've got to watch out for! :D
Speccy forever!!!one!!!1one!!!

PS: My only regret is never to have driven a C5! :)

PPS: Normal transmissions will be resumed shortly.
</OT>
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
Chrisfs
---- E L I T E ----
---- E L I T E ----
Posts: 433
Joined: Sun Sep 20, 2009 10:24 am
Location: California

Post by Chrisfs »

Commander McLane wrote:
unteer wrote:
On the note of the missiles, and sorry that this is a total newb question, but can you select which missile to fire?
Yes, if you have bought the Multi Targeting System (vanilla Oolite equipment item).
Even with out that pressing 'Y' allows you to cyle through missles in order to choose which will be fired next.
unteer
Average
Average
Posts: 8
Joined: Mon Oct 19, 2009 5:53 am
Location: Mombasa, Kenya
Contact:

Post by unteer »

thanks all for the helpful replies. Will see if this can be worked into a system somehow.
"Any sufficiently advanced technology is indistinguishable from magic." -Arthur C. Clarke's Third Law of Prediction
Post Reply