Jump to content
The simFlight Network Forums

makoy

Members
  • Posts

    12
  • Joined

  • Last visited

Posts posted by makoy

  1. I KNOW I HAVE MESS IT, thats why i have ask help, becouse am totally new with LUA, i never havent write it before. Here is the script what dosent give errors. I just have add ref=0 , below of seatfl=0 -- seat belt flag , nothing else.

    Looping sound stop now before landing.

    ------------------------------------------------------------------------------

    -- Turbulence looping sound -- Seat Belts Messages -- ATC Radio Chatter

    -- Initializing flags --

    sndflg=0 -- turbulence sound flag

    seatfl=0 -- seat belt flag

    ref=0

    -- Function to play sound if and until turbulence is detected --

    function turbulence(offset,value)

    ground=ipc.readUW(0x0366)

    if (value > 0) and (sndflg == 0) and (ground == 0) then

    ref=sound.playloop("C:\\WideClient\\Sounds\\Turbulence.wav")

    sndflg=1

    ipc.sleep(1000)

    if (seatfl == 2) or (seatfl == 4) then

    sound.play("C:\\WideClient\\Sounds\\nattend.wav")

    ipc.sleep(1000)

    end

    sound.play("C:\\WideClient\\Sounds\\nattend.wav")

    end

    if (value == 0) and (sndflg == 1) then

    sound.stop(ref)

    sndflg=0

    if (seatfl == 2) or (seatfl ==4) then

    sound.play("C:\\WideClient\\Sounds\\nattend.wav")

    ipc.sleep(1000)

    sound.play("C:\\WideClient\\Sounds\\nattend.wav")

    end

    end

    end

    -- Function to manage messages when seat belts sign changes - welcome on board -- descent --- on cruise ---- parked at the arrival gate

    function seatbelt(offset,value)

    if (value == 1) and (seatfl == 0) then

    sound.play("C:\\WideClient\\Sounds\\nattend.wav")

    ipc.sleep(1000)

    sound.play("C:\\WideClient\\Sounds\\welcomeonboard.wav")

    seatfl=1

    end

    if (value == 1) and (seatfl == 2) then

    sound.play("C:\\WideClient\\Sounds\\nattend.wav")

    ipc.sleep(1000)

    sound.play("C:\\WideClient\\Sounds\\descent.wav")

    seatfl=3

    end

    if (value == 0) and (seatfl == 1) then

    sound.play("C:\\WideClient\\Sounds\\nattend.wav")

    ipc.sleep(1000)

    sound.play("C:\\WideClient\\Sounds\\levelautobelt.wav")

    seatfl=2

    end

    if (value == 0) and (seatfl == 3) then

    sound.play("C:\\WideClient\\Sounds\\nattend.wav")

    ipc.sleep(1000)

    sound.play("C:\\WideClient\\Sounds\\atgate.wav")

    seatfl=4

    end

    end

    -- Function to play ATC chatter - COM2 freqs 118.10 and 118.20 - 70 wavs for each freq - y var to make the frequency of chat random - x var to make the messages random

    function ATC_Radio()

    -- Radio squelch if a valid freq is selected

    n = ipc.readUW(0x3118)

    if (n == 0x1810) or (n == 0x1820) then

    if (n1 ~= n) then

    sound.play("C:\\WideClient\\Sounds\\Radio.wav")

    n1=n

    end

    end

    -- Radio chatter play routine

    y= math.random(1,5)

    if (y == 2) or (y == 4) then

    if (n == 0x1810) then

    x=math.random (1,70)

    suono = "C:\\WideClient\\Sounds\\chatter1.wav"

    sound.play(suono)

    end

    if (n == 0x1820) then

    x=math.random (1,70)

    suono = "C:\\WideClient\\Sounds\\chatter2.wav"

    sound.play(suono)

    end

    end

    end

    -- FSUIPC LUA calls for the different events -- timer to exec the ATC function every 1 min

    event.offset(0x0E88,"UW","turbulence")

    event.offset(0x0E98,"UW","turbulence")

    event.offset(0x341D,"UB","seatbelt")

    event.timer(60000,"ATC_Radio")

    ------------------------------------------------------------------------

  2. Please can you simply paste in the Lua script you are trying to use? I want to look at what YOU are using! I don't want references to other things and instructions! I need to see exactly what you are running!

    Pete

    Ok, here it is.

    ------------------------------------------------------------------------------

    -- Turbulence looping sound -- Seat Belts Messages -- ATC Radio Chatter

    -- Initializing flags --

    sndflg=0 -- turbulence sound flag

    seatfl=0 -- seat belt flag

    ref=0 -- onground

    -- Function to play sound if and until turbulence is detected --

    function turbulence(offset,value)

    ground=ipc.readUW(0x0366)

    if (value > 0) and (sndflg == 0) and (ground == 0) then

    ref=sound.playloop("C:\\WideClient\\Sounds\\Turbulence.wav")

    sndflg=1

    ipc.sleep(1000)

    if (seatfl == 2) or (seatfl == 4) then

    sound.play("C:\\WideClient\\Sounds\\nattend.wav")

    ipc.sleep(1000)

    end

    sound.play("C:\\WideClient\\Sounds\\nattend.wav")

    end

    if (value == 0) and (sndflg == 1) then

    sound.stop(ref)

    sndflg=0

    if (seatfl == 2) or (seatfl ==4) then

    sound.play("C:\\WideClient\\Sounds\\nattend.wav")

    ipc.sleep(1000)

    sound.play("C:\\WideClient\\Sounds\\nattend.wav")

    end

    end

    function onground(offset,value)

    if value ~=0 and sndflg ~=0 then

    sound.stop(ref)

    sndflg=0

    end

    end

    end

    -- Function to manage messages when seat belts sign changes - welcome on board -- descent --- on cruise ---- parked at the arrival gate

    function seatbelt(offset,value)

    if (value == 1) and (seatfl == 0) then

    sound.play("C:\\WideClient\\Sounds\\nattend.wav")

    ipc.sleep(1000)

    sound.play("C:\\WideClient\\Sounds\\welcomeonboard.wav")

    seatfl=1

    end

    if (value == 1) and (seatfl == 2) then

    sound.play("C:\\Documents and Settings\\Delli\\Työpöytä\\WideClient\\Sounds\\nattend.wav")

    ipc.sleep(1000)

    sound.play("C:\\WideClient\\Sounds\\descent.wav")

    seatfl=3

    end

    if (value == 0) and (seatfl == 1) then

    sound.play("C:\\WideClient\\Sounds\\nattend.wav")

    ipc.sleep(1000)

    sound.play("C:\\WideClient\\Sounds\\levelautobelt.wav")

    seatfl=2

    end

    if (value == 0) and (seatfl == 3) then

    sound.play("C:\\WideClient\\Sounds\\nattend.wav")

    ipc.sleep(1000)

    sound.play("C:\\WideClient\\Sounds\\atgate.wav")

    seatfl=4

    end

    end

    -- Function to play ATC chatter - COM2 freqs 118.10 and 118.20 - 70 wavs for each freq - y var to make the frequency of chat random - x var to make the messages random

    function ATC_Radio()

    -- Radio squelch if a valid freq is selected

    n = ipc.readUW(0x3118)

    if (n == 0x1810) or (n == 0x1820) then

    if (n1 ~= n) then

    sound.play("C:\\WideClient\\Sounds\\Radio.wav")

    n1=n

    end

    end

    -- Radio chatter play routine

    y= math.random(1,5)

    if (y == 2) or (y == 4) then

    if (n == 0x1810) then

    x=math.random (1,70)

    suono = "C:\\WideClient\\Sounds\\chatter1.wav"

    sound.play(suono)

    end

    if (n == 0x1820) then

    x=math.random (1,70)

    suono = "C:\\WideClient\\Sounds\\chatter2.wav"

    sound.play(suono)

    end

    end

    end

    -- FSUIPC LUA calls for the different events -- timer to exec the ATC function every 1 min

    event.offset(0x0E88,"UW","turbulence")

    event.offset(0x0E98,"UW","turbulence")

    event.offset(0x341D,"UB","seatbelt")

    event.timer(60000,"ATC_Radio")

    event.offset(0x0366,"UW","onground")

    ------------------------------------------------------------------------

  3. Pete, this is the script i try to add.

    Of course, just test the on ground flag via an event, and stop the sound if it is playing. Add this to the code:

    ref = 0 

    near the top , where the other variables are set, and this at the end:

    function onground(off, val)
       if  val ~= 0 and sndflg ~= 0 then
       	sound.stop(ref)
       	sndflg=0
       end
    end
    
    event.offset(0x0366, "UW", "onground")

    Regards

    Pete

    ....and here is the lua, where that script goes. Turbulence sound dont stop, it continue even landed already. Can you please show how it should looks like. Sorry Pete but I dont get it right?

    http://forum.simflight.com/topic/66922-turbulence-sound-atc-radio-chatter-lua/

  4. Pete, i got it working, but sound still goes on and on (on ground). So i have try to add the script you write here earlier, but get always errors. This is my first time to trying with LUA-script, so am new of this. Is it possible to correct that script on Users Contributions to get it work like it should. Thank you.

    Regards

    Marco

  5. Okay. It wasn't too hard. In the process of working out what to do I also found that the facilities for those offsets in FSUIPC4 only worked for the lower three wind and cloud layers, owing to the way they are linked to the old FS98 facilities.

    Versions FSUIPC 3.998p and FSUIPC 4.752 both include full support for offsets 0E84-0E88 for cloud data and 0E94-0E98 for wind data "at aircraft" no matter how many layers there are. Get the updates from the Download Links subforum.

    Regards

    Pete

    Hi Pete, do 3.999 still have these offsets. I cant get sound out?

    Regards

    Marco

  6. Okay. It wasn't too hard. In the process of working out what to do I also found that the facilities for those offsets in FSUIPC4 only worked for the lower three wind and cloud layers, owing to the way they are linked to the old FS98 facilities.

    Versions FSUIPC 3.998p and FSUIPC 4.752 both include full support for offsets 0E84-0E88 for cloud data and 0E94-0E98 for wind data "at aircraft" no matter how many layers there are. Get the updates from the Download Links subforum.

    Regards

    Pete

    Thank you very very much for your time and support Pete, you are Santa :razz:

    Wish you relaxing and happy Christmas and new year.

    Regards

    Marco

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.