Jump to content

Custom element type OOP


rain_gloom

Recommended Posts

How can I add custom OOP methods to a custom element type?

eg.:

(getElementsByType("myElementType")[1]):someCustomMethod() 

:arrowup: That should call a method on the element I created.

It should also support exporting, if possible.

What kind of constructor would I need?

Does the new OOP support this?

Link to comment
myElementType = createElement("myElementType", "yolo") 
local myElementTypeClass = getmetatable(myElementType).__class 
function myElementTypeClass:testFunc() 
    outputChatBox("my Element type id: "..getElementID(self)) 
end 
  
getElementsByType("myElementType")[1]:testFunc() 

Link to comment

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...