• Advertisement
Sign in to follow this  

LuaInterface - Extending Imported Types

This topic is 3729 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

First, I've just recently started with Lua and a few early achievements mislead me to think Lua was a fairly easy language. Please bear with me while I try to explain. Is it possible to have a table "inherit" from an imported type? Is it possible to extend this newly created table so that additional methods might be called? Let's say I have a Control, imported in Lua via import_type("MyNamespace.Control"). What I'm trying to achieve is in the following pseudocode:
Button = InheritsFrom(Control)

function Button(name, parent)
   [...]
end function

-- "extending" the Control type in the Button table (?)
function Button:SetNormalTexture(texture)
   [...]
end function

-- the end-user should be able to create a button like this:
testButton = Button("test", nil)
The Control types accepts a constructor with a void (string, Control) signature. All of this comes from the necessity of not hardcoding the standard controls of the user interface I'm currently working on. I hope someone well versed in Lua can explain me how / whether this can be accomplished. Thanks for reading!

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement