--OOP Sandbox
player = {name, level, class}
function player:new()
setmetatable(self)
self.__index = self
end
testplayer = player:new()
testplayer.name = "testplayer" --errors are coming from these lines
testplayer.level = 80 -- here
testplayer.class = "Warrior" --and here
Okay, I have been trying to learn and research how to do basic classes and Object Oriented Programming with LUA, but the guides/references on the web are a bit confusing. I understand why LUA is different than other languages but I am having trouble figuring out syntax and other stuff.
All I want to do is create a basic class and create objects out of it.
I want to reference stuff like:
print testplayer.name
but I am getting an error in the first code block saying
attempt to index global 'testplayer' (a nil value)
What does this error mean and how do I fix it?
Thanks so much in advance!!