While LUA is not an object oriented programming language, you can mimick your code to act like one. The key here is with the setmetatable() function.

Here is a .lua file containing a simple class.

That’s it! That is all there is to it. Save it as object.lua and now you can simply create a new instance of your class like this:

Related Posts Plugin for WordPress, Blogger...