Jump to content
  • Advertisement
Sign in to follow this  
OmarShehata

Class-completion in lua? (OOP)

This topic is 2168 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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 MoonScript which seems to be better at OOP, as well as Squirrel and Killa. 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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!