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 revisionPrevious revision
Last revisionBoth sides next revision
custom-classes [2020/07/08 10:57] – [Custom components] maximecustom-classes [2020/07/08 11:18] 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: 2022/03/29 20:36 by minotorious

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki