Sign in to follow this  
OmarShehata

Class-completion in lua? (OOP)

Recommended Posts

So I've been delving into Lua for a few days, and I've been reading about how to use metatables and whatnot to "simulate" OOP. However one thing that I can't seem to get the hang of is, assume I've gotten a "class" set up as a table with functions and variables inside this table.

Now when I make an "instance" of this "class", and set it as my metatable and all that, a really crucial thing is that when I type dot after my object, it should show the methods and variables inside its class. Otherwise things can get pretty messy.

Any idea how I can get this done? I'm using Sublime Text 2 as my code editor.

Thanks!

Share this post


Link to post
Share on other sites
For anyone who's interested, this doesn't actually seem to be possible due to Lua's loose nature. And while not directly fixing this, some scripts which are based on Lua make using it have a lot less headaches such as [url="http://moonscript.org/"]MoonScript[/url] which seems to be better at OOP, as well as [url="http://www.squirrel-lang.org/"]Squirrel[/url] and [url="https://love2d.org/forums/viewtopic.php?f=3&t=9069"]Killa[/url]. All these scripts compile to Lua.

I've chosen to use Killa because it has the least changes to the structure of the language so that it can be easily used/ported with existing code and adds some really crucial stuff.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this