I have just started delving into Lua, and I learnt that C++ object properties could be accessible through metatables.
I am trying to access such an object's functions in a game's script: "GameLib". It is available in Lua as a global variable, but getmetatable() returns nil:
-- example usage elsewhere in the scripts:
local pPlayer = GameLib.GetLocalPlayer();
-- my tried code:
local mt = getmetatable(GameLib);
print("Metatable type:" .. type(mt)); -- "Metatable type: nil"
What could be the problem? Are there cases, when a C++ object has no metatable? If so, is there another way to access its properties?
Aucun commentaire:
Enregistrer un commentaire