I’m scratching my head on this one. I’ve followed a few tutorials on OOP, specifically using metatables and inheritance. Anyways, based on the tutorials I’ve been following, this seems like the correct format of a class (“entities/PowerUp.lua”):
[lua]PowerUp = {}
PowerUp_mt = { __index = PowerUp }
function PowerUp:new()
local powerup = {}
setmetatable( powerup, PowerUp_mt );
return powerup;
end
function PowerUp:className()
print( “PowerUp” );
end
function PowerUp:doSomething()
print( “Doing something” );
end[/lua]
However, when I try to instantiate an instance of this class with the following code in my “main.lua” file:
[lua]local PowerUp = require(“entities.PowerUp”)
local pu = PowerUp:new();[/lua]
I get the following error:
Runtime Error: attempt to index upvalue ‘PowerUp’ (a boolean value)
Just not sure what I’m doing wrong, and hope someone can point me in the right direction.
[import]uid: 49447 topic_id: 16309 reply_id: 316309[/import]