6 Replies Latest reply on Jan 19, 2009 6:40 PM by fazstp

    Problem with statements

    nick2price Level 1
      I am doing multiple comparisons, but for some reason it is complaining about my usage of the word and. This is my script
      on exitFrame
      if sprite(12).loc = point(450, 388) and
      sprite(13).loc = point(408, 390) and
      sprite(14).loc = point(320, 389) and
      sprite(15).loc = point(358, 389) and
      sprite(16).loc = point(285, 389) then
      go to frame 26
      else

      go to the frame

      end if
      end

      Any help in letting me know whats wrong would be a great help.
      thanks
        • 1. Re: Problem with statements
          Level 7
          If you are really putting each condition on a single line then you need
          to add the continuation character to the end. Otherwise put it all on
          one line.

          nick2price wrote:
          > I am doing multiple comparisons, but for some reason it is complaining about my
          > usage of the word and. This is my script
          > on exitFrame
          > if sprite(12).loc = point(450, 388) and
          > sprite(13).loc = point(408, 390) and
          > sprite(14).loc = point(320, 389) and
          > sprite(15).loc = point(358, 389) and
          > sprite(16).loc = point(285, 389) then
          > go to frame 26
          > else
          >
          > go to the frame
          >
          > end if
          > end
          >
          > Any help in letting me know whats wrong would be a great help.
          > thanks
          >
          • 2. Re: Problem with statements
            Level 7
            on exitFrame if sprite(12).loc = point(450, 388) and \
            sprite(13).loc = point(408, 390) and \
            sprite(14).loc = point(320, 389) and \
            sprite(15).loc = point(358, 389) and \
            sprite(16).loc = point(285, 389) then
            go to frame 26
            else

            go to the frame

            end if
            end
            • 3. Re: Problem with statements
              Level 7
              Oops...

              on exitFrame
              if sprite(12).loc = point(450, 388) and \
              sprite(13).loc = point(408, 390) and \
              sprite(14).loc = point(320, 389) and \
              sprite(15).loc = point(358, 389) and \
              sprite(16).loc = point(285, 389) then
              go to frame 26
              else

              go to the frame

              end if
              end
              • 4. Re: Problem with statements
                fazstp Level 2
                Or if you don't like line continuation and you want seperate lines;

                on exitFrame
                v_aligned = TRUE
                if NOT ( sprite( 12 ).loc = point( 450, 388 ) ) then v_aligned = FALSE
                if NOT ( sprite( 13 ).loc = point( 408, 390 ) ) then v_aligned = FALSE
                if NOT ( sprite( 14 ).loc = point( 320, 389 ) ) then v_aligned = FALSE
                if NOT ( sprite( 15 ).loc = point( 358, 389 ) ) then v_aligned = FALSE
                if NOT ( sprite( 16 ).loc = point( 285, 389 ) ) then v_aligned = FALSE

                if ( v_aligned = TRUE ) then
                go frame 26
                else
                go the frame
                end if
                end

                • 5. Re: Problem with statements
                  nick2price Level 1
                  It doesnt throw any errors but its not working with the last replies suggestions. Should i be closing more end if's?
                  • 6. Re: Problem with statements
                    fazstp Level 2
                    You could attach a simple behaviour to sprites 12-16

                    on mouseUp me
                    put "Sprite" && me.spriteNum & ":" && sprite( me.spriteNum ).loc
                    end

                    So you can see the loc that you have moved the sprite to and compare them to the exitFrame locations you are checking.