Jump to content
The simFlight Network Forums

Recommended Posts

Posted

Hi all,

I will use a function to check status of strobe lights in PMDG 737 but nothing happens

function depart(offset,value)
    if (ipc.readUB(0x6500) ==2) then                            --check status of strobe at PMDG 737
        sound.play("c:\\mysound\\paxsign.wav")                    --if status on white play sound
    end
end

if I use the same string in a while 1 do I get the result as expected.

while 1 do
if (ipc.readUB(0x6500) ==0) then
    ipc.display("0")
    elseif (ipc.readUB(0x6500) ==1) then
    ipc.display("1")
    elseif (ipc.readUB(0x6500) ==2) then
    ipc.display("2")
    end
    ipc.sleep(50)
end

What's wrong here ?

cheers Artox

Posted
20 minutes ago, Artox67 said:

I will use a function to check status of strobe lights in PMDG 737 but nothing happens

function depart(offset,value)
    if (ipc.readUB(0x6500) ==2) then                            --check status of strobe at PMDG 737
        sound.play("c:\\mysound\\paxsign.wav")                    --if status on white play sound
    end
end

I assume that is just an extract? Where's the rest of the program?  I can't help with and incomplete extract!

And why not simplify it to:

function depart(offset,value)
    if value==2 then   --check status of strobe at PMDG 737
        sound.play("c:\\mysound\\paxsign.wav")   --if status on white play sound
    end
end

since both the offset and its value are supplied in the function call. That's the whole point of having parameters in it!

Pete

 

Posted (edited)

Hi Pete,

 

thx for the response.

At the moment this is all of the script. The idea behind is to play a sound e.g. "saets for departure....) if strobe goes to white.

It seems to be I get not the value back as expected or as tested in the while 1 do. 

Any further ideas?

Artox

P.S. the log shows NO errors at the script

 

Edited by Artox67
Posted
1 hour ago, Artox67 said:

At the moment this is all of the script.

So the function is NEVER called -- there's nothing to call it!

Have you not looked at any of the many examples using events instead of loops? How did you think the function was called?

The proper script for you would be:

function depart(offset,value)
    if value==2 then   --check status of strobe at PMDG 737
        sound.play("c:\\mysound\\paxsign.wav")   --if status on white play sound
    end
end
event.offset(0x6500, "UB", "depart")

The "event" call keeps the plug-in running awaiting a change to that offset, when it then calls the function. That's what events are for -- please do have a look at the documentation and examples provided.

Pete

Posted
2 hours ago, Pete Dowson said:

The "event" call keeps the plug-in running awaiting a change to that offset

Sorry I didn't post the caller here with. 

 

I tried your script but still nothing happens.

Again no errors.

Attached is the whole script

 

 

announcement.lua

Posted
3 hours ago, Artox67 said:

I tried your script but still nothing happens.

Again no errors.

Attached is the whole script

Er, which part of the "whole script" is the problem? There's no function "depart" there! What has that got to do with "my" script? Have you tested the latter on its own?

One weird thing I do see is this:

until (ipc.readUB("3367") > 0 )

In other words a loop depending on an offset value! You are mixing up loops and event-driven functions. Are there more? Is your plug-in stuck in a loop someplace? You should be using an event on offset 3367 to detect it changing, not a loop within an event function. The latter makes little sense -- think about it. What happens to other events whilst you are stuck in such a loop?

You seem to have several loops waiting upon offset changes. I've not checked but i wouldn't be surprised if what you are experiencing is a "deadly embrace" where one thing depends on something else which cannot happen because of some other action is preventing it being seen.

I assume you've used the Debug Logging option in FSUIPC's Logging Tab to debug your appication? If not, don't you think you should?

3 hours ago, Artox67 said:

Again no errors.

Surely you aren't expecting the Lua interpreter to tell you how your program isn't working? Errors are related to actual syntax being wrong, not the logic of what you are writing!

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.