Noob Scripter Question

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

Moderators: winston, another_commander

Vaztr
Above Average
Above Average
Posts: 28
Joined: Tue Jul 13, 2010 3:31 am
Location: ACT Australia
Contact:

Noob Scripter Question

Post by Vaztr »

Hi All,

Long time lurker, first time poster.

I'm just wondering if those with large brains can point me at a 'scripting OXP's for noobs' post/page/site etc.

I'm looking to script an OXP that adds a small piece of equipment to the player ship that I would find invaluable.

Any and all help is appreciated.

VAZ
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 »

Hello, Vaztr & welcome to the board, we're apparently the friendliest this side of Riedquat...

Unfortunately writing such a step-by-step guide, in one go, could take a very long time to do, so I don't quite know if/when any of the more knowledgeable board members will get the time to do just that...

Your best option is to grab a bunch of the equipent oxps, see how they do things, then ask a couple of specific questions about things that are a bit above your head...

Once thost first couple of problems are sorted, move on to the next questions, etc... that way we might just possibly build such a guide on this very thread, bit by bit.

Hope this helps.
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
User avatar
Disembodied
Jedi Spam Assassin
Jedi Spam Assassin
Posts: 6885
Joined: Thu Jul 12, 2007 10:54 pm
Location: Carter's Snort

Post by Disembodied »

There's always the How To pages on the wiki, to get you started.
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 »

Another "Hi!" from another scripter. :D

Unfortunately there is no real guide for noobs. But it is certainly a good idea to have a look into existing OXPs (or the scripts that come with Oolite, in /Oolite/Contents/Resources/Config and /Oolite/Contents/Resources/Scripts).

Basicly you have to learn the general syntax of the languages used (plists for static information, like shipdata, or equipment; and JavaScript for scripts), and then of course the specific commands that you can use. The latter is documented in the Elite Wiki, specifically in all pages collected in the Category:Oolite_scripting and the Category:Oolite_JavaScript_Reference category pages.

Please do start with the howTo-pages and follow the links to more information. If you then have more specific questions, feel free to ask here on the boards, which have the distincion of being the friendliest this side of Riedquat™, so in most cases you will have a fairly profound answer fairly quick. :wink:

So, for now there is only one thing left to say:

Right On, Commander! :D
Vaztr
Above Average
Above Average
Posts: 28
Joined: Tue Jul 13, 2010 3:31 am
Location: ACT Australia
Contact:

Post by Vaztr »

Thanx All,

I'm not new to scripting (whew - that's a start) but Oolite has it's own idiosyncracies that I'll have to get familiar with.

I've started pulling apart 'Fuel Tank' by Ramirez as this has some elements that will be common to my OXP.

My first quickie - what part of the scripts defines the keypress that 'enables' the 'feature'?

Thanx

VAZ
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 »

The fuel tank - and any similar one-use equipment - tells the engine it's a special type of mine/bomb/external tank, so to activate it, you need to 'fire' it: press Y to select the fuel tank as the active 'mine/bomb', then press M...
Last edited by Kaks on Fri Aug 06, 2010 8:12 am, edited 1 time in total.
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
Vaztr
Above Average
Above Average
Posts: 28
Joined: Tue Jul 13, 2010 3:31 am
Location: ACT Australia
Contact:

Post by Vaztr »

Bugger,

That's exaclty what I don't want!!

I need to add a new (unused) keypress to enable the new feature.

Guess I'll grab a different OXP to try
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Post by Thargoid »

Don't bother - capturing keypresses and assigning (unused) keys isn't currently possible for OXPs.

The only way to manually trigger something is having it pylon-mounted as a missile/mine, as described above.
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 »

Yep, capturing keypresses is a much requested feature, but we haven't devised a system yet to avoid possible clashes between different OXPs trying to access the same key...

