Hi,
How do I store the name of a class in a variable?
For example I have a class called "Hit".
The player object has the following attribute:
self.skill = Hit
Calling player.skill.new() doesn't work.
I need to store what kind of skill the player has, but don't want to initialize it right away.
Can I store classes in an associative table? I can't imagine how this would look, but it would solve my problem by something like skills[player.skill].new()
Comments
it should have worked the way you stated, saving class in a variable.
Example that works for me:
When you say 'doesn't work', what happens exactly ?
I actually forgot to add skill to fighter (who then uses it). Therefore it said "try to access a nil value". Kind of a dumb mistake, but thanks for your both responses, saved a lot of wondering on my side!
Tl;dr: lua ftw