Page 51 of 117

Re: Scripters cove

Posted: Fri Aug 10, 2012 7:38 am
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...

Re: Scripters cove

Posted: Fri Aug 10, 2012 2:07 pm
by Thargoid
You may also want to look at my cargo shepherd OXP, as that is also in a similar vein perhaps.

Re: Scripters cove

Posted: Sat Aug 11, 2012 3:37 am
by Rese249er
I'll take a look...

Re: Scripters cove

Posted: Wed Aug 15, 2012 5:00 am
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.

Re: Scripters cove

Posted: Wed Aug 15, 2012 7:13 am
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.

Re: Scripters cove

Posted: Sun Sep 16, 2012 3:47 am
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.

Re: Scripters cove

Posted: Sun Sep 16, 2012 4:03 am
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.

Re: Scripters cove

Posted: Sun Sep 16, 2012 5:23 am
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.

Re: Scripters cove

Posted: Sun Sep 16, 2012 5:48 am
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.

Re: Scripters cove

Posted: Sun Sep 16, 2012 11:47 am
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.

Re: Scripters cove

Posted: Sun Sep 16, 2012 11:53 am
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.

Re: Scripters cove

Posted: Sun Sep 16, 2012 3:34 pm
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.

Re: Scripters cove

Posted: Wed Sep 19, 2012 2:44 pm
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... :)

Re: Scripters cove

Posted: Wed Sep 19, 2012 3:17 pm
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.

Re: Scripters cove

Posted: Wed Sep 19, 2012 3:57 pm
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. :(