Topic: Classes in Lua (A little help)
I guess classes aren't a part of lua, but I found a tutorial on youtube that shows you how to fake it. And it fakes it really well:
https://www.youtube.com/watch?v=jq58moMWlT8
But! I modified his example a little, and I need suggestions on how to make it more authentic (If it can be any more authentic):
--New Person Class
function newPerson(name,age)
local object = {}
object.name = name
object.age = age
function object:sayName()
print (object.name)
end
return object
end
--Create Joe
local joe = newPerson("Joe",24)
--Create Bill
local bill = newPerson("Bill",25)
--Print Joe's name
print (joe.name)
--Make Bill say his name
bill:sayName()
Last edited by Tutorial Doctor (2013-08-23 05:57:45)