Scripting requests

An area for discussing new ideas and additions to Oolite.

Moderators: winston, another_commander

User avatar
Svengali
---- E L I T E ----
---- E L I T E ----
Posts: 2365
Joined: Sat Oct 20, 2007 2:52 pm

Re: Scripting requests

Post by Svengali » Sun Mar 20, 2016 10:49 pm

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: 2552
Joined: Wed Aug 15, 2012 4:19 am
Location: Finland

Re: Scripting requests

Post by spara » Mon Jul 24, 2017 11:16 am

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
Dangerous
Dangerous
Posts: 85
Joined: Fri Mar 17, 2017 1:49 am

Re: Scripting requests

Post by cag » Tue Oct 17, 2017 1:51 am

- 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
Dangerous
Dangerous
Posts: 85
Joined: Fri Mar 17, 2017 1:49 am

Re: Scripting requests

Post by cag » Tue Oct 17, 2017 2:42 am

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: 596
Joined: Sun Jul 21, 2013 12:26 pm

Re: Scripting requests

Post by Astrobe » Tue Oct 17, 2017 5:07 pm

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.
http://www.aegidian.org/bb/viewtopic.ph ... 45#p259439

cag
Dangerous
Dangerous
Posts: 85
Joined: Fri Mar 17, 2017 1:49 am

Re: Scripting requests

Post by cag » Tue Oct 17, 2017 11:48 pm

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
---- E L I T E ----
---- E L I T E ----
Posts: 2365
Joined: Sat Oct 20, 2007 2:52 pm

Re: Scripting requests

Post by Svengali » Fri Jan 19, 2018 11:21 am

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: 272
Joined: Mon May 30, 2016 3:54 am

Re: Scripting requests

Post by montana05 » Fri Jan 19, 2018 2:32 pm

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.
Trying to survive behind the controls of a Caduceus Psi XT in Alpha test :lol:

User avatar
spara
---- E L I T E ----
---- E L I T E ----
Posts: 2552
Joined: Wed Aug 15, 2012 4:19 am
Location: Finland

Re: Scripting requests

Post by spara » Fri Jan 19, 2018 4:31 pm

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
---- E L I T E ----
---- E L I T E ----
Posts: 2365
Joined: Sat Oct 20, 2007 2:52 pm

Re: Scripting requests

Post by Svengali » Fri Jan 19, 2018 5:48 pm

You are right. If the entity does not explicitely declare materials in shipdata.plist you get an empty object via getMaterials().

User avatar
Svengali
---- E L I T E ----
---- E L I T E ----
Posts: 2365
Joined: Sat Oct 20, 2007 2:52 pm

Re: Scripting requests

Post by Svengali » Mon Mar 19, 2018 10:43 am

Can we get a script method to check if an image or texture file exists, please? :wink:

User avatar
Phasted
Competent
Competent
Posts: 48
Joined: Wed Jun 09, 2010 3:56 pm

Re: Scripting requests

Post by Phasted » Fri Aug 09, 2019 6:34 pm

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

Post Reply