Jump to content
The simFlight Network Forums

Recommended Posts

Posted

Hi Pete, everyone,

 

I'm having a problem triggering sound files using LUA.

 

For example:

 

1. I have a wav file called firebell.wav

2. It is located in the root of drive D

3. FS9 is also located on drive D  ( D:\Flight Simulator 9 )

4. My LUA file is titled "firebell.lua" and is located in the FS9 modules folder

 

So I load FS9 and go into the FSUIPC GUI, click on buttons, and press the button I want to trigger the wav file. It reads location in FSUIPC as 5,0. Next switch 5,1, next switch 5,2 and so on.

 

So once I press the switch I want to associate with the wav file (5,1), I place a check in the "Select for FS Control" box.

I then scroll down until I see the "firebell lua" and select it.

I then hit ok and exit FSUIPC.

I re-boot FS and push the switch. NOTHING. No sound file play. 

 

I've done this over and over placing the sound files on the C drive, FS9/sound directory etc. etc. - No luck

 

Below is the contents of my LUA file. Any help appreciated.

 

Mitch

 

Sound.play("D:\\firebell.wav")

Posted

Sound.play("D:\\firebell.wav")

 

Two problems I can see:

 

1. sound should start with a lower case s

 

sound.play()

 

 

2. The parameter should be the name of the sound file, not a path. The default path according to the documentation is the 'sound' folder under the main FS folder. If you want to play sounds from a different folder, you can call sound.path() with the new folder.

 

Try this:

sound.path("D:\\")sound.play("firebell.wav")

Paul

Posted

Addendum:

 

Note 1:The switch location in FSUIPC is actually 5,0 (not 5,1)

 

Note 2: After reading other similar posts, I changed the firebell.lua to read:

 

sound.play("D:\\firebell.wav")     <<< whereas I un-capitalized the "S" in sound as referenced in sound library

 

Mitch

Posted

Paul,

 

Thank you kindly for your reply.

 

After reading your comments and more in the Lua-Library doc, I omitted the path statement and relocated my sound files to the default 

D:\Flight Simulator 9\Sound folder. So my firebell.lua now reads:

 

sound.play("firebell.wav")

 

Unfortunately, it still does not work.  :???:

Posted

Have a look in the FSUIPC.log file (in the modules folder). It might have a error message that will explain why it's not working.

 

Paste the contents here if you want me to take a look.

 

Paul

Posted

Yes please help Paul. Much appreciated.

 

Note 1: Tried to cut and paste here but must have been to large. FSUIPC.log attached as file.

 

Note 2: Here is the info from my FSUIPC.ini file which might be relevant:

 

[sounds]
Path=D:\Flight Simulator 9\Sound\
Device1=Primary Sound Driver
Device2=Speakers (Realtek High Definition Audio)
Device3=SPDIF-Out (SB X-Fi Surround 5.1)
Device4=Speakers (SB X-Fi Surround 5.1)
Device5=Realtek Digital Output (Realtek High Definition Audio)
Device6=Realtek Digital Output(Optical) (Realtek High Definition Audio)
 
[buttons]
ButtonRepeat=20,10
2=P5,6,CL2:R,0
3=P5,5,CL2:R,20
4=P5,4,CL6:R,20
5=P5,3,CL2:R,20
6=P5,2,CL2:R,20
10=U5,4,CL6:K,0
11=P5,11,CL5:R,0
12=U5,11,CL5:K,0
15=P5,0,CL2:R,0
16=U5,0,CL2:K,0
 
[LuaFiles]
1=ipcready
2=firebell
 

 

Note 3: Screenshot of FSUIPC GUI:

 

fsuipc.jpg

Posted

There are no Lua errors reported in the log and your screenshot of the GUI also looks okay.

 

I can only offer two suggestions now...

 

1. You have a few sound devices listed. You could try specifying the number of the device you are using as the second parameter. Without this you are leaving up to windows to decide on the 'primary' device. For example if you are using the 5.1 speaker output then use:

sound.play("firebell.wav", 4)

2. Try using one of the sounds that comes with flight sim in case your firebell.wav is in an unsupported bit-depth or sample rate. I used

sound.play("INNERMK.WAV")

but I have FSX, so check this is in FS9 or chose another one.

 

 

Pete is back on Thursday if you have no luck with these.

 

Paul

Posted

Hey Paul, finally got it working! YEAAAAAA  (Thank you again).

 

As I now have 8 working LUA's for 8 different sound files, I was reading where I can combine them into one LUA file. For the reason that I want to code many sound commands into one LUA rather than what I have now which is a  LUA for every sound command.

 

For example, currently I have:

 

Firebell.lua file

 

sound.path("C:\\")
sound.play("5-0firebell.wav")
 
and
 
SafetyBrief.lua file
 
sound.path("C:\\")
sound.play("5-4safety_brief")
______________________________________________________________________________________________________
 
So if I make one file called Sound.lua, can you give me below an example of how I program the parameter numbers? I'm assuming once I have the parameter number programmed, then all I need to do is go into the FSUIPC GUI and trigger each button & choose the referenced parameter number???
 
Sound.lua file:
 
sound.path("C:\\")
sound.play("5-0firebell.wav")
 
sound.path("C:\\")
sound.play("5-4safety_brief")
Posted

The parameter set in the FSUIPC dialog comes through in lua as a variable called ipcPARAM. You just set up some if statements to test the value...

 

You can use any numbering scheme you want. Maybe you'll want to match the parameter number with the number in your filenames. I've just used 1 to 3 here.

sound.path("C:\\")
if     ipcPARAM == 1 then
          sound.play("5-0firebell.wav")
elseif ipcPARAM == 2 then
          sound.play("5-4safety_brief")
elseif ipcPARAM == 3 then
          sound.play("5-5another_file")
end

Just stack as many elseif blocks as you need.

 

Paul

Posted

I forgot to say that you probably don't need to do the 'luakill' control on the button release. The script will automatically die when it's finished executing (i.e. it gets to the bottom).

Posted

Hi Paul,

 

Wanted to thank you again for taking the time and effort to assist me.

 

I wanted to help others in the future, who may wish to accomplish in their cockpits, what I have. Therefore, I put together a short step by step

instruction document in PDF format.

 

See attached and thanks again.

 

Mitch

 

Instructions

Posted

Hi Paul,

 

Wanted to thank you again for taking the time and effort to assist me.

 

I wanted to help others in the future, who may wish to accomplish in their cockpits, what I have. Therefore, I put together a short step by step

instruction document in PDF format.

 

See attached and thanks again.

 

Mitch

 

Instructions

 

Could you please post it with a covering message in the "User Contributions" subforum? I could do it, but I'd rather the contrtibutor did it. It looks better! ;-)

 

Pete

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
×
×
  • 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.