User Tools

Site Tools


custom-classes

Differences

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

Link to this comparison view

Next revision
Previous revision
Last revisionBoth sides next revision
custom-classes [2020/07/08 10:56] – created maximecustom-classes [2020/07/08 11:18] maxime
Line 6: Line 6:
  
 You can find more information on on the ''registerClass'' function on the [[mod-management-functions#registerClass|mod management functions page]]. You can find more information on on the ''registerClass'' function on the [[mod-management-functions#registerClass|mod management functions page]].
-**[[:custom-classes#Extendable classes|Extendable]]**+ 
 +----
  
 ===== 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>
  
 ---- ----
Line 16: Line 24:
 ===== Custom components ===== ===== Custom components =====
  
-When you define a new component type, you can assign it properties that are editable, usable in your component's behavior, and that can be saved in a savegame. Those properties must have a name and a type. They can also have a default value, flags, and access functions (getter and setter). +For custom types extending ''[[api:component|COMPONENT]]'', you can override some base functions that are automatically called for all components:
- +
-Components can also have functions. In addition to new functions, you can override some base functions that are automatically called for all components:+
   * ''**create**()'': when the component is created   * ''**create**()'': when the component is created
   * ''**init**()'': when the component is initialized in the game   * ''**init**()'': when the component is initialized in the game
custom-classes.txt · Last modified: 2022/03/29 20:36 by minotorious

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki