Marcelo peixoto Posted June 16, 2012 Report Posted June 16, 2012 (edited) Hi friends My FSuipc is 4.831 I'm doing a GPWS Lua script for any aircraft. I don´t know how to zero the volume, if i put 0 the sound still play quiet. In the manual say The vol ( volume) is a % value between 0% and 100%. This isn't the complete range from silence ot max, but 0 is very quiet. This defaults to 100. This right? 0 is not absolute silence? i put the line if ipc.readSB(0x0B20) == 1 then to play the sound only when the sound is on in FS. Other think i wanna do, is play the sound only when the FS is in focus, but i don´t find a way. see code: gpws.lua while 1 dovol = 80ralt = ipc.readUD(0x31E4)*3.28084/65536if (ralt > 1000) thenaltvar = 2000snd = 1000endif (ralt < 1000) and (ralt > 500) thenif (snd == 1000) thenif ipc.readSB(0x0B20) == 1 thensound.play("jetone_1000" ,0 ,vol)endsnd = 500endendif (ralt < 500) and (ralt > 400) thenif (snd == 500) thenif ipc.readSB(0x0B20) == 1 thensound.play("jetone_500" ,0 ,vol)endsnd = 400endendif (ralt < 400) and (ralt > 300) thenif (snd == 400) thenif ipc.readSB(0x0B20) == 1 thensound.play("jetone_400" ,0 ,vol)endsnd = 300endendif (ralt < 300) and (ralt > 250) thenif (snd == 300) thenif ipc.readSB(0x0B20) == 1 thensound.play("jetone_300" ,0 ,vol)endsnd = 250endendif (ralt < 250) and (ralt > 200) thenif (snd == 250) thenif ipc.readSB(0x0B20) == 1 thensound.play("jetone_min" ,0 ,vol)endsnd = 200endendif (ralt < 200) and (ralt > 100) thenif (snd == 200) thenif ipc.readSB(0x0B20) == 1 thensound.play("jetone_200" ,0 ,vol)ipc.writeSB("07BC", 0) -- DESLIGA AP MASTERipc.writeSB("07DC", 0) -- DESLIGA SPDendsnd = 100endendif (ralt < 100) and (ralt > 50) thenif (snd == 100) thenif ipc.readSB(0x0B20) == 1 thensound.play("jetone_100" ,0 ,vol)endsnd = 50endendif (ralt < 50) and (ralt > 40) thenif (snd == 50) thenif ipc.readSB(0x0B20) == 1 thensound.play("jetone_50" ,0 ,vol)endsnd = 40endendif (ralt < 40) and (ralt > 30) thenif (snd == 40) thenif ipc.readSB(0x0B20) == 1 thensound.play("jetone_40" ,0 ,vol)endsnd = 30endendif (ralt < 30) and (ralt > 20) thenif (snd == 30) thenif ipc.readSB(0x0B20) == 1 thensound.play("jetone_30" ,0 ,vol)endsnd = 20endendif (ralt < 20) and (ralt > 10) thenif (snd == 20) thenif ipc.readSB(0x0B20) == 1 thensound.play("jetone_20" ,0 ,vol)endsnd = 10endendif (ralt < 10) thenif (snd == 10) thenif ipc.readSB(0x0B20) == 1 thensound.play("jetone_10" ,0 ,vol)endsnd = 0endendend[/CODE]To this work:1 need download the sound package in http://www.4shared.c...CcY/Sound.html? extract the files on your FS Sound folder2 create a file in Modules folder called gpws.lua and copy the code inside this file3 create a file in Modules folder called ipcready.lua and put the code below inside ipc.runlua("gpws.lua")Restart FSFor everyone use and improve.Tanks! Edited June 16, 2012 by Marcelo peixoto
Marcelo peixoto Posted June 16, 2012 Author Report Posted June 16, 2012 To play only when FS is in focus only change vol = 80 to vol = -80 in the code.
Pete Dowson Posted June 16, 2012 Report Posted June 16, 2012 I don´t know how to zero the volume, if i put 0 the sound still play quiet. Correct. Why play the sound with zero volume? Just don't play it, or stop it if playing. FSUIPC scales the volume to give more precise control with 100 positions that otherwise you'd get. This right? 0 is not absolute silence? Yes, as it says. Why would you want to play sounds with no sound? Other think i wanna do, is play the sound only when the FS is in focus, but i don´t find a way. As Marcelo says, and as stated in the documentation for the sound.play function, just set the volume control -ve. (Obviously you cannot do this for zero, so don't use zero). Regards Pete
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now