I am trying to modify a script to change the volume of an engine sound according to the current engine thrust level (w and s keys). I am reading the player.ship.thrust property but it always seems to return the ship's maximum thrust (=32 for the Cobra III).
Is there a property that will return the actual engine level, in this case somewhere between 0 and 32 presumably?
The sound plays OK, I just cannot change the volume.
The thrust property measures the ability of the ship to accelerate. While it could in theory change, it doesn't tend to. (I'm not sure there are any circumstances in which the JS value changes for the player ship)
You probably want player.ship.speed and player.ship.maxSpeed instead (noting that speed will exceed maxSpeed under injectors or torus drive, but the SoundSource will treat any volume > 1 as equal to 1 anyway, so you probably don't need to worry about that here)
Excellent! Thank you, that works nicely. I now have a custom engine roar whose volume is proportional to my speed.
btw I have done this by hacking the main script in the BGS expansion along with stealing the engine sound from the XR2 in Orbiter.
ed. top tip for other newbie script hackers: Hold the Shift key down when starting Oolite! It seems that scripts are cached and changes will not register even after a reboot.
Nice job on the script, I was thinking about missing engine sound for the player only yesterday.
streb2001 wrote:
Excellent! Thank you, that works nicely. I now have a custom engine roar whose volume is proportional to my speed.
btw I have done this by hacking the main script in the BGS expansion along with stealing the engine sound from the XR2 in Orbiter.
ed. top tip for other newbie script hackers: Hold the Shift key down when starting Oolite! It seems that scripts are cached and changes will not register even after a reboot.