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: 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 »

Okay. That was my fallback idea. I was going to do it with a 1px x 2px image.
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5525
Joined: Thu Jun 12, 2008 6:55 pm

Post by Thargoid »

Can I request a this.gameWillSave(type) world script function that triggers just before a save-game (type = auto, quick or standard for the different types of save-game).

For use to refresh mission variables etc just before a save-game to ensure that they are up to date, especially when the MV is used to encode something else like an array to make it persistent.
Ragged
Above Average
Above Average
Posts: 28
Joined: Mon Jun 29, 2009 10:55 am

Post by Ragged »

Can we have a way to set an absolute colour of the sun, please, without the 50% white admixture.

Mainly because a black sun with a red corona will make a passable black hole.
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6574
Joined: Wed Feb 28, 2007 7:54 am

Post by another_commander »

Thargoid wrote:
Can I request a this.gameWillSave(type) world script function that triggers just before a save-game (type = auto, quick or standard for the different types of save-game).

For use to refresh mission variables etc just before a save-game to ensure that they are up to date, especially when the MV is used to encode something else like an array to make it persistent.
Done. Taken from the commit comments of r3746:
Added the playerWillSaveGame script event handler, taking as parameter the type of savegame, which can be standardSave, autoSave or quickSave.
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5525
Joined: Thu Jun 12, 2008 6:55 pm

Post by Thargoid »

Thank you :)

Whilst I'm in this thread, would it be possible for this.shipFiredMissile to trigger for mines (_MINE) as well as missiles? At the moment I can't see a way to reliably detect a ship launching a mine (or in the case I'm trying to do to detect when they have nothing left on their pylons) without using a timer and a check on player.ship.missiles.length.

And as I'm in a demanding mood tonight, how about a this.shipAwardedEquipment(equipment) triggered when a ship is script-awarded a piece of equipment (as opposed to the player buying it triggering this.playerBoughtEquipment which doesn't get triggered by a script-award).
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5525
Joined: Thu Jun 12, 2008 6:55 pm

Post by Thargoid »

another_commander wrote:
Done. Taken from the commit comments of r3746:
Added the playerWillSaveGame script event handler, taking as parameter the type of savegame, which can be standardSave, autoSave or quickSave.
Berlios still seems to be on 3745 (from 3rd Sept)? Has something gone wrong with the distribution or update?
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6574
Joined: Wed Feb 28, 2007 7:54 am

Post by another_commander »

Thargoid wrote:
Berlios still seems to be on 3745 (from 3rd Sept)? Has something gone wrong with the distribution or update?
Actually, Berlios is on 3747 at the moment. The problem seems to be the server distributing the nightly builds. Hopefully Getafix will take care of it soon.
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5525
Joined: Thu Jun 12, 2008 6:55 pm

Post by Thargoid »

A thought leading on from this discussion. Would it be possible to have a new event function (e.g. this.scriptsLoaded or something nicer) that is executed once all scripts have been loaded. To be used for example to check whether a particular script (and so OXP) is loaded, for either dependency or incompatibility checking.

We can use a timer run from this.startUp to check for dependencies etc, but having the function above would be nicer and cleaner as you wouldn't have to guess what length the timer would need to be.
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Post by Eric Walch »

Thargoid wrote:
.....as you wouldn't have to guess what length the timer would need to be.
The internal clock is not updated during handler execution, so a time of 0 seconds should be enough to load last. Or use 0.1 when in doubt of equality, that last value always worked for me.
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5525
Joined: Thu Jun 12, 2008 6:55 pm

Post by Thargoid »

One semi-oddity.

By script we can set position for entities, but seemingly not sub-entities attached to one (ie you can't move a sub-ent around relative to its main mother entity). Orientation/rotation works, but position seems fixed?

Is there a specific reason for that, or could such functionality be added? That would open up some interesting ideas for ships and OXPs...
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 »

Err, I don't seem to have any problems moving the position of subentities, at least in trunk...
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5525
Joined: Thu Jun 12, 2008 6:55 pm

Post by Thargoid »

Didn't seem to work for me in 1.74.2 last night.

Maybe I did something wrong - will check again tonight with that and also with a trunk set-up.
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Post by Eric Walch »

Thargoid wrote:
Didn't seem to work for me in 1.74.2 last night.

Maybe I did something wrong - will check again tonight with that and also with a trunk set-up.
It should have worked in 1.74. I used it in the past sometimes to quickly find a nice position to put my subentities on ships. That suitable position found I added to shipdata. (Works much faster than restarting Oolite everytime after changing shipdata)
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5525
Joined: Thu Jun 12, 2008 6:55 pm

Post by Thargoid »

I think I see where I went wrong in the scripting. Will test tonight and then begin to ponder what else can be done with this functionality :twisted:
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 »

An AI method to attach a script to a ship.

Reason: As we know, the full possibilities of AI scripting are only open in combination with ship scripts. However, it is a little tricky to attach a ship script to a ship if you have no access to its shipdata. For instance, if you want to create a modified version of route1traderAI which sends script messages. It is impractical or plainly impossible to insert a script-key into the shipdata of all ships which may get route1traderAI. Even if you would create and maintain a monstrous shipdata-overrides.plist, what if someone else would want to attach a different script snippet to the ships? The overrides would override each other.

But what if the AI itself, in the very moment it starts, could amend the ship script itself? I have no idea if that's even possible, but it would be extremely useful. I could imagine a method with a js-file as parameter. The content of that JS file would then be added to the ship script.

Alternatively, and more indirect, an AI message that triggers a new world script event. In this case the actual attaching could be done in the world script. The event should then have the triggering entity as a parameter.

I hope I am making myself clear. The request was triggered by this post and my addition to it.
Post Reply