Module new_class

An instantiatable class to inherit for defining new instantiatable classes classes the "base" class.

To make a new class call leef.class.new(def) or leef.new_class:new_class(def) Also note that these classes will not have the type table but instead class when type(object) is called. This is apart of the LEEF-class module

Functions

new_class (..., def) creates a new base class.
construct (self) Called when an instance is created.
construct_new_class (self) Called when a new child class is created is created.
new (def) creates an instance of the base class.
dump (self, dump_classes) (for printing) dumps the variables of this class
leef.class.new_class (def) creates a new class
leef.class.is_class (value) checks if something is a class

Fields

instance Indicates wether the object is an instance or the base class
__legacy_inherit Quick dirty way to fix inheritence for old mods.
base_class Only present for instances: reference to the class from which this instance originates
parent_class Reference to the class from which THIS object (or it's base class) was inherited from.


Functions

new_class (..., def)
creates a new base class. Calls all constructors in the chain with def.instance=true. Can also be invoked by calling the class. Constructors will be called in reverse order (that way the first has the "final say" on all fields meaning highest priority)

Parameters:

  • ... additional tables inherited by def
  • def the table containing the base definition of the class. This should contain a construct

Returns:

    def a new base class
construct (self)
Called when an instance is created. will be called for any classes which are children or grandchildren (etc) instances, aswell as instances of this class. use this to instantiate arbitrary data like subclasses. if the field "legacyinherit" is present, it will be called for new base classes as well as the initialization of this base class if present.

Parameters:

  • self the table (which would be def from new()).
construct_new_class (self)
Called when a new child class is created is created. will be called when a new child or grandchild (etc) class is created. useful for instantiation of subtables or any other data.

Parameters:

  • self the table (which would be def from new()).
new (def)
creates an instance of the base class. Calls all constructors in the chain with def.instance=true

Parameters:

  • def field for the new instance of the class. If fields are not present they will refer to the base class's fields (if present in the base class).

Returns:

    self a new instance of the class.
dump (self, dump_classes)
(for printing) dumps the variables of this class

Parameters:

  • self
  • dump_classes bool whether to also print/dump classes.

Returns:

    string
leef.class.new_class (def)
creates a new class

Parameters:

  • def definition of the class

Returns:

    class
leef.class.is_class (value)
checks if something is a class

Parameters:

  • value value

Returns:

    bool

Fields

instance
Indicates wether the object is an instance or the base class
  • instance
__legacy_inherit
Quick dirty way to fix inheritence for old mods.
  • __legacy_inherit
base_class
Only present for instances: reference to the class from which this instance originates
  • base_class
parent_class
Reference to the class from which THIS object (or it's base class) was inherited from. If table is inherited from multiple classes, than value is a dummy table which inherits values of all classes in the order inherted classes were put in.
  • parent_class
generated by LDoc 1.5.0 Last updated 2025-07-13 23:51:10