Omni Cloud
Banned User
- Joined
- May 31, 2016
- Messages
- 308
- Reaction score
- 149
I am not exactly certain how a metatable is constructed but also how it inherits from one metatable to another.
Although this code works, I am not sure how it works if that makes any sense.
Also can anyone point me to a few decent tutorials on the subject
Although this code works, I am not sure how it works if that makes any sense.
Code:
Creature = {}
Creature.__index = Creature
setmetatable(Creature, {
__call = function(cls, ...)
return cls.new(...)
end,
})
function Creature:whoami()
return "I am a Creature"
end
Player = getmetatable(setmetatable({}, Creature))
print(Player:whoami())
Code:
I am a Creature
Also can anyone point me to a few decent tutorials on the subject