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

Scripters cove

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

Moderators: winston, another_commander

User avatar
Rese249er
---- E L I T E ----
---- E L I T E ----
Posts: 647
Joined: Thu Jun 07, 2012 2:19 pm
Location: Well, I WAS in G3...

Re: Scripters cove

Post by Rese249er »

Aaand yet again I rip Okti's code for my nefarious purposes.

EDIT: Well... it's got some kinda functionality... GrappleBeamv0.2 is available for download... I'm really not sure how I managed to make it work with such limited effect...
Got all turned around, lost my nav connection... Where am I now?
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5525
Joined: Thu Jun 12, 2008 6:55 pm

Re: Scripters cove

Post by Thargoid »

You may also want to look at my cargo shepherd OXP, as that is also in a similar vein perhaps.
User avatar
Rese249er
---- E L I T E ----
---- E L I T E ----
Posts: 647
Joined: Thu Jun 07, 2012 2:19 pm
Location: Well, I WAS in G3...

Re: Scripters cove

Post by Rese249er »

I'll take a look...
Got all turned around, lost my nav connection... Where am I now?
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2321
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia

Re: Scripters cove

Post by Wildeblood »

How do I check within a script whether any particular commodity is on the illegal goods list? Currently I have firearms, slaves and narcotics hard-coded in Trading Assistant, but like most things in Oolite the illegal goods list is easily re-configured.
User avatar
Tricky
---- E L I T E ----
---- E L I T E ----
Posts: 821
Joined: Sun May 13, 2012 11:12 pm
Location: Bradford, UK. (Anarchic)

Re: Scripters cove

Post by Tricky »

Wildeblood wrote:
How do I check within a script whether any particular commodity is on the illegal goods list? Currently I have firearms, slaves and narcotics hard-coded in Trading Assistant, but like most things in Oolite the illegal goods list is easily re-configured.
I don't think it is exposed to Javascript, however if you look at the [EliteWiki] Illegal Goods Tweak OXP, specifically illegal_goods_tweak.js in the Scripts directory, you will get an idea as to how you could handle it.
User avatar
Tricky
---- E L I T E ----
---- E L I T E ----
Posts: 821
Joined: Sun May 13, 2012 11:12 pm
Location: Bradford, UK. (Anarchic)

Re: Scripters cove

Post by Tricky »

Any chance of these 2 world script events?

Code: Select all

this.playerAttackedOther = function(other)
{
     // Your code here
}

Code: Select all

this.playerFiredMissile = function(missile, target)
{
     // Your code here
}
Similar to shipAttackedOther and shipFiredMissile ship events.

Really difficult to work out if the player is actively in combat without these.
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2321
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia

Re: Scripters cove

Post by Wildeblood »

shipAttackedOther will work in a worldScript, the wiki is confused/confusing in the way it lists playerShip events, some on the worldScripts page, some on the ship scripts page. See also:-
https://bb.oolite.space/viewtopic.php?f=3&t=12491
Tricky wrote:
Really difficult to work out if the player is actively in combat without these.

Code: Select all

if (player.alertHostiles)
One of the few player, not playerShip, properties.
User avatar
Tricky
---- E L I T E ----
---- E L I T E ----
Posts: 821
Joined: Sun May 13, 2012 11:12 pm
Location: Bradford, UK. (Anarchic)

Re: Scripters cove

Post by Tricky »

Wildeblood wrote:
shipAttackedOther will work in a worldScript, the wiki is confused/confusing in the way it lists playerShip events, some on the worldScripts page, some on the ship scripts page. See also:-
https://bb.oolite.space/viewtopic.php?f=3&t=12491
Tricky wrote:
Really difficult to work out if the player is actively in combat without these.

Code: Select all

if (player.alertHostiles)
One of the few player, not playerShip, properties.
shipAttackedOther in the worldScript only triggers on NPC's attacking players. I've tried that method.
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2321
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia

Re: Scripters cove

Post by Wildeblood »

Tricky wrote:
Wildeblood wrote:
shipAttackedOther ... See also:-
https://bb.oolite.space/viewtopic.php?f=3&t=12491
shipAttackedOther in the worldScript only triggers on NPC's attacking players. I've tried that method.
It worked for my death ray. Too well, in fact. I suspect you're thinking of shipBeingAttacked.
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Re: Scripters cove

Post by Eric Walch »

