Scripting requests

An area for discussing new ideas and additions to Oolite.

Moderators: winston, another_commander

User avatar
Cmd. Cheyd
---- E L I T E ----
---- E L I T E ----
Posts: 934
Joined: Tue Dec 16, 2008 2:52 pm
Location: Deep Horizon Industries Manufacturing & Research Site somewhere in G8...

Post by Cmd. Cheyd »

If I'm overlooking it, or am ignorant of some restriction or method, please let me know... But could the planetinfo.plist properties of Corona Flare, Corona Hue, Corona Shimmer, Sun Color be exposed to Javascript?
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 »

Cmd. Cheyd wrote:
If I'm overlooking it, or am ignorant of some restriction or method, please let me know... But could the planetinfo.plist properties of Corona Flare, Corona Hue, Corona Shimmer, Sun Color be exposed to Javascript?
you can set them with

Code: Select all

system.info.corona_flare=1;
and

Code: Select all

System.infoForSystem(0, 55).sun_color='blueColor';

Changes to sun's properties are only applied after a system jump, but I'll look into applying them immediately to the current system.

I'm not entirely sure how to retrieve the system info in js, though.
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
User avatar
Cmd. Cheyd
---- E L I T E ----
---- E L I T E ----
Posts: 934
Joined: Tue Dec 16, 2008 2:52 pm
Location: Deep Horizon Industries Manufacturing & Research Site somewhere in G8...

Post by Cmd. Cheyd »

If it's writable as your example shows, that's what I need. :) Will test it out.
User avatar
Rustybolts
---- E L I T E ----
---- E L I T E ----
Posts: 293
Joined: Sun Jun 07, 2009 6:22 pm
Location: UK

Post by Rustybolts »

Im wanting to be able to find out if player ship is using witchdrive injector if so i want to run some code if condition is met.
my test code

Code: Select all

if (player.ship.maxSpeed > 1.0) 
{ 
    player.commsMessage("Works"); 
}
Doesn't work (i assume 1 is the maximum this indicator goes) so is there another way of doing this, if not consider this a suggestion.
The same would apply for jump drive if this is also not possible to detect.
STE.+ Firefly/Dragonfly + BlackJacksbullion v.1.23 link below.
http://www.mediafire.com/?sharekey=ca16 ... f6e8ebb871
Image
User avatar
Frame
---- E L I T E ----
---- E L I T E ----
Posts: 1477
Joined: Fri Mar 30, 2007 8:32 am
Location: Witchspace

Post by Frame »

apparently this is being dscussed in another topic


{
//do whatever
}
[/code]

However, you cannot be sure of that the ship is using injectores, when exceeding the max speed it can use the torus drive too

So you need to calculate the ratio of the speed for all ships in question..

Injector speed has a max factor of 7.0. if it goes above that, and the ship is not using injector, but the torus drive..

now I'm not going to serve it all on a silver plate, it is after all, your script, I told you what you need to do, but not how to do it.. ;-)

Cheers Frame
Bounty Scanner
Number 935
User avatar
Rustybolts
---- E L I T E ----
---- E L I T E ----
Posts: 293
Joined: Sun Jun 07, 2009 6:22 pm
Location: UK

Post by Rustybolts »

For what i wanted it for it needed to be a event handler. At the moment i can only call the code via tickle.
STE.+ Firefly/Dragonfly + BlackJacksbullion v.1.23 link below.
http://www.mediafire.com/?sharekey=ca16 ... f6e8ebb871
Image
zevans
---- E L I T E ----
---- E L I T E ----
Posts: 332
Joined: Mon Jul 06, 2009 11:12 pm
Location: Uncharted backwaters of the unfashionable end of the western spiral arm

Post by zevans »

Well, I guess you could post a request here for the long term...
https://bb.oolite.space/viewtopic.php?t=3296

You want a way to be notified of engaging injectors or engaging jump drive - and depending on why you're doing it, you might also want to be notified if time acceleration is switched on? Do I have that right?
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Post by Thargoid »

Minor request for 1.74, could the station parameter be added to this.shipLaunchedFromStation in the same way that it is present in this.shipWillLaunchFromStation? So we can have an entity reference of the station the ship launched from, without having to use shipWillLaunch and store it in a script variable?
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post by JensAyton »

At the time shipLaunchedFromStation() is called, the game no longer knows which station it was launched from. Although we could add (yet another) variable to the player to track that, it’s actually more efficient for scripts to do it themselves if they need it – scripts can delete their variables when they’re not needed any longer, native code can’t.
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Post by Thargoid »

Fairy snuff, it just always seemed a fairly awkward way of doing it in scripting to have to have one event set a variable to pass-down to the other event. But if that's actually the most efficient way of doing it then so be it...
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6682
Joined: Wed Feb 28, 2007 7:54 am

Post by another_commander »

Done on SVN2448. I used the nearestEntityMatchingPredicate method to name the station that is closest to a ship at the time of its launch. So far tested and looks OK. The theory behind this is that, when a ship is in STATUS_LAUNCHING (or is executing launching updates in the case of player ship), the nearest station to said ship has to be the one it launched from. Some further testing will be needed.
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post by JensAyton »

Epic lateral thinking. I suspect you’ll find that a carrier finds itself, though. Fix: ANDPredicate(NOTPredicate(IsShipPredicate)), IsStationPredicate). Wow, gotta give myself a pat on the back for building that stuff. :-)
Last edited by JensAyton on Wed Oct 07, 2009 7:55 pm, edited 1 time in total.
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 »

Following my trials and tribulations up to here, I'd like to know: Is there a good reason that the shipWasScooped and shipScoopedOther handlers do not fire if the scooped entity is an escape pod?

If not, I request that escape pods be included to the list of scooped entities that cause the handler to fire, without setting their cargo_type to CARGO_SCRIPTED_ITEM. Because that effectively turns them into cargopods, not escape pods anymore.
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 »

A way to clear a ship's target via JS. (Or tell me how it is done, I can't figure it out.)

this.ship.target = null doesn't do anything and is reported as an error, same for this.ship.target = "". I guess that is because it actually points to another ship, which can't be nullified.

Therefore another way to reset the target of an NPC (or even the player) is needed. Probably a method.

It should trigger the "TARGET_LOST" message in the AI.
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 »

A new event handler shipFiredMissile(missile,target), sent to the firing ship, both player and NPC. Should return the missile entity and the target the missile was fired at.
Post Reply