Profile image

Navigation; multiple conditional statements

1,514 atgxtg  10 months ago

Hi, I am working on something that will always give the distance, ETA and bearing for a given destination, say Wright Airfield.

But I need a way to handle a conditional statement with at least 3 options in order to get the bearing right. Basically it's got the angle right, but has to decide between 0+Angle, 180+Angle or 360+Angle to get the proper bearing, and the standard

Ternary operator: condition ? valueiftrue : valueiffalse

only handles two options.

Does anybody know a way to do this?

  • Log in to leave a comment
  • Profile image
    46.5k PlaneFlightX

    @Korzalerke2147483647 I'm hoping for the end of this year, I've been working on school stuff but I have a 2 week break coming up soon, I should get a lot done then

    +1 10 months ago
  • Profile image

    @PlaneFlightX Damn that's a lot, guessing it won't be done for another year or two.

    It'll probably rise to the best of all time page pretty fast when you post it though.

    10 months ago
  • Profile image
    46.5k PlaneFlightX

    @Korzalerke2147483647 I haven't done much work on the plane, but it's getting there. It's missing the autopilot, ILS, autoland, backend FMC stuff, and a bunch of random cockpit switches.
    Before I publish the plane I also need to make a tutorial video, pdf manual, pdf checklist, charts, and airport vehicles (player controlled AI, it's going to be epic)

    +1 10 months ago
  • Profile image
    1,514 atgxtg

    @Korzalerke2147483647
    They don't seem to work, If i recall correctly when you have an conditional statement that is false, nothing that follows it gets processed. In the past I've had to multiply and add up several conditions to get around it.

    On a positive note MrCOPTY 's https://www.simpleplanes.com/a/8bjkWo/Grumman-F9F-2-Panther-FULL-EXPERIENCE, has a waypoint system that is almost exactly what I was going for. I just have to reverse engineer his variables. The variable do seem to be much better than typing out formula's multiple times.

    So at least now I know it can be done, because it has been done.!

    +1 10 months ago
  • Profile image

    @PlaneFlightX How's the plane coming along btw? Is it like, 80% done?

    10 months ago
  • Profile image
    46.5k PlaneFlightX

    @Korzalerke2147483647 I have over 50 of these stacked statements in a lot of my variables. I use a text editor and a lot of notes to make sense of them

    +1 10 months ago
  • Profile image

    Looks ugly but it's the only option afaik:

    Condition ? value_if_true : (Condition ? value_if_true : value_if_false)
    

    or

    Condition ? (Condition ? value_if_true : value_if_false) : value_if_false
    

    Kinda like chaining a bunch of if else statements, but it becomes very hard to read very fast.

    I heard you can add them over multiple lines like this:

    Condition ?
    value_if_true
    : Condition ?
        value_if_true
        : Condition ?
            value_if_true
            : value_if_false
    

    But I haven't tested it so idk if it really works.

    10 months ago