User Tools

Site Tools


custom-classes

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
custom-classes [2020/07/08 10:57]
maxime [Custom components]
custom-classes [2020/07/08 11:18] (current)
maxime
Line 11: Line 11:
 ===== Extendable classes ===== ===== Extendable classes =====
  
-Some core types are flagged as **Extendable** in the documentation. This means an extendable type can be used as parent type when creating a custom type. In addition to new functions, you can override some base functions existing in the parent type, flagged as **virtual**.+Some core types are flagged as **Extendable** in the documentation. This means an extendable type can be used as parent type when creating a custom type. In addition to new functions, you can override some base functions existing in the parent type, flagged as **Virtual function**. When extend a virtual function, define a new function for your custom type with the same type and parameters. You can call the parent function using the keyword ''​super''​. 
 + 
 +<code lua> 
 +function myCustomTypeInfo:​someVirtualFunction(param1,​ param2) 
 +    self.super:​someVirtualFunction(param1,​ param2) 
 +    ... -- custom additional behavior 
 +end 
 +</​code>​
  
 ---- ----
custom-classes.txt · Last modified: 2020/07/08 11:18 by maxime