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. Ifmetadata
is not a table, creates a table with this value asdefault_value
. Themetadata
table may include the following fields:default_value
ordefault
or1
: 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 fromdefault_value
. May be a Enumerations.VariantType (VariantType.Vector2
), the type directly (Vector2), or a Resource class (AudioStream
) - (optional)
get
orgetter
: 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
orsetter
: 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 toPropertyHint.NONE
. - (optional)
hint_string
: the hint text, required for some hints likeRANGE
. - (optional)
usage
: one of Enumerations.PropertyUsage. Default toPropertyUsage.NOEDITOR
. - (optional)
rset_mode
: one of Enumerations.RPCMode. Default toRPCMode.DISABLED
.
TODO: accept hints directly (
range = '1,10'
;enum = 'value1,value2,value3'
;file = '*.png'
, etc...).Parameters:
- metadata Property default value or metadata table
Returns:
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', }