0

I'm trying to create ncar table with 2 different functions: setup ans main_frame

local ncar=
{
    img=display.newImageRect("test_car.png",50,120,true);
    x=0;
    y=0;
    frames=0;
    setup=function(self)
        return self;
    end
    main_frame=function(self)
        self.frames=self.frames+1;
        return function(event)
            self.img.x=self.x;
            self.img.y=self.y;
        end
    end

}

But compiler says that he expects to see '}' where the second function (main_frame in this case) starts, when I add it. What are the reasons?

hjpotter92
  • 78,589
  • 36
  • 144
  • 183
user2136963
  • 2,526
  • 3
  • 22
  • 41

1 Answers1

3

A comma or semicolon is required after setup function definition.
This is because you are creating a table by listing its fields, that should be separated from each other.

Egor Skriptunoff
  • 23,359
  • 2
  • 34
  • 64