Jump to content

View more

Image of the Day

雑魚は多めにして、爽快感重視にしつつ・・・(´・ω・`)
早いとこ、ベースを作って、完成にもっていかないとね。
タイトルもまだ迷ってるだよなぁ。 
#indiedev  #indiegame #screenshotsaturday https://t.co/IwVbswGrhe
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Class-completion in lua? (OOP)

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
1 reply to this topic

#1 OmarShehata   Members   

205
Like
0Likes
Like

Posted 14 June 2012 - 04:36 AM

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!

#2 OmarShehata   Members   

205
Like
0Likes
Like

Posted 18 June 2012 - 02:46 AM

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.




Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.