Help on ...more than 60 upvalues

Hi everyone…

I have seen the error …more than 60 upvalues

a few times, when I have a lot of code in one scene

I just take some part’s of that code and move it to another scene

like I just take 4 images and from create Scene and move them to show scene

But now I did that and I have almost nothing, and still I get that 60 upvalues problem.


I have a keyboard on my app(with 13 white and black rectangles, to form the piano)

on each rectangle I am adding an event listener to do something

inside that function I have something like this

    local function playFaSharp()         if isRightFaS == true then          if isRightSolB == true then             if numberRnd == 16 then                 print ("Solb Bemol")                 if pmLive \>= 1 then                     if isMoving == false then                         moveBoat()                         changeNotes()                     end                 end             end         else         if isRightFaS == true then                 if numberRnd == 9 then                     print ("Fa# Sostenido")                     if pmLive \>= 1 then                         if isMoving == false then                             moveBoat()                             changeNotes()                         end                     end                 end         else         destroyBoat( )         end     end         audio.play(playGsound)         return true     end     keyFaS:addEventListener("tap", playFaSharp)

I think if I have that 13 times, probably that is too much

but I don’t know how to do that better, or with less code

I have seen something like

if red == true or yellow == false then

but I don’t really know how to do this

I hope someone can help me figure this up

and I would like to know more why is the 60 upvalue error

thanks

Usually that sort of error occurs when you have too many or not enough end statements. Your code above is a good example, because it’s not indented properly you’ve lost track of which end belongs to which code block and there is actually one too few.

[lua]

local function playFaSharp()

  if isRightFaS == true then

    if isRightSolB == true then

      if numberRnd == 16 then

        print (“Solb Bemol”)

        if pmLive >= 1 then

          if isMoving == false then

            moveBoat()

            changeNotes()

          end

        end

      end

    else

      if isRightFaS == true then

        if numberRnd == 9 then

          print (“Fa# Sostenido”)

          if pmLive >= 1 then

            if isMoving == false then

              moveBoat()

              changeNotes()

            end

          end

        end

      else

        destroyBoat( )

      end

    end

        audio.play(playGsound)

        return true

  end

– end missing here

[/lua]

Thanks… is there a way to make this kind of comparing stuff

much easier?

Use an editor that automatically indents. My Outlaw does it, and I would be surprised if Glider and Sublime don’t, as well.

 Jay

PS - Don’t indent with spaces – use tabs because that gives you easy options later if you need to reformat.

The Free textwrangler does this as well!

Usually that sort of error occurs when you have too many or not enough end statements. Your code above is a good example, because it’s not indented properly you’ve lost track of which end belongs to which code block and there is actually one too few.

[lua]

local function playFaSharp()

  if isRightFaS == true then

    if isRightSolB == true then

      if numberRnd == 16 then

        print (“Solb Bemol”)

        if pmLive >= 1 then

          if isMoving == false then

            moveBoat()

            changeNotes()

          end

        end

      end

    else

      if isRightFaS == true then

        if numberRnd == 9 then

          print (“Fa# Sostenido”)

          if pmLive >= 1 then

            if isMoving == false then

              moveBoat()

              changeNotes()

            end

          end

        end

      else

        destroyBoat( )

      end

    end

        audio.play(playGsound)

        return true

  end

– end missing here

[/lua]

Thanks… is there a way to make this kind of comparing stuff

much easier?

Use an editor that automatically indents. My Outlaw does it, and I would be surprised if Glider and Sublime don’t, as well.

 Jay

PS - Don’t indent with spaces – use tabs because that gives you easy options later if you need to reformat.

The Free textwrangler does this as well!