Page 48 of 56
Re: Scripting requests
Posted: Sat Nov 24, 2012 2:22 pm
by Eric Walch
I still don't see the problem. Is your request not the same what you are already doing for years in the Hammerhead?
Doing it in one function gives:
Code: Select all
globalPosition = this.ship.position.add(localPosition.rotateBy(this.ship.orientation));
localPosition
being the position in ship coordinates and
globalPosition
the position in system coordinates.
Re: Scripting requests
Posted: Sun Nov 25, 2012 6:23 pm
by Thargoid
Not quite - it's actually the inverse (the Hammerhead is converting local to global, whereas I needed to go the other way). But it was indeed that coding which gave me the inspiration check about how to invert a quaternion. A quick hunt around the net gave me a solution, which is what Cim has now kindly integrated into trunk as noted as it's quite a useful thing to have available.
The code above isn't quite right I think (not tried it) as you need to rotate by the inverse of the player ship orientation, not by just the orientation itself.
Re: Scripting requests
Posted: Sat Dec 08, 2012 1:36 pm
by Smivs
Something I mentioned in passing on the Progress thread but perhaps got lost in the general discussion-
Can we have the ability to attach exhausts to sub-entities please? At the moment they have to be attached to the 'main' ship, which means if the sub-entity is removed or destroyed the exhaust prevails (which is/looks silly!). This feature would be of great help to me in my current project, and would also make shoot-off-able engine sub-ents a realistic and workable possibility.
Re: Scripting requests
Posted: Sat Dec 08, 2012 2:08 pm
by Thargoid
Or as an alternative (as I think exhausts are a special kind of sub-ent themselves, and so you'd end up with the sub-ent of a sub-ent question) could the current special sub-entities (exhausts and flashers) be exposed with r/w to scripting? Either within the usual subEntities array, or perhaps in an array (or two) of their own.
That way we could do the tweaks like Smivs suggests, but also for flashers have them more independently controlled and controllable.
Re: Scripting requests
Posted: Sat Dec 08, 2012 2:25 pm
by cim
Thargoid wrote:Or as an alternative (as I think exhausts are a special kind of sub-ent themselves, and so you'd end up with the sub-ent of a sub-ent question)
Which normally works, but because of the way exhaust display is calculated might be more troublesome. Making the sub-ent types scriptable seems better to me, at least in so far as allowing remove/restore, but probably not for 1.77/8.
Re: Scripting requests
Posted: Sat Dec 08, 2012 2:31 pm
by Smivs
Ah, OK. Something to look forward to then.
<Smivs goes off to ponder how to sort out his current issue
>
Re: Scripting requests
Posted: Sat Jan 05, 2013 6:20 pm
by Cmd. Cheyd
I realize we're in a freeze for 1.77, but after - How hard would it be to make the camera position readable? We can set camera position (player.ship.setCustomView), so why can't we read it? (Or can we, and I just didn't find it?)
Re: Scripting requests
Posted: Sun Jan 13, 2013 3:10 pm
by spara
This is a big request
.
A functionality for an oxp to add dynamic text layers to the screen. I've been abusing message_gui for this, which not a very clean solution.
event handler that runs after a game is loaded
Posted: Wed Jan 16, 2013 1:44 am
by GGShinobi
I'm currently working with spara on an update for his [wiki]Updating TSC[/wiki].oxp, and I ran into a little problem there:
We want the equipment to be automatically awarded to the players ship if the ship has an [wiki]Advanced Space Compass[/wiki] (ASC) installed.
I've looked at the event list that can be found
in the wiki, and I already use
playerBoughtEquipment and
playerBoughtNewShip to add the equipment in the respective cases. But I have not found a nice way to add it if the player's ship already had an ASC installed
before he installed the oxp.
My current workaround will be to use another event, for example
shipWillLaunchFromStation for the check if an ASC is installed and add the equipment if so. But this is a little bit of overkill, since it would be sufficient to check it only after a game is loaded. So, something like a
"playerHasLoadedGame" (similar to the
playerWillSaveGame-event) would be nice in the future
Re: event handler that runs after a game is loaded
Posted: Wed Jan 16, 2013 4:09 am
by submersible
GGShinobi wrote:
We want the equipment to be automatically awarded to the players ship if the ship has an [wiki]Advanced Space Compass[/wiki] (ASC) installed.
Can you test
Code: Select all
player.ship.equipmentStatus("EQ_???")
http://wiki.alioth.net/index.php/Oolite ... mentStatus
Re: Scripting requests
Posted: Wed Jan 16, 2013 7:31 am
by Thargoid
That would be the simplest way. Do a test on game start-up (see below) and if that fails (ie they don't have the ASC) then do a test on equipment purchase as already noted below.
Alternatively this.playerHasLoadedGame
is otherwise known as [url=http://wiki.alioth.net/index.php/Oolite_JavaScript_Reference:_world_script_event_handlers#startUp]this.startUp[/url]
.
Re: Scripting requests
Posted: Wed Jan 16, 2013 10:06 am
by GGShinobi
Thank you submersible and Thargoid for your answers!
Thargoid wrote:Alternatively this.playerHasLoadedGame
is otherwise known as [url=http://wiki.alioth.net/index.php/Oolite_JavaScript_Reference:_world_script_event_handlers#startUp]this.startUp[/url]
.
That is exactly what I've been looking for! I didn't get that from the
description in the wiki - there it sounded to me like that event is run (only once) after the game has been started. And I already wondered why no one else has been missing such an event.
I made an edit to the wiki to point out that the event is called also when a game is loaded. Question
: Does this mean that everytime I load a new game, all OXPs are reloaded? If so, the entry in the wiki should be edited, e.g. by changing the sentence to "
This also means that it is also called after the player has loaded a game."
Anyway, thanks again!
Re: Scripting requests
Posted: Wed Jan 16, 2013 10:25 am
by Lone_Wolf
GGShinobi wrote:
Question
: Does this mean that everytime I load a new game, all OXPs are reloaded? If so, the entry in the wiki should be edited, e.g. by changing the sentence to "
This also means that it is also called after the player has loaded a game."
Yes, OXPs are reloaded when you load a new game.
Below is a partial copy of my latest.log .
At 11:16:19 i started oolite, answered yes to 'Load previous commander' .
The oxp loading entries for the loadgame start at 11:16:29.058 .
Code: Select all
11:16:19.359 [shipData.load.begin]: Loading ship data.
11:16:20.535 [script.javascript.init]: JavaScript reset successful.
11:16:20.670 [script.load.world.listAll]: Loaded 39 world scripts:
BGS-M 1.6
Cabal_Common_Briefing 1.7
Cabal_Common_Comms 1.7
Cabal_Common_Functions 1.7
Cabal_Common_Keyboard 1.7
Cabal_Common_MissionHandling 1.7
Cabal_Common_Music 1.7
Cabal_Common_Overlay 1.7
Cabal_Common_OXPStrength 1.7
Cabal_Common_SpecialMarkets 1.7
Famous Planets 2.5.1
genericHUDswitch - MilHUD.js 1.05, modified by Wyvern for MilHUD
long_way_round
Missile Spoof 1.02 - for Oolite 1.75
oolite-cloaking-device 1.77
oolite-constrictor-hunt 1.77
oolite-contracts-cargo 1.77
oolite-contracts-helpers 1.77
oolite-contracts-parcels 1.77
oolite-contracts-passengers 1.77
oolite-nova 1.77
oolite-thargoid-plans 1.77
oolite-trumbles 1.77
OXPConfig 2.0.14
Povray Planets 1
Povray Planets Galaxy1 Textures 1.1
Povray Planets Galaxy2 Textures 0.1
Povray Planets Galaxy3 Textures 0.1
Povray Planets Galaxy4 Textures 0.1
Povray Planets Galaxy5 Textures 0.1
Povray Planets Galaxy6 Textures 0.1
Povray Planets Galaxy7 Textures 0.1
Povray Planets Galaxy8 Textures 0.1
randomshipnames 1.2
Repair system 2.08
Shield Cycler 0.30.3
Shield Cycler External Events 0.30.3
shieldequalizercapacitors 1.3
targetAutolock 1.11
11:16:23.726 [Povray Planets]: Startup
11:16:23.727 [Povray Planets]: Povray Planets Galaxy1 Textures
11:16:23.727 [Povray Planets]: Monkey patch Povray Planets Galaxy1 Textures
11:16:23.727 [Povray Planets]: Povray Planets Galaxy2 Textures
11:16:23.727 [Povray Planets]: Monkey patch Povray Planets Galaxy2 Textures
11:16:23.727 [Povray Planets]: Povray Planets Galaxy3 Textures
11:16:23.727 [Povray Planets]: Monkey patch Povray Planets Galaxy3 Textures
11:16:23.727 [Povray Planets]: Povray Planets Galaxy4 Textures
11:16:23.727 [Povray Planets]: Monkey patch Povray Planets Galaxy4 Textures
11:16:23.727 [Povray Planets]: Povray Planets Galaxy5 Textures
11:16:23.727 [Povray Planets]: Monkey patch Povray Planets Galaxy5 Textures
11:16:23.727 [Povray Planets]: Povray Planets Galaxy6 Textures
11:16:23.727 [Povray Planets]: Monkey patch Povray Planets Galaxy6 Textures
11:16:23.727 [Povray Planets]: Povray Planets Galaxy7 Textures
11:16:23.727 [Povray Planets]: Monkey patch Povray Planets Galaxy7 Textures
11:16:23.727 [Povray Planets]: Povray Planets Galaxy8 Textures
11:16:23.727 [Povray Planets]: Monkey patch Povray Planets Galaxy8 Textures
11:16:23.882 [startup.complete]: ========== Loading complete in 5.49 seconds. ==========
11:16:28.058 [script.javascript.init]: JavaScript reset successful.
11:16:28.078 [script.load.world.listAll]: Loaded 39 world scripts:
BGS-M 1.6
Cabal_Common_Briefing 1.7
Cabal_Common_Comms 1.7
Cabal_Common_Functions 1.7
Cabal_Common_Keyboard 1.7
Cabal_Common_MissionHandling 1.7
Cabal_Common_Music 1.7
Cabal_Common_Overlay 1.7
Cabal_Common_OXPStrength 1.7
Cabal_Common_SpecialMarkets 1.7
Famous Planets 2.5.1
genericHUDswitch - MilHUD.js 1.05, modified by Wyvern for MilHUD
long_way_round
Missile Spoof 1.02 - for Oolite 1.75
oolite-cloaking-device 1.77
oolite-constrictor-hunt 1.77
oolite-contracts-cargo 1.77
oolite-contracts-helpers 1.77
oolite-contracts-parcels 1.77
oolite-contracts-passengers 1.77
oolite-nova 1.77
oolite-thargoid-plans 1.77
oolite-trumbles 1.77
OXPConfig 2.0.14
Povray Planets 1
Povray Planets Galaxy1 Textures 1.1
Povray Planets Galaxy2 Textures 0.1
Povray Planets Galaxy3 Textures 0.1
Povray Planets Galaxy4 Textures 0.1
Povray Planets Galaxy5 Textures 0.1
Povray Planets Galaxy6 Textures 0.1
Povray Planets Galaxy7 Textures 0.1
Povray Planets Galaxy8 Textures 0.1
randomshipnames 1.2
Repair system 2.08
Shield Cycler 0.30.3
Shield Cycler External Events 0.30.3
shieldequalizercapacitors 1.3
targetAutolock 1.11
11:16:29.071 [Povray Planets]: Startup
11:16:29.071 [Povray Planets]: Povray Planets Galaxy1 Textures
11:16:29.071 [Povray Planets]: Monkey patch Povray Planets Galaxy1 Textures
11:16:29.071 [Povray Planets]: Povray Planets Galaxy2 Textures
11:16:29.071 [Povray Planets]: Monkey patch Povray Planets Galaxy2 Textures
11:16:29.071 [Povray Planets]: Povray Planets Galaxy3 Textures
11:16:29.071 [Povray Planets]: Monkey patch Povray Planets Galaxy3 Textures
11:16:29.071 [Povray Planets]: Povray Planets Galaxy4 Textures
11:16:29.071 [Povray Planets]: Monkey patch Povray Planets Galaxy4 Textures
11:16:29.071 [Povray Planets]: Povray Planets Galaxy5 Textures
11:16:29.071 [Povray Planets]: Monkey patch Povray Planets Galaxy5 Textures
11:16:29.071 [Povray Planets]: Povray Planets Galaxy6 Textures
11:16:29.071 [Povray Planets]: Monkey patch Povray Planets Galaxy6 Textures
11:16:29.071 [Povray Planets]: Povray Planets Galaxy7 Textures
11:16:29.072 [Povray Planets]: Monkey patch Povray Planets Galaxy7 Textures
11:16:29.072 [Povray Planets]: Povray Planets Galaxy8 Textures
11:16:29.072 [Povray Planets]: Monkey patch Povray Planets Galaxy8 Textures
11:16:33.148 [exit.context]: Exiting: Exit Game selected on options screen.
11:16:33.162 [gameController.exitApp]: .GNUstepDefaults synchronized.
Closing log at 2013-01-16 11:16:33 +0100.
Re: Scripting requests
Posted: Wed Jan 16, 2013 12:22 pm
by GGShinobi
Lone_Wolf wrote:Yes, OXPs are reloaded when you load a new game.
Lone_Wolf, thanks for the info. I've updated the wiki accordingly.
Re: Scripting requests
Posted: Sat Jan 19, 2013 6:06 am
by Cmd. Cheyd
Would it be possible to make galaxy and system writable from JS (i.e. - change the current system) during startup?