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:
- Variant:as_array ()
-
Return the Variant as a Array.
Returns:
- Variant:as_basis ()
-
Return the Variant as a Basis.
Returns:
- Variant:as_bool ()
-
Return the Variant as a boolean.
Returns:
-
bool
- Variant:as_color ()
-
Return the Variant as a Color.
Returns:
- Variant:as_dictionary ()
-
Return the Variant as a Dictionary.
Returns:
- Variant:as_int ()
-
Return the Variant as an integer.
Returns:
-
int64_t
- Variant:as_node_path ()
-
Return the Variant as a NodePath.
Returns:
- 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:
- Variant:as_plane ()
-
Return the Variant as a Plane.
Returns:
- Variant:as_pool_byte_array ()
-
Return the Variant as a PoolByteArray.
Returns:
- Variant:as_pool_color_array ()
-
Return the Variant as a PoolColorArray.
Returns:
- Variant:as_pool_int_array ()
-
Return the Variant as a PoolIntArray.
Returns:
- Variant:as_pool_real_array ()
-
Return the Variant as a PoolRealArray.
Returns:
- Variant:as_pool_string_array ()
-
Return the Variant as a PoolStringArray.
Returns:
- Variant:as_pool_vector2_array ()
-
Return the Variant as a PoolVector2Array.
Returns:
- Variant:as_pool_vector3_array ()
-
Return the Variant as a PoolVector3Array.
Returns:
- Variant:as_quat ()
-
Return the Variant as a Quat.
Returns:
- Variant:as_real ()
-
Return the Variant as an number.
Returns:
-
number
- Variant:as_rect2 ()
-
Return the Variant as a Rect2.
Returns:
- Variant:as_rid ()
-
Return the Variant as a RID.
Returns:
- Variant:as_string ()
-
Return the Variant as a String.
Returns:
- Variant:as_transform ()
-
Return the Variant as a Transform.
Returns:
- Variant:as_transform2d ()
-
Return the Variant as a Transform2D.
Returns:
- Variant:as_uint ()
-
Return the Variant as an unsigned integer.
Returns:
-
uint64_t
- Variant:as_vector2 ()
-
Return the Variant as a Vector2.
Returns:
- Variant:as_vector3 ()
-
Return the Variant as a Vector3.
Returns:
- 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:
- Variant:has_method (method)
-
Returns
true
if Variant has methodmethod
.Parameters:
- method Method name, stringified with GD.str
Returns:
-
bool
- Variant:hash_compare (other)
-
Returns
true
if Variant's hash is equal toother
'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:
-
bool
true
if method was called successfully - Method call result
Or
-
bool
false
on errors - 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:
Returns:
- Variant:__eq (a, b)
-
Equality comparison (
a == b
).Parameters:
Returns:
-
bool
- Variant:__eq (a, b)
-
Less than comparison (
a < b
).Parameters:
Returns:
-
bool
- Variant:__new (value)
-
Variant constructor, called by the idiom
Variant(value)
.Parameters:
- value Value to be boxed
Returns:
- Variant:__tostring ()
-
Returns a Lua string from the result of as_string.
Returns: