I am working on a scripting layer for my game engine. Currently I am using a Script as a Class, adding a method to the "Table" named new. This function basically created an instantiated copy of the Class. I call this function from the C API when an instance of the script is needed.
function PlayerController:new(o)
print('A new instance of the PlayerController has been created');
o = o or {}
setmetatable(o, self)
self.__index = self
return o
end
My question is: How can I take the above Lua code, and move that into C so it is not required to be added to every script file I write for this system?