Skip to Content
Welcome to the Spectrum Documentation

Data

source: Data.gd

Copyright (c) 2026
Liam Sherwin — All rights reserved.
Licensed under GPLv3

Data is a static utility class that defines custom data types, serialization flags, and network flags used across the Spectrum Lighting Engine. It provides the canonical Type enum used throughout the codebase to describe and identify data, along with a mapping from those types to their underlying GDScript Variant.Type equivalents, and a small set of static utility methods for type comparison and conversion.


Enums

Type

The primary type enum used across the engine to identify and describe data values.

NameValueDescription
NULL0Represents no value.
ANY1Represents an untyped Variant.
STRING2A text string.
BOOL3A true/false boolean.
INT4A 64-bit integer.
FLOAT5A floating-point number.
ARRAY6A dynamic array of values.
DICTIONARY7A key/value map.
VECTOR28A 2D vector (x, y) with floats.
VECTOR2I9A 2D vector (x, y) with integers.
RECT210A 2D rectangle defined by position and size, using floats.
RECT2I11A 2D rectangle defined by position and size, using integers.
VECTOR312A 3D vector (x, y, z) with floats.
VECTOR3I13A 3D vector (x, y, z) with integers.
VECTOR414A 4D vector (x, y, z, w) with floats.
VECTOR4I15A 4D vector (x, y, z, w) with integers.
COLOR16A colour with red, green, blue, and alpha channels.
OBJECT17A reference to any Godot Object.
CALLABLE18A callable function reference.
SIGNAL19A signal reference.
ENUM20An enumerator value.
BITFLAGS21A bitmask of flags.
IP22An IP address, stored as a IPAddr object.
INPUTEVENT23A Godot InputEvent.
SETTINGSMANAGER24A SettingsManager instance.
PACKEDSCENE25A PackedScene resource.
ACTION26A triggerable action.

SerializationFlags

Flags that control serialization behaviour. These are bitmask values and may be combined.

NameValueDescription
NONE0No special serialization behaviour.
REALTIME1Include realtime data that is not normally saved. Useful for state synchronisation.
NO_UUID2Exclude the object’s UUID. Useful when duplicating objects.

NetworkFlags

Flags that control how an object participates in network serialization. These are bitmask values and may be combined.

NameValueDescription
NONE0No special network behaviour.
ALLOW_SERIALIZE1Allow the object to be serialized in outgoing messages.
ALLOW_DESERIALIZE2Allow the object to be deserialized from incoming messages.
ALLOW_UNRESOLVED4Return the object’s UUID if the object cannot be resolved, rather than failing.

Member Variables

Sub

DataType: DataConfig.SubType
An instance of DataConfig.SubType exposing sub-type definitions sourced from DataConfig. Provides access to additional type values beyond those defined in Type. Use as Data.Sub.VALUE_NAME.


custom_type_map

DataType: Dictionary[Type, Variant.Type]
A static dictionary mapping each Type value to its corresponding GDScript Variant.Type. Used to determine the underlying Godot type for a given Data.Type. Several Data.Type values share a base Variant.Type — for example, ENUM and BITFLAGS both map to TYPE_INT, and IP maps to TYPE_OBJECT as IP is stored as an IPAddr object.


Public API

do_types_match_base

Args:

  • Type: p_type_one
  • Type: p_type_two

Returns: bool

Returns true if both given Data.Type values share the same underlying Variant.Type in custom_type_map. Useful for checking type compatibility without requiring an exact Data.Type match.


custom_type_to_string

Args:

  • Variant: p_variant
  • Type: p_orignal_type

Returns: String

Converts a value to a human-readable string, taking the original Data.Type into account. If a custom conversion callable has been configured via DataConfig, it is called first. If the callable is not set or does not return a String, the value is converted using GDScript’s built-in type_convert.


get_object_name_changed_signal

Args: SettingsModule: p_module
Returns: Signal

Returns the signal emitted when the name of the object held by the given SettingsModule changes. If a custom callable is configured via DataConfig, it is used to resolve the signal. Otherwise, the method falls back to returning the renamed signal if the object is a Node, or an empty Signal() if it is not.


get_object_db

Args: Object: p_object
Returns: ObjectDB

Returns the ObjectDB that the given object’s type belongs to. If no custom callable is configured via DataConfig, returns null.


Notes

  • Data is a static class. All members and methods are static or class-level. It is not expected to be instantiated.
  • custom_type_to_string, get_object_name_changed_signal, and get_object_db all depend on callables configured in DataConfig. Behaviour may vary or fall back to defaults if DataConfig is not present or the callables are not set.
Last updated on