3 Replies Latest reply on Apr 3, 2013 7:07 AM by Imposturous

    Problem with Lingo If statements - Director

    Imposturous Level 1

      I have the lingo on my movie script - if statements with one set stating go one frame and the other set stating to go another.  I am not getting any script compile errors but these statements are not working as both sets of if statements are going to the exact same frame in Director.  I have tried over and over but still not working.  Here is an shortened version of the code: 

       

      on timeOut

       

       

        if the timer >= 360 and sprite(16).visible = 1 then

          member ("tellIt").text = "TIME UP"

          _movie.go(32)

          _movie.delay(20*60)

         

         

        end if

       

        if the timer >= 360 and sprite(15).visible = 1 then

          member ("tellIt").text = "TIME UP"

          _movie.go(32)

         

         

        end if

       

        if the timer >= 360 and sprite(14).visible = 1 then

          member ("tellIt").text = "TIME UP"

          _movie.go(32)

       

      end if

       

      if the timer > 350 and sprite(16).visible = 0 then

          _movie.go(31)

          member ("endIt").text = "LUNCH IS FOR THE BIRDS"

          member ("tellIt").text = "TIME FLIES"

        end if

       

        if the timer > 350 and sprite(15).visible = 0 then

          _movie.go(31)

          member ("endIt").text = "LUNCH IS FOR THE BIRDS"

          member ("tellIt").text = "TIME FLIES"

        end if

       

        if the timer > 350 and sprite(14).visible = 0 then

          _movie.go(31)

          member ("endIt").text = "LUNCH IS FOR THE BIRDS"

          member ("tellIt").text = "TIME FLIES"

        end if

       

       

      I hope someone can point me in the right direction.  The game is going fine apart from this one problem I can't seem to solve.

       

      Cheers

        • 1. Re: Problem with Lingo If statements - Director
          Wolfgang Herold Level 2

          This script makes no sense.

          First you check sprite 14/15/16 if visible and if so you set "Timeup" and jump to frame 32.

          In case of any of the 3 sprites is invisible you change back to "Lunch...." immediatly.

           

          "Time up" will only be functional when Sprite 14 and 15 and 16 are visible.

          Also the value of THE TIMER is very low, i think it will always be higher than 350.

           

          wolf

          • 2. Re: Problem with Lingo If statements - Director
            Production Monkey Level 3

            The problem is that all the "if" statements that are True will execute and you will only see the effect of the last one in the sequence that is true. So if the code go(32) is executed and then later go(31) is executed then you will only see the effects of the go(31) statement.

             

            Using a "case" statement for the timer check will fix the problem. Also a lot of your code is redundant. It will be easier to understand if you remove the redundancies.  Here is an untested rewrite of what you posted.

             

            on timeUp

              case true of

                (the timer >= 360):

                  if sprite(16).visible = 1 then _movie.delay(20*60)

                 

                  if  sprite(16).visible = 1 OR sprite(15).visible = 1 then

                    member ("tellIt").text = "TIME UP"

                    _movie.go(32)

                  end if

                 

                (the timer > 350):

                  if sprite(14).visible = 0 OR sprite(15).visible = 0 OR sprite(16).visible = 0 then

                    member ("endIt").text = "LUNCH IS FOR THE BIRDS"

                    member ("tellIt").text = "TIME FLIES"

                    _movie.go(31)

                  end if

                 

              end case

             

            end timeUp

            • 3. Re: Problem with Lingo If statements - Director
              Imposturous Level 1

              Thank you.  I gave up on having a timer because I was having such a problem.