:(
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
User avatar
DaddyHoggy
Intergalactic Spam Assassin
Intergalactic Spam Assassin
Posts: 8515
Joined: Tue Dec 05, 2006 9:43 pm
Location: Newbury, UK
Contact:

Post by DaddyHoggy »

Kaks wrote:
Yep, capturing keypresses is a much requested feature, but we haven't devised a system yet to avoid possible clashes between different OXPs trying to access the same key...

:(
I think I suggested before that to avoid keypress clashes a single keypress could perhaps be assigned to pull up a configurable scroll down menu - so people who have lots of equipment based OXPs can put their most used equipment near the top of the list and useful but little used at the bottom. Selecting your equipment would then clear the list off the screen.

I'm guessing that would be a lot of work to fudge the current GUI?
Selezen wrote:
Apparently I was having a DaddyHoggy moment.
Oolite Life is now revealed here
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 »

I don't think there would be a way to avoid clashes in the long run.

It is because our scripters are just too ingenious. Before long they would have scripted more things to activate by keypress than there are actual keys on a keyboard (and let's not forget that quite some keys are already used).

Therefore at least for the we-install-all-OXPs-no-matter-what-faction of Oolite players the clash would be inevitable.

Therefore: no keypresses for equipment.
User avatar
DaddyHoggy
Intergalactic Spam Assassin
Intergalactic Spam Assassin
Posts: 8515
Joined: Tue Dec 05, 2006 9:43 pm
Location: Newbury, UK
Contact:

Post by DaddyHoggy »

Commander McLane wrote:
I don't think there would be a way to avoid clashes in the long run.

It is because our scripters are just too ingenious. Before long they would have scripted more things to activate by keypress than there are actual keys on a keyboard (and let's not forget that quite some keys are already used).

Therefore at least for the we-install-all-OXPs-no-matter-what-faction of Oolite players the clash would be inevitable.

Therefore: no keypresses for equipment.
Which is why I keep suggesting a scrolly selection list for OXP equipment...
Selezen wrote:
Apparently I was having a DaddyHoggy moment.
Oolite Life is now revealed here
User avatar
maik
Wiki Wizard
Wiki Wizard
Posts: 2025
Joined: Wed Mar 10, 2010 12:30 pm
Location: Ljubljana, Slovenia (mainly industrial, feudal, TL12)

Post by maik »

Commander McLane wrote:
Therefore at least for the we-install-all-OXPs-no-matter-what-faction of Oolite players the clash would be inevitable.
Inevitable yes, but so is our doom when the sun explodes. ;-)

What could go a long way until then would be the following suggestion:
Don't allow OXPs to define their own keys (except for a suggestion for a key), but only to register that they need a key or two. On the configuration screen you would then allow to assign keys to native functions as well as functions registered by OXPs and in the key handler route the key press event accordingly. Considering that you have modifiers like alt, shift, control, and any combination of these you can define a lot of keys for a lot of equipment.

Caveat: That was a bold shot from the hip, hope it doesn't miss by much :roll:
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 »

DaddyHoggy wrote:
I think I suggested before that to avoid keypress clashes a single keypress could perhaps be assigned to pull up a configurable scroll down menu - so people who have lots of equipment based OXPs can put their most used equipment near the top of the list and useful but little used at the bottom. Selecting your equipment would then clear the list off the screen.
I think I don't get your point here.

We are not talking about managing or viewing all your equipment, but about activating any (OXP-)equipment by a keypress.

Or do you suggest that there should be a single pre-defined key for all possible OXP-equipments, which would not directly activate any equipment, but open a scroll-down list from which you would choose?

Example: Let's for a moment presume that this method would work for the cloaking device as well: You are in the middle of a battle and you want to cloak. You would press "0", but you wouldn't cloak instantly; instead you would get some sort of menu. Even if we leave the question aside whether the game around you would be automatically paused while you have this menu in front of your eyes (and without auto-pause you would probably be dead before you even had scrolled down to the correct menu item), how immersive would that be? For me it would break the flow of the game every time I want to activate (or de-activate) something. In the extreme case you would have to go through a scroll-down menu every time you want to accelerate, or pitch, or roll, or fire your laser. That would be just silly.

Of course all those are basic features of Oolite, and nobody would even propose to make them dependent on a scroll-down menu. But basically the same is valid for OXP-added items. Pausing the game in order to for instance activate a fuel tank, or whatever item a scripter may come up with, strikes me as impractical and breaking the immersion. I wouldn't want it.
User avatar
DaddyHoggy
Intergalactic Spam Assassin
Intergalactic Spam Assassin
Posts: 8515
Joined: Tue Dec 05, 2006 9:43 pm
Location: Newbury, UK
Contact:

Post by DaddyHoggy »

Commander McLane wrote:
DaddyHoggy wrote:
I think I suggested before that to avoid keypress clashes a single keypress could perhaps be assigned to pull up a configurable scroll down menu - so people who have lots of equipment based OXPs can put their most used equipment near the top of the list and useful but little used at the bottom. Selecting your equipment would then clear the list off the screen.
I think I don't get your point here.

We are not talking about managing or viewing all your equipment, but about activating any (OXP-)equipment by a keypress.

Or do you suggest that there should be a single pre-defined key for all possible OXP-equipments, which would not directly activate any equipment, but open a scroll-down list from which you would choose?

Example: Let's for a moment presume that this method would work for the cloaking device as well: You are in the middle of a battle and you want to cloak. You would press "0", but you wouldn't cloak instantly; instead you would get some sort of menu. Even if we leave the question aside whether the game around you would be automatically paused while you have this menu in front of your eyes (and without auto-pause you would probably be dead before you even had scrolled down to the correct menu item), how immersive would that be? For me it would break the flow of the game every time I want to activate (or de-activate) something. In the extreme case you would have to go through a scroll-down menu every time you want to accelerate, or pitch, or roll, or fire your laser. That would be just silly.

Of course all those are basic features of Oolite, and nobody would even propose to make them dependent on a scroll-down menu. But basically the same is valid for OXP-added items. Pausing the game in order to for instance activate a fuel tank, or whatever item a scripter may come up with, strikes me as impractical and breaking the immersion. I wouldn't want it.
Direct as ever Cmd McL - I find it odd that you consider this to be immersive breaking suggestion and yet are happy to accept that every piece of equipment that has to be activated requires a pylon mount which then must be cycled through to select the one you want anyway!

All I was suggesting - based on your own example is:

(User has edited a text based config file prior to playing the game that puts his cloaking device at the top of the list, his fuel pod second, etc...)

During the battle you want to activate your cloak, hit 0, this pulls up the menu on the screen (game is not paused - this is a UI that is part of the ship's console the same as the scanner or anything else on screen - to keep it immersive) - the first item is auto-selected - this happens to be your most used piece of equipment as you decided earlier - you hit return (or some other key) - the cloak is turned on - the menu disappears.

The cloak is eating your power reserves and the battle is not yet over - so you hit 0 again pull up the menu, scroll down one item (this will need another key I concede) and select your fuel pod, your fuel is topped up, enough to put your injectors to good use, you hit return, the fuel pod is activated and the menu disappears.

You bang on your injectors to escape and while doing so, hit 0 a final time, the first item on the list is, as before, pre-selected, hit return and your cloak is deactivated, allowing your energy to build up while you escape the pirates on injectors.

Four keys required - a key to call up the menu, a key to scroll down the menu, a key to scroll up the menu, and one to select the chosen item.

It is up to the pilot to decide the order of the items on the menu - this is a tactical decision based on how you play and what equipment you carry, no more difficult to do than selecting pylons (which I consider an immersion breaker).
Selezen wrote:
Apparently I was having a DaddyHoggy moment.
Oolite Life is now revealed here
Post Reply