Scripting requests
Moderators: winston, another_commander
- Cmd. Cheyd
- ---- 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...
Okay. That was my fallback idea. I was going to do it with a 1px x 2px image.
Find my OXP's at:
Deep Horizon Industries - Your Planet Our Design
Deep Horizon Industries - Your Planet Our Design
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.
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.
My OXPs via Boxspace or from my Wiki pages .
Thargoid TV
Dropbox Referral Link
Thargoid TV
Dropbox Referral Link
-
- Quite Grand Sub-Admiral
- Posts: 6682
- Joined: Wed Feb 28, 2007 7:54 am
Done. Taken from the commit comments of r3746: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.
Added the playerWillSaveGame script event handler, taking as parameter the type of savegame, which can be standardSave, autoSave or quickSave.
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).
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).
My OXPs via Boxspace or from my Wiki pages .
Thargoid TV
Dropbox Referral Link
Thargoid TV
Dropbox Referral Link
Berlios still seems to be on 3745 (from 3rd Sept)? Has something gone wrong with the distribution or update?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.
My OXPs via Boxspace or from my Wiki pages .
Thargoid TV
Dropbox Referral Link
Thargoid TV
Dropbox Referral Link
-
- Quite Grand Sub-Admiral
- Posts: 6682
- Joined: Wed Feb 28, 2007 7:54 am
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.
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.
My OXPs via Boxspace or from my Wiki pages .
Thargoid TV
Dropbox Referral Link
Thargoid TV
Dropbox Referral Link
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
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.Thargoid wrote:.....as you wouldn't have to guess what length the timer would need to be.
UPS-Courier & DeepSpacePirates & others at the box and some older versions
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...
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...
My OXPs via Boxspace or from my Wiki pages .
Thargoid TV
Dropbox Referral Link
Thargoid TV
Dropbox Referral Link
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)
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.
Maybe I did something wrong - will check again tonight with that and also with a trunk set-up.
My OXPs via Boxspace or from my Wiki pages .
Thargoid TV
Dropbox Referral Link
Thargoid TV
Dropbox Referral Link
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
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)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.
UPS-Courier & DeepSpacePirates & others at the box and some older versions
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
My OXPs via Boxspace or from my Wiki pages .
Thargoid TV
Dropbox Referral Link
Thargoid TV
Dropbox Referral Link
- 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:
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.
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.