FerbZides
(FerbZides)
January 8, 2021, 8:12am
1
Basically what I want is that if an metatable already exists then I would not use something like module.new()
Here is an simple OOP Module:
local module = {}
module.__index = module
function module.new()
local BallStats = {}
BallStats.PickUp = false
BallStats.StealDelay = 1.5
BallStats.BallHandler = ""
BallStats.Power = 75
return setmetatable(BallStats, module)
end
return module
Blockzez
(Blockzez)
January 8, 2021, 8:17am
2
Maybe you’re looking for getmetatable?
getmetatable(value) ~= nil
FerbZides
(FerbZides)
January 8, 2021, 8:18am
3
exactly! but what is value? the metatable we are getting?
Blockzez
(Blockzez)
January 8, 2021, 8:22am
4
Whatever the metatable you’ve setted (unless the __metatable field is present, then it’ll get that value), if there isn’t any, it’ll be nil.
You can easily search this up: Programming in Lua : 13