Jump to content
The simFlight Network Forums

Recommended Posts

Posted

Hi Pete and all,

 

Im having mixed results when programmimg LUA for use with the goflight WP-6 panel

 

An example is below

 

---------- GEAR LIGHTS
function NoseGearStatus(offset, value) --LIGHT 1
if logic.And(value,0x0000) ~=0 then --if nose red
    gfd.SetColour(GFWP6, 0, 0, 2) --set red light
    gfd.SetLight(GFWP6, 0, 0) --turn it on
elseif logic.And(value,0x0002) ~=0 then --if nose green
    gfd.SetColour(GFWP6, 0, 0, 3) --set green light
    gfd.SetLight(GFWP6, 0, 0) --turn it on
else
    gfd.ClearLight(GFWP6, 0, 0) -- extinguish if no lights
    end
    end
event.offset("941E", "UB", "NoseGearStatus")

 

Basically im testing the value of the nose uc light green and red status to decide if my button should glow red or green or extinguish.

 

Im getting the green light fine and off with aircraft power off. I dont get any red light though and wonder now if its possible to use a light to use 2 colours.

 

The offsets im using are correct and they are for the ifly 737

 

Hope you can help

 

Graham

Posted

Im having mixed results when programmimg LUA for use with the goflight WP-6 panel

 

This is NEVER true:

 

logic.And(value,0x0000) ~=0

 

If you AND something with zero the answer is ALWAYS zero!

 

Pete

Posted
logic.And(value,0x0000) ~=0
 
this is testing bit 0 ( in HEX) of offset 941E or so i thought
offset     bit     description
941E      0      NOSE_GEAR_RedLight_Status
 

taken from ifly2fsuipc documentation

 

Graham

cleardot.gif
Posted

 

logic.And(value,0x0000) ~=0

 

this is testing bit 0 ( in HEX) of offset 941E or so i thought

 

No, it certainly is not. Bit 0 is actually a bit, a part of a byte, and you have no bits at all set in the value 0x0000. Zero is zero and contains no bits to "AND" with at all!  Bit 0 has the value 0x0001.

 

Please go to the FAQ subforum and look at the thread about bits and numbers. 

 

Pete

Posted

Thanks Pete,

All the LUA I've written never included tes ing a 0 bit before. Of course a 0 bit must have a value. I just over looked it !

Small things make a big difference ! All ok now.

Have a great weekend !

Graham

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.