If I have a class defined with the string "Player" like so:
class('Player').extends()
Am I able to get a reference to that class later from the string "Player"?
I am reading level data in from a file and was hoping that it would be easy to read in an entity in that file with a name like "Player" and easily instantiate that object with Player(), but I am not seeing anyway to get from a string to the object class once it has been declared. Does that just not exist?
I can do something silly like:
function getClassFromString(s)
if s == "Player" then return Player end
end
...
-- elsewhere, in the main file
local class = getClassFromString("Player")
local player = class()
That seems to work. But then I'd need to update this function for every single kind of Class that I could potentially be reading in from the file, which seems like a pain. Is there really no way to go from the string name of the class to the class itself that I am missing?