• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

FSX LUA ~=0 versus ==1 - SOLVED

Messages
35
Country
ca-quebec
Solution: http://www.fsdeveloper.com/forum/threads/lua-0-versus-1.438989/#post-760757


Hi,

I used == in a previous LUA and checking bits worked as expected.

Code:
  if ipc.readUB(0x9358) ~= nil then
--        No Autoland
    if logic.And(ipc.readUB(0x9358),1) == 1 then
      MipAnnAutoLandLine2 = 2
    end
--        No Land 3
    if logic.And(ipc.readUB(0x9358),2) == 1 then
      MipAnnAutoLandLine2 = 1
    end
--        Land 2
    if logic.And(ipc.readUB(0x9358),4) == 1 then
      MipAnnAutoLandLine1 = 2
    end
--        Land 3
    if logic.And(ipc.readUB(0x9358),8) == 1 then
      MipAnnAutoLandLine1 = 1
    end
  end

I copied that LUA to make a MasterCaution LUA.

Code:
  if ipc.readUB(0x92e3) ~= nil then
--        Warning
    if logic.And(ipc.readUB(0x92e3),1) == 1 then
      MipAnnMasterWarning = 1
    end
--        Caution
    if logic.And(ipc.readUB(0x92e3),2) == 1 then
      MipAnnMasterCaution = 1
    end
  end

But == 1 does not work in this new LUA.

(original MasterCaution gauge at far left, making a larger one at right)



I have to use ~= 0 to read the bits.



Any idea what I'm assuming wrong?

Robert
 
Last edited:

n4gix

Resource contributor
Messages
11,674
Country
unitedstates
Per the SDK, the only consistently guaranteed valid Boolean value is zero. The non-zero value may be 1 or -1. Therefore to be guaranteed success, always check for a non-zero return.
 
Messages
35
Country
ca-quebec
Thanks.

I searched the SDK Gauge manual and found nothing for LOGIC or BITWISE that mentionned this.

I also looked through the LUA Library Manual (FSUIPC) and saw no reference either.

Robert
 
Last edited:

n4gix

Resource contributor
Messages
11,674
Country
unitedstates
Robert, as far as I know that little bit of "received wisdom" isn't actually documented anywhere officially. I learned it directly from Susan Ashlock, who was the last "Chief XML Architect" in the ACES studio when they were closed down.

(A:SomeVariable,bool) ! if{ DoThis if TRUE } els{ DoThat if FALSE }

will always work since it is checking for a non-zero return to become TRUE, and zero return to become FALSE.
 
Top