I've tried defining my class on a file called "basic.lua" called "Point" and tried to implement it on the file "main.lua" but I keep getting this error:
Error
Syntax error: basic.lua:3: '(' expected near 'Point'
Traceback
[C]: at 0x7ffc269728f0
[C]: in function 'require'
main.lua:3: in function 'load'
[C]: in function 'xpcall'
[C]: in function 'xpcall'
Here is my code for "basic.lua"
return {
function Point(self, x, y)
local Point = {
x = x;
y = y;
AsString = function(self)
print("{x: " + self.x + ", y: " + self.y + "}");
end;
}
return Point;
end;
};
and here is my code for "main.lua"
function love.load()
local Basic = require("basic");
PlayerAcceleration = Basic.Point:new{1, 2};
PlayerVelocity = Basic.Point:new{0, 0};
PlayerPosition = Basic.Point:new{0, 0};
love.graphics.print(PlayerAcceleration.AsString(), 0, 0, 0, 1, 1, 0, 0, 0, 0);
end;
I'm struggling with Lua's classes a lot so any help would be appreciated.