Jump to content
Sign in to follow this  
Damlimey

Can anyone tell me what is wrong with this code?

Recommended Posts

Hi all,

This code what I wrote is all about getting an alarm to sound when the fuel reaches a certain value of emptiness, i.e. at 47 gallons. But it ain't working. It is not my intention to assign it to a button. It resides in the actions.lua file for the specific aircraft. The sound file resides in the fsx/sound folder:

-- Fuel Alarm --
function Fuel_Alarm()
if ipc.readLvar("A:FUEL_TOTAL_QUANTITY, gallons")==47 then
    alarmf=sound.play("BingoFuel")
    sound.adjust(alarmf, 100)
    end
    ipc.sleep(50)
end

So far, all my coding that I've assigned to button/switches are working so where have I gone wrong chaps?

Thanks in advance,

D

P.S. If anyone has any idea why my landing lights work but do not illuminate the ground texture in FSX SE, I would love to know.

Share this post


Link to post
Share on other sites

If you are not assigning your Fuel_Alarm function to a button or switch then how are you calling it?

Chris.


Christopher Bell.

Share this post


Link to post
Share on other sites

The code looks good but again how are you calling it?

might work better if you make it an LUA file and place it in the modules folder.

Aircraft lights illuminated ground option checked in Fsx settings?


Luke Pype

Share this post


Link to post
Share on other sites

The function will only trigger when the fuel quantity is exactly 47. This is unlikely. Use <= instead.

When developing functions in LINDA editor you can call them by right-clicking on the function name. You will see a notification in the top line as you do this. It is not necessary to assign functions to buttons to test it.


Andrew Gransden

Scotland, UK

LINDA Support/Developer - VATSIM and BAVirtual - Airbus Flyer

i7 1TB SSD GTX980 - FSX/P3D - Aerosoft Airbus A318/A319/A320/A321 - FS2Crew

Share this post


Link to post
Share on other sites

<=47 Does that mean “less than or equal to” 47 ?

thanks

Edited by MaDDogz

Luke Pype

Share this post


Link to post
Share on other sites

== equal to

<= less than or equal to

>= greater than or equal to

~= not equal to

  • Upvote 1

Andrew Gransden

Scotland, UK

LINDA Support/Developer - VATSIM and BAVirtual - Airbus Flyer

i7 1TB SSD GTX980 - FSX/P3D - Aerosoft Airbus A318/A319/A320/A321 - FS2Crew

Share this post


Link to post
Share on other sites

Hi all,

Sorry for the delay in saying thank you for your help.

To answer ccb777, the code resides within a function triggered by a fuel pump switch. Fuel pump is switched on by a .lua function in the action file and then the 'fuel alarm' code sits in the same actions file. I thought the .lua would just keep running so the code would test the fuel level all the time.

But it ain't working. However, at least now you guys think the code is good, I'll look elsewhere.

Thanks all!

D

Share this post


Link to post
Share on other sites

Well , if it ain’t working then I certainly can’t help you as you have failed to state whether you made changes to the code, as stated above, or not. No time to ask twice...sorry.

 


Luke Pype

Share this post


Link to post
Share on other sites

Take a look at fsuipc events.

 

Chris.


Christopher Bell.

Share this post


Link to post
Share on other sites

Apologies for being a bit hot headed with last reply.

using Linda tracer, does ("A:FUEL_TOTAL_QUANTITY, gallons") ever give a value of 47 or below?

also I’m not sure on the (“A...........gallons”)

have you tried removing the quote marks, so (A:.........gallons)?


Luke Pype

Share this post


Link to post
Share on other sites

Thanks for the clues guys, I'll have a look at these suggestions and see what happens.

Don't worry MaDDogz, we all have our moments... Just ask my ex!

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  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...