Jump to content

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.

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?

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.

Share this post


Link to post
Share on other sites
Posted (edited)

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

thanks

Edited by MaDDogz

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

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.

 

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)?

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...