Class Variant

Variant metatype, wrapper for godot_variant.

Useful for interfacing directly with the GDNative API. Construct using the idiom Variant(value), which calls __new.

Tables

Variant.Type Alias for GD.VariantType

Methods

Variant:as_aabb () Return the Variant as an AABB.
Variant:as_array () Return the Variant as a Array.
Variant:as_basis () Return the Variant as a Basis.
Variant:as_bool () Return the Variant as a boolean.
Variant:as_color () Return the Variant as a Color.
Variant:as_dictionary () Return the Variant as a Dictionary.
Variant:as_int () Return the Variant as an integer.
Variant:as_node_path () Return the Variant as a NodePath.
Variant:as_object () Return the Variant as an Object.
Variant:as_plane () Return the Variant as a Plane.
Variant:as_pool_byte_array () Return the Variant as a PoolByteArray.
Variant:as_pool_color_array () Return the Variant as a PoolColorArray.
Variant:as_pool_int_array () Return the Variant as a PoolIntArray.
Variant:as_pool_real_array () Return the Variant as a PoolRealArray.
Variant:as_pool_string_array () Return the Variant as a PoolStringArray.
Variant:as_pool_vector2_array () Return the Variant as a PoolVector2Array.
Variant:as_pool_vector3_array () Return the Variant as a PoolVector3Array.
Variant:as_quat () Return the Variant as a Quat.
Variant:as_real () Return the Variant as an number.
Variant:as_rect2 () Return the Variant as a Rect2.
Variant:as_rid () Return the Variant as a RID.
Variant:as_string () Return the Variant as a String.
Variant:as_transform () Return the Variant as a Transform.
Variant:as_transform2d () Return the Variant as a Transform2D.
Variant:as_uint () Return the Variant as an unsigned integer.
Variant:as_vector2 () Return the Variant as a Vector2.
Variant:as_vector3 () Return the Variant as a Vector3.
Variant:call (method, ...) Call method with the passed name and arguments.
Variant:get_type () Returns the Variant type enum value (enum godot_variant_type).
Variant:get_type_name () Returns the Variant type name.
Variant:has_method (method) Returns true if Variant has method method.
Variant:hash_compare (other) Returns true if Variant's hash is equal to other's.
Variant:pcall (method, ...) Make a protected call to method with the passed name and arguments.
Variant:unbox () Unbox a Variant, returning the corresponding Lua object.

Metamethods

Variant:__concat (a, b) Concatenates values.
Variant:__eq (a, b) Equality comparison (a == b).
Variant:__eq (a, b) Less than comparison (a < b).
Variant:__new (value) Variant constructor, called by the idiom Variant(value).
Variant:__tostring () Returns a Lua string from the result of as_string.


Tables

Variant.Type
Alias for GD.VariantType

Methods

Variant:as_aabb ()
Return the Variant as an AABB.

Returns:

    AABB
Variant:as_array ()
Return the Variant as a Array.

Returns:

    Array
Variant:as_basis ()
Return the Variant as a Basis.

Returns:

    Basis
Variant:as_bool ()
Return the Variant as a boolean.

Returns:

    bool
Variant:as_color ()
Return the Variant as a Color.

Returns:

    Color
Variant:as_dictionary ()
Return the Variant as a Dictionary.

Returns:

    Dictionary
Variant:as_int ()
Return the Variant as an integer.

Returns:

    int64_t
Variant:as_node_path ()
Return the Variant as a NodePath.

Returns:

    NodePath
Variant:as_object ()
Return the Variant as an Object. If object is a Reference, it is automatically referenced and marked for unreferencing upon garbage-collection.

Returns:

    Object
Variant:as_plane ()
Return the Variant as a Plane.

Returns:

    Plane
Variant:as_pool_byte_array ()
Return the Variant as a PoolByteArray.

Returns:

    PoolByteArray
Variant:as_pool_color_array ()
Return the Variant as a PoolColorArray.

Returns:

    PoolColorArray
Variant:as_pool_int_array ()
Return the Variant as a PoolIntArray.

Returns:

    PoolIntArray
Variant:as_pool_real_array ()
Return the Variant as a PoolRealArray.

Returns:

    PoolRealArray
Variant:as_pool_string_array ()
Return the Variant as a PoolStringArray.

Returns:

    PoolStringArray
Variant:as_pool_vector2_array ()
Return the Variant as a PoolVector2Array.

Returns:

    PoolVector2Array
Variant:as_pool_vector3_array ()
Return the Variant as a PoolVector3Array.

Returns:

    PoolVector3Array
Variant:as_quat ()
Return the Variant as a Quat.

Returns:

    Quat
Variant:as_real ()
Return the Variant as an number.

Returns:

    number
Variant:as_rect2 ()
Return the Variant as a Rect2.

Returns:

    Rect2
Variant:as_rid ()
Return the Variant as a RID.

Returns:

    RID
Variant:as_string ()
Return the Variant as a String.

Returns:

    String
Variant:as_transform ()
Return the Variant as a Transform.

Returns:

    Transform
Variant:as_transform2d ()
Return the Variant as a Transform2D.

Returns:

    Transform2D
Variant:as_uint ()
Return the Variant as an unsigned integer.

Returns:

    uint64_t
Variant:as_vector2 ()
Return the Variant as a Vector2.

Returns:

    Vector2
Variant:as_vector3 ()
Return the Variant as a Vector3.

Returns:

    Vector3
Variant:call (method, ...)
Call method with the passed name and arguments.

Parameters:

  • method Method name, stringified with GD.str
  • ... Arguments passed to method

Returns:

    Method call result

See also:

Variant:get_type ()
Returns the Variant type enum value (enum godot_variant_type). Use get_type_name or Variant.Type to get the type name.

Returns:

    int
Variant:get_type_name ()
Returns the Variant type name.

Returns:

    string
Variant:has_method (method)
Returns true if Variant has method method.

Parameters:

  • method Method name, stringified with GD.str

Returns:

    bool
Variant:hash_compare (other)
Returns true if Variant's hash is equal to other's.

Parameters:

  • other Other value, boxed by __new

Returns:

    bool
Variant:pcall (method, ...)
Make a protected call to method with the passed name and arguments.

Parameters:

  • method Method name, stringified with GD.str
  • ... Arguments passed to method

Returns:

  1. bool true if method was called successfully
  2. Method call result

Or

  1. bool false on errors
  2. Error message

See also:

Variant:unbox ()
Unbox a Variant, returning the corresponding Lua object.

Returns:

    nil, bool, number, String, Vector2, Rect2, Vector3, Transform2D, Plane, Quat, AABB, Basis, Transform, Color, NodePath, RID, Object, Dictionary, Array, PoolByteArray, PoolIntArray, PoolRealArray, PoolStringArray, PoolVector2Array, PoolVector3Array or PoolColorArray

Metamethods

Variant:__concat (a, b)
Concatenates values.

Parameters:

  • a First value, stringified with GD.str
  • b First value, stringified with GD.str

Returns:

    String
Variant:__eq (a, b)
Equality comparison (a == b).

Parameters:

  • a First value, boxed with __new
  • b Second value, boxed with __new

Returns:

    bool
Variant:__eq (a, b)
Less than comparison (a < b).

Parameters:

  • a First value, boxed with __new
  • b Second value, boxed with __new

Returns:

    bool
Variant:__new (value)
Variant constructor, called by the idiom Variant(value).

Parameters:

  • value Value to be boxed

Returns:

    Variant
Variant:__tostring ()
Returns a Lua string from the result of as_string.

Returns:

    string
generated by LDoc 1.4.6 Last updated 2023-01-04 08:52:34