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

Scripting requests

An area for discussing new ideas and additions to Oolite.

Moderators: another_commander, winston

User avatar
Svengali
Commander
Commander
Posts: 2370
Joined: Sat Oct 20, 2007 2:52 pm

Re: Scripting requests

Post by Svengali »

Could we get an option to set light position and color in mission.runScreen? Maybe even with the possibility to change it on-the-fly? I'm aware that we can pass them to the shader, but writable properties which can be bound are rare.

Image

Edit:Updated pic.
User avatar
spara
---- E L I T E ----
---- E L I T E ----
Posts: 2676
Joined: Wed Aug 15, 2012 4:19 am
Location: Finland

Re: Scripting requests

Post by spara »

I want to set materials for a ship using a ship script. Currently I can easily do that in shipSpawned event. That however, does not work when the ship is being displayed on mission screen.

Ideally I would like to have an ship script event shipDisplayed with a suitable handle to the ship model, that would trigger when a ship is being shown.
cag
Deadly
Deadly
Posts: 197
Joined: Fri Mar 17, 2017 1:49 am

Re: Scripting requests

Post by cag »

- be able to provide a destination for data to reduce garbage generation

1) calls to filteredEntities or entitiesWithScanClass return arrays, thus generate garbage
- if I could supply an array as a parameter for the result, there'd be no garbage to be collected
(ok, that's a bad solution, how about a separate method?)

[Aside: I replaced a single call to filteredEntities with 11 to entitiesWithScanClass, as that was much faster. But the former creates 3.43 x's as much garbage! filteredEntities must be creating JS objects rather than core ones, no?}

2) during frame callbacks, I often refer to .position & .orientation data, which genereate garbage
- if I could provide a Vector3D object (or better still, an array) for the data to be copied to, no garbage is created

Also, are there any pre-determined garbage collection calls? I'm recycling arrays to reduce how many I create and if I know when a pre-determined GC will occur, I can purge some if my pool gets too big. I currently do purge much in shipWillDockWithStation & shipWillEnterWitchspace on the assumption GC may happen but knowing actually when/if might be helpful.
"Better to be thought a fool, boy, than to open your trap and remove all doubt." - Grandma [over time, just "Shut your trap... fool"]
"The only stupid questions are the ones you fail to ask." - Dad
How do I...? Nevermind.
cag
Deadly
Deadly
Posts: 197
Joined: Fri Mar 17, 2017 1:49 am

Re: Scripting requests

Post by cag »

I'd like programatic access to the data logged by console.writeJSMemoryStats():
JS heap, limit, # collections to date
- really only need the 1st but with fine resolution (not MiB)
- it could be used to monitor rate of production, isolate which areas are responsible
"Better to be thought a fool, boy, than to open your trap and remove all doubt." - Grandma [over time, just "Shut your trap... fool"]
"The only stupid questions are the ones you fail to ask." - Dad
How do I...? Nevermind.
Astrobe
---- E L I T E ----
---- E L I T E ----
Posts: 609
Joined: Sun Jul 21, 2013 12:26 pm

Re: Scripting requests

Post by Astrobe »

cag wrote: Tue Oct 17, 2017 1:51 am
Also, are there any pre-determined garbage collection calls? I'm recycling arrays to reduce how many I create and if I know when a pre-determined GC will occur, I can purge some if my pool gets too big. I currently do purge much in shipWillDockWithStation & shipWillEnterWitchspace on the assumption GC may happen but knowing actually when/if might be helpful.
https://bb.oolite.space/viewtopic.ph ... 45#p259439
cag
Deadly
Deadly
Posts: 197
Joined: Fri Mar 17, 2017 1:49 am

Re: Scripting requests

Post by cag »

D'oh! Perfectly demonstrates the value of a wiki over BB. I must've scrolled past that a number of times, it's so small. Such a declarative and authoritative statement
should be writ large,
don't you think? :D

Anyway, it doesn't appear to matter if you use
  • shipWillDockWithStation or shipDockedWithStation
  • shipWillExitWitchspace or shipExitedWitchspace,
as they're invoked on consecutive lines in the code. The is no shipEnteredWitchspace, so all that remains is
  • shipWillLaunchFromStation or shipLaunchedFromStation
which would only concern station based oxp's (and really, how much garbage can they generate!)

Unless you can think of a problem, I suggest the wiki advise purges/freeing be done in the 'Will' events, to keep is simple & consistent.
"Better to be thought a fool, boy, than to open your trap and remove all doubt." - Grandma [over time, just "Shut your trap... fool"]
"The only stupid questions are the ones you fail to ask." - Dad
How do I...? Nevermind.
User avatar
Svengali
Commander
Commander
Posts: 2370
Joined: Sat Oct 20, 2007 2:52 pm

Re: Scripting requests

Post by Svengali »

Can we get a mouseclick event on missionscreens, which passes mouse coordinates, pleeeeaaase?

spara wrote:
I want to set materials for a ship using a ship script. Currently I can easily do that in shipSpawned event. That however, does not work when the ship is being displayed on mission screen.
It's already possible to change materials/shaders on mission screens.
User avatar
montana05
---- E L I T E ----
---- E L I T E ----
Posts: 1166
Joined: Mon May 30, 2016 3:54 am
Location: lurking in The Devils Triangle (G1)

Re: Scripting requests

Post by montana05 »

Just a suggestion of mine, including defense_ship_roles similar to escort_roles would make life easier. I am aware that a script could do the same trick easy so its just an idea.

On the other hand I tired scan_description for certain groups and the result was all the time that the game earlier or later crashed, usually while exiting whitchspace with a lot ships of this group waiting ahead.
Scars remind us where we've been. They don't have to dictate where we're going.
User avatar
spara
---- E L I T E ----
---- E L I T E ----
Posts: 2676
Joined: Wed Aug 15, 2012 4:19 am
Location: Finland

Re: Scripting requests

Post by spara »

Svengali wrote:
spara wrote:
I want to set materials for a ship using a ship script. Currently I can easily do that in shipSpawned event. That however, does not work when the ship is being displayed on mission screen.
It's already possible to change materials/shaders on mission screens.
You indeed can change materials on mission screen. And I actually heavily utilized that with those card games I did a long time ago. I had to scratch my head quite a bit to remember what this was all about. It's about a different way to do ship variants. Traditionally one like_ships a core ship and it's roles and in the process changes the distribution balance of different ships. I was experimenting with the idea of changing the livery via script rather than defining oodles of new ships. I actually managed to attach the livery to the personality of the ship. The show stopper was different mission screens in various OXPs that show some random ship and some missions regarding it. I could not get my hands on those because there is practically no hook to the model displayed on the mission screen. Or it would have needed some serious hacking.
User avatar
Svengali
Commander
Commander
Posts: 2370
Joined: Sat Oct 20, 2007 2:52 pm

Re: Scripting requests

Post by Svengali »

You are right. If the entity does not explicitely declare materials in shipdata.plist you get an empty object via getMaterials().
User avatar
Svengali
Commander
Commander
Posts: 2370
Joined: Sat Oct 20, 2007 2:52 pm

Re: Scripting requests

Post by Svengali »

Can we get a script method to check if an image or texture file exists, please? :wink:
User avatar
Phasted
Competent
Competent
Posts: 51
Joined: Wed Jun 09, 2010 3:56 pm

Re: Scripting requests

Post by Phasted »

When it's convenient, I'd like to see an event handler that triggers when the Player scans a wormhole (passing the wormhole object). :D
User avatar
Reval
---- E L I T E ----
---- E L I T E ----
Posts: 402
Joined: Thu Oct 29, 2020 3:14 am
Location: At home in the Xexedi Cluster, driving an FE Asp II, Laenina's Flux.

Re: Scripting requests

Post by Reval »

Having briefly brought this request up elsewhere, I thought this might be the more appropriate topic for it.

Proposal is to be able to set the current speed of the player ship.

Useful (to me, at least) because on leaving space-dock, one is currently forced to bring the ship to full speed manually. I'd like to be able to have my ship's speed set to full automatically, perhaps via a simple OXP, thereby obviating need for the tedious pressing of 'w' every time I launch from station...

I realize this only applies to keyboard players. On a joystick with throttle lever this can be permanantly maxed and the problem does not apply. But I believe a lot of people still play keyboard only, so this would help them.
Dor 'call me Grocer' Reval (a Xexedian Laver) was always considered a little backward.
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6559
Joined: Wed Feb 28, 2007 7:54 am

Re: Scripting requests

Post by another_commander »

Reval wrote: Sun Nov 01, 2020 12:59 am
Proposal is to be able to set the current speed of the player ship.

Useful (to me, at least) because on leaving space-dock, one is currently forced to bring the ship to full speed manually. I'd like to be able to have my ship's speed set to full automatically, perhaps via a simple OXP, thereby obviating need for the tedious pressing of 'w' every time I launch from station...
I am not convinced this is a good idea. Even if we do let scripts change the player ship's speed, it is very likely that the player will do something to counter the effect (that something being straightforward piloting most of the times). Also, it is very jarring for players having the ship do things that they did not specifically request, with the exception of docking autopilot, of course. Finally, it is not as simple a task to code as it looks. Changing any ship's current speed on a whim may interfere with the physics of the game, so it is really a load of effort for very little (if any) gain.

If you want full speed upon launching, you can easily achieve that with a single keypress: press injectors for just a split second after launching and your ship will hit top speed right away.
User avatar
Reval
---- E L I T E ----
---- E L I T E ----
Posts: 402
Joined: Thu Oct 29, 2020 3:14 am
Location: At home in the Xexedi Cluster, driving an FE Asp II, Laenina's Flux.

Re: Scripting requests

Post by Reval »

Understood. And thanks for the injector tip.
Dor 'call me Grocer' Reval (a Xexedian Laver) was always considered a little backward.
Post Reply