Jump to content

Lua Classes


meia-lua
 Share

Recommended Posts

Hello,

After calling some of the LeadWerks functions in Lua it dawned upon me that I have no idea how they have been implemented (not that it makes any difference to use them), I would just like to understand how they have been implemented. 

I thought the classes would just be Lua tables and then methods are elements within the table but the length of any class is zero. It also appears that the Script class has been implemented differently and doesn't exist as a Lua object. 

I have seen function calls like this:

Quote

self.entity:Turn(0,0,1)

Wouldn't self be redundant if Lua represented all classes such as entity as tables.

Link to comment
Share on other sites

Basically, in Lua a table is associated with an entity, and the entity is a member of the table. thus you call self.entity to get the entity.

The entity object in Lua is a "userdata" object. I think they use metatables or something to represent the C++ functions. I use tolua++ for the binding code.

  • Thanks 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...