Tricky wrote:
Any chance of these 2 world script events?
Similar to shipAttackedOther and shipFiredMissile ship events.

Really difficult to work out if the player is actively in combat without these.
It should be easy to copy the shipAttackedOther and shipFiredMissile ship events into the shipscript of the player. In that case they only will fire for the player :)

e.g.

Code: Select all

player.ship.script.shipAttackedOther = ......
But, as Tricky writes, it can also be used in the worldscript.
User avatar
Tricky
---- E L I T E ----
---- E L I T E ----
Posts: 821
Joined: Sun May 13, 2012 11:12 pm
Location: Bradford, UK. (Anarchic)

Re: Scripters cove

Post by Tricky »

Wildeblood wrote:
Tricky wrote:
Wildeblood wrote:
shipAttackedOther ... See also:-
https://bb.oolite.space/viewtopic.php?f=3&t=12491
shipAttackedOther in the worldScript only triggers on NPC's attacking players. I've tried that method.
It worked for my death ray. Too well, in fact. I suspect you're thinking of shipBeingAttacked.
Ah yes. I stand corrected.

Still, the above suggested functions would be advantageous. There is a really un-helpful helpful AI message...

Code: Select all

AGGRESSOR_SWITCHED_TARGET id1 id2
You can't even get the AI to trigger on it.

The only way I can think of checking for that is setting up a frame call-back and check the AI message state of the NPC.
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:

Re: Scripters cove

Post by Commander McLane »

Tricky wrote:
There is a really un-helpful helpful AI message...

Code: Select all

AGGRESSOR_SWITCHED_TARGET id1 id2
You can't even get the AI to trigger on it.

The only way I can think of checking for that is setting up a frame call-back and check the AI message state of the NPC.
It's quite useful (and needed) for what it does, but it's not meant to trigger the AI. Think of it as an internal AI message. You cannot use it meaningfully, because the two ID numbers are part of the message, and there is no way in the world to foresee which unique IDs will be involved when the message is sent.
Rocketman
Poor
Poor
Posts: 5
Joined: Wed Sep 19, 2012 11:28 am

Re: Scripters cove

Post by Rocketman »

Hello! Is there possibility to access basic game propetries initialized in config .plist files (such as commodities.plist, for instance) by extention pack JS scripts? I walked trough Oolite JavaScript Reference but didn't find solution.

For example, AITradingAssistant OXP uses manually written prices. This makes it potentially incompatible with any other XPs wich modify commodities. I'am pretty sure that there may be a lot of other similar examples.

Isn't that good reason to make such global properties lists reachable by scripts? Or that is already done and I simply didn't find it in manuals?

P.S. english is not my native language, so I'am sorry for any incovenience caused... :)
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:

Re: Scripters cove

Post by Commander McLane »

Hi, Rocketman, and first of all welcome to the Friendliest Board This Side Of Riedquat™!

Indeed, most of the properties defined in the various plists are exposed to the JS-scripting engine. There are a few exceptions, mainly because something hasn't been implemented yet. Unfortunately, commodities.plist is among these exceptions.

You can, however, access the cargo currently carried by the player via the Image Manifest-object.
Rocketman wrote:
For example, AITradingAssistant OXP uses manually written prices. This makes it potentially incompatible with any other XPs wich modify commodities.
This isn't necessarily a bad thing, though. As far as I understand, the AITradingAssistant is specifically written for the default price ranges in main stations. Thus, it cannot be expected to be compatible with OXPs that change the default price ranges in main stations. I am not aware of any OXP that changes this default, anyway.
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2321
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia

Re: Scripters cove

Post by Wildeblood »

Rocketman wrote:
Hello! Is there possibility to access basic game propetries initialized in config .plist files (such as commodities.plist, for instance) by extention pack JS scripts? I walked trough Oolite JavaScript Reference but didn't find solution.

For example, AITradingAssistant OXP uses manually written prices. This makes it potentially incompatible with any other XPs wich modify commodities. I'am pretty sure that there may be a lot of other similar examples.

Isn't that good reason to make such global properties lists reachable by scripts? Or that is already done and I simply didn't find it in manuals?

P.S. english is not my native language, so I'am sorry for any incovenience caused... :)
Most (but not all) of the properties in shipdata.plist and planetinfo.plist can be accessed by scripts. Most of the rest of the configuration is hidden. That's just the way it is. :(
Post Reply