Sign in to follow this  
Followers 0
Marcelo peixoto

GPWS for any aircraft in lua script

3 posts in this topic

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 do
vol = 80
ralt = ipc.readUD(0x31E4)*3.28084/65536
if (ralt > 1000) then
altvar = 2000
snd = 1000
end
if (ralt < 1000) and (ralt > 500) then
if (snd == 1000) then
if ipc.readSB(0x0B20) == 1 then
sound.play("jetone_1000" ,0 ,vol)
end
snd = 500
end
end
if (ralt < 500) and (ralt > 400) then
if (snd == 500) then
if ipc.readSB(0x0B20) == 1 then
sound.play("jetone_500" ,0 ,vol)
end
snd = 400
end
end
if (ralt < 400) and (ralt > 300) then
if (snd == 400) then
if ipc.readSB(0x0B20) == 1 then
sound.play("jetone_400" ,0 ,vol)
end
snd = 300
end
end
if (ralt < 300) and (ralt > 250) then
if (snd == 300) then
if ipc.readSB(0x0B20) == 1 then
sound.play("jetone_300" ,0 ,vol)
end
snd = 250
end
end
if (ralt < 250) and (ralt > 200) then
if (snd == 250) then
if ipc.readSB(0x0B20) == 1 then
sound.play("jetone_min" ,0 ,vol)
end
snd = 200
end
end
if (ralt < 200) and (ralt > 100) then
if (snd == 200) then
if ipc.readSB(0x0B20) == 1 then
sound.play("jetone_200" ,0 ,vol)
ipc.writeSB("07BC", 0) -- DESLIGA AP MASTER
ipc.writeSB("07DC", 0) -- DESLIGA SPD
end
snd = 100
end
end
if (ralt < 100) and (ralt > 50) then
if (snd == 100) then
if ipc.readSB(0x0B20) == 1 then
sound.play("jetone_100" ,0 ,vol)
end
snd = 50
end
end
if (ralt < 50) and (ralt > 40) then
if (snd == 50) then
if ipc.readSB(0x0B20) == 1 then
sound.play("jetone_50" ,0 ,vol)
end
snd = 40
end
end
if (ralt < 40) and (ralt > 30) then
if (snd == 40) then
if ipc.readSB(0x0B20) == 1 then
sound.play("jetone_40" ,0 ,vol)
end
snd = 30
end
end
if (ralt < 30) and (ralt > 20) then
if (snd == 30) then
if ipc.readSB(0x0B20) == 1 then
sound.play("jetone_30" ,0 ,vol)
end
snd = 20
end
end
if (ralt < 20) and (ralt > 10) then
if (snd == 20) then
if ipc.readSB(0x0B20) == 1 then
sound.play("jetone_20" ,0 ,vol)
end
snd = 10
end
end
if (ralt < 10) then
if (snd == 10) then
if ipc.readSB(0x0B20) == 1 then
sound.play("jetone_10" ,0 ,vol)
end
snd = 0
end
end
end
[/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 folder

2 create a file in Modules folder called gpws.lua and copy the code inside this file

3 create a file in Modules folder called ipcready.lua and put the code below inside

ipc.runlua("gpws.lua")

Restart FS

For everyone use and improve.

Tanks!

Edited by Marcelo peixoto
0

Share this post


Link to post
Share on other sites

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

0

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0