Module property

Property declarations for scripts.

Functions

export (metadata) Alias for property that always adds PropertyUsage.EDITOR to the usage flags.
property (metadata) Adds metadata to a property.


Functions

export (metadata)
Alias for property that always adds PropertyUsage.EDITOR to the usage flags. This is a shortcut for creating properties that are exported to the editor.

Parameters:

  • metadata Property default value or metadata table

See also:

property (metadata)
Adds metadata to a property. If metadata is not a table, creates a table with this value as default_value. The metadata table may include the following fields:

  • default_value or default or 1: default property value, returned when Object has no other value set for it. If absent, type must be given and a default value for the type will be used instead.
  • type or 2: property type. If absent, it is inferred from default_value. May be a Enumerations.VariantType (VariantType.Vector2), the type directly (Vector2), or a Resource class (AudioStream)
  • (optional) get or getter: getter function. May be a string with the method name to be called or any callable value, like functions and tables with a __call metamethod.
  • (optional) set or setter: setter function. May be a string with the method name to be called or any callable value, like functions and tables with a __call metamethod.
  • (optional) hint: one of Enumerations.PropertyHint. Default to PropertyHint.NONE.
  • (optional) hint_string: the hint text, required for some hints like RANGE.
  • (optional) usage: one of Enumerations.PropertyUsage. Default to PropertyUsage.NOEDITOR.
  • (optional) rset_mode: one of Enumerations.RPCMode. Default to RPCMode.DISABLED.

TODO: accept hints directly (range = '1,10'; enum = 'value1,value2,value3'; file = '*.png', etc...).

Parameters:

  • metadata Property default value or metadata table

Returns:

    table

Raises:

If neither default value, type or getter is passed.

See also:

Usage:

    MyClass.some_prop = property(42)
    MyClass.some_prop_with_metadata = property {
        type = int,
        set = function(self, value)
            self.some_prop_with_metadata = value
            self:emit('some_prop_with_metadata_changed', value)
        end,
        hint = PropertyHint.RANGE,
        hint_text = '1,100',
    }
generated by LDoc 1.4.6 Last updated 2023-01-04 08:52:34