Scripters cove
Moderators: winston, another_commander
- Rese249er
- ---- E L I T E ----
- Posts: 647
- Joined: Thu Jun 07, 2012 2:19 pm
- Location: Well, I WAS in G3...
Re: Scripters cove
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...
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?
Re: Scripters cove
You may also want to look at my cargo shepherd OXP, as that is also in a similar vein perhaps.
My OXPs via Boxspace or from my Wiki pages .
Thargoid TV
Dropbox Referral Link
Thargoid TV
Dropbox Referral Link
- Rese249er
- ---- E L I T E ----
- Posts: 647
- Joined: Thu Jun 07, 2012 2:19 pm
- Location: Well, I WAS in G3...
Re: Scripters cove
I'll take a look...
Got all turned around, lost my nav connection... Where am I now?
- Wildeblood
- ---- E L I T E ----
- Posts: 2453
- Joined: Sat Jun 11, 2011 6:07 am
- Location: Western Australia
- Contact:
Re: Scripters cove
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.
- Tricky
- ---- E L I T E ----
- Posts: 821
- Joined: Sun May 13, 2012 11:12 pm
- Location: Bradford, UK. (Anarchic)
Re: Scripters cove
I don't think it is exposed to Javascript, however if you look at the 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.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.
- Tricky
- ---- E L I T E ----
- Posts: 821
- Joined: Sun May 13, 2012 11:12 pm
- Location: Bradford, UK. (Anarchic)
Re: Scripters cove
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.
Code: Select all
this.playerAttackedOther = function(other)
{
// Your code here
}
Code: Select all
this.playerFiredMissile = function(missile, target)
{
// Your code here
}
Really difficult to work out if the player is actively in combat without these.
- Wildeblood
- ---- E L I T E ----
- Posts: 2453
- Joined: Sat Jun 11, 2011 6:07 am
- Location: Western Australia
- Contact:
Re: Scripters cove
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
One of the few player, not playerShip, properties.
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)
- Tricky
- ---- E L I T E ----
- Posts: 821
- Joined: Sun May 13, 2012 11:12 pm
- Location: Bradford, UK. (Anarchic)
Re: Scripters cove
shipAttackedOther in the worldScript only triggers on NPC's attacking players. I've tried that method.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.One of the few player, not playerShip, properties.Code: Select all
if (player.alertHostiles)
- Wildeblood
- ---- E L I T E ----
- Posts: 2453
- Joined: Sat Jun 11, 2011 6:07 am
- Location: Western Australia
- Contact:
Re: Scripters cove
It worked for my death ray. Too well, in fact. I suspect you're thinking of shipBeingAttacked.Tricky wrote:shipAttackedOther in the worldScript only triggers on NPC's attacking players. I've tried that method.Wildeblood wrote:shipAttackedOther ... See also:-
https://bb.oolite.space/viewtopic.php?f=3&t=12491
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
Re: Scripters cove
It should be easy to copy theTricky 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.
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 = ......
UPS-Courier & DeepSpacePirates & others at the box and some older versions
- Tricky
- ---- E L I T E ----
- Posts: 821
- Joined: Sun May 13, 2012 11:12 pm
- Location: Bradford, UK. (Anarchic)
Re: Scripters cove
Ah yes. I stand corrected.Wildeblood wrote:It worked for my death ray. Too well, in fact. I suspect you're thinking of shipBeingAttacked.Tricky wrote:shipAttackedOther in the worldScript only triggers on NPC's attacking players. I've tried that method.Wildeblood wrote:shipAttackedOther ... See also:-
https://bb.oolite.space/viewtopic.php?f=3&t=12491
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
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.
- Commander McLane
- ---- 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
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.Tricky wrote:There is a really un-helpful helpful AI message...You can't even get the AI to trigger on it.Code: Select all
AGGRESSOR_SWITCHED_TARGET id1 id2
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
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...
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...
- Commander McLane
- ---- 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
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 Manifest-object.
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 Manifest-object.
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.Rocketman wrote:For example, AITradingAssistant OXP uses manually written prices. This makes it potentially incompatible with any other XPs wich modify commodities.
- Wildeblood
- ---- E L I T E ----
- Posts: 2453
- Joined: Sat Jun 11, 2011 6:07 am
- Location: Western Australia
- Contact:
Re: Scripters cove
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.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...