Love2D APIDataModuleOn this pageDataModule Description: Provides functionality for creating and transforming data. newByteData Type: Function. Description: Creates a new Data object containing arbitrary bytes. -- Data:getPointer along with LuaJIT's FFI can be used to manipulate the contents of the ByteData object after it has been created. Signature: newByteData: function(size: integer): ByteData Parameters: ParameterTypeDescriptionsizeintegerThe size in bytes of the new Data object. (Default: data:getSize().) Returns: Return TypeDescriptionByteDatabytedata — The new Data object. newByteData Type: Function. Description: Creates a new Data object containing arbitrary bytes. -- Data:getPointer along with LuaJIT's FFI can be used to manipulate the contents of the ByteData object after it has been created. Signature: newByteData: function(bytes: string): ByteData Parameters: ParameterTypeDescriptionbytesstringThe size in bytes of the new Data object. Returns: Return TypeDescriptionByteDatabytedata — The new Data object. newByteData Type: Function. Description: Creates a new Data object containing arbitrary bytes. -- Data:getPointer along with LuaJIT's FFI can be used to manipulate the contents of the ByteData object after it has been created. Signature: newByteData: function(data: Data, offset?: integer, size?: integer): ByteData Parameters: ParameterTypeDescriptiondataDataThe existing Data object to copy.offsetintegerThe offset of the subsection to copy, in bytes. (Default: 0.)sizeintegerThe size in bytes of the new Data object. Returns: Return TypeDescriptionByteDatabytedata — The new Data object. newDataView Type: Function. Description: Creates a new Data referencing a subsection of an existing Data object. Overload details: Data:getString and Data:getPointer will return the original Data object's contents, with the view's offset and size applied. Signature: newDataView: function(data: any, offset: integer, size: integer): DataView Parameters: ParameterTypeDescriptiondataanyThe Data object to reference.offsetintegerThe offset of the subsection to reference, in bytes.sizeintegerThe size in bytes of the subsection to reference. Returns: Return TypeDescriptionDataViewThe new Data view. encode Type: Function. Description: Encode Data or a string to a Data or string in one of the EncodeFormats. Signature: encode: function(container: string, format: EncodeFormat, source: string | Data, line_length?: integer): string Parameters: ParameterTypeDescriptioncontainerstringWhat type to return the encoded data as.formatEncodeFormatThe format of the output data.sourcestringDataline_lengthintegerThe maximum line length of the output. Only supported for base64, ignored if 0. (Default: 0.) Returns: Return TypeDescriptionstringencoded — ByteData/string which contains the encoded version of source. encode Type: Function. Description: Encode Data or a string to a Data or string in one of the EncodeFormats. Signature: encode: function(container: string, format: EncodeFormat, source: string | Data, line_length?: integer): ByteData Parameters: ParameterTypeDescriptioncontainerstringWhat type to return the encoded data as.formatEncodeFormatThe format of the output data.sourcestringDataline_lengthintegerThe maximum line length of the output. Only supported for base64, ignored if 0. (Default: 0.) Returns: Return TypeDescriptionByteDataencoded — ByteData/string which contains the encoded version of source. decode Type: Function. Description: Decode Data or a string from any of the EncodeFormats to Data or string. Signature: decode: function(container: string, format: EncodeFormat, source: string | Data): string Parameters: ParameterTypeDescriptioncontainerstringWhat type to return the decoded data as.formatEncodeFormatThe format of the input data.sourcestringData Returns: Return TypeDescriptionstringdecoded — ByteData/string which contains the decoded version of source. decode Type: Function. Description: Decode Data or a string from any of the EncodeFormats to Data or string. Signature: decode: function(container: string, format: EncodeFormat, source: string | Data): ByteData Parameters: ParameterTypeDescriptioncontainerstringWhat type to return the decoded data as.formatEncodeFormatThe format of the input data.sourcestringData Returns: Return TypeDescriptionByteDatadecoded — ByteData/string which contains the decoded version of source. compress Type: Function. Description: Compresses a string or data using a specific compression algorithm. Signature: compress: function(container: string, format: CompressionFormat, source: string | Data, level?: integer): string Parameters: ParameterTypeDescriptioncontainerstringWhat type to return the compressed data as.formatCompressionFormatThe format to use when compressing the string.sourcestringDatalevelintegerThe level of compression to use, between 0 and 9. -1 indicates the default level. The meaning of this argument depends on the compression format being used. (Default: -1.) Returns: Return TypeDescriptionstringcompressedData — CompressedData/string which contains the compressed version of rawstring. compress Type: Function. Description: Compresses a string or data using a specific compression algorithm. Signature: compress: function(container: string, format: CompressionFormat, source: string | Data, level?: integer): CompressedData Parameters: ParameterTypeDescriptioncontainerstringWhat type to return the compressed data as.formatCompressionFormatThe format to use when compressing the data.sourcestringDatalevelintegerThe level of compression to use, between 0 and 9. -1 indicates the default level. The meaning of this argument depends on the compression format being used. (Default: -1.) Returns: Return TypeDescriptionCompressedDataCompressedData/string which contains the compressed version of data. decompress Type: Function. Description: Decompresses a CompressedData or previously compressed string or Data object. Signature: decompress: function(container: string, compressed: CompressedData): string Parameters: ParameterTypeDescriptioncontainerstringWhat type to return the decompressed data as.compressedCompressedDataThe compressed data to decompress. Returns: Return TypeDescriptionstringdecompressedData — Data/string containing the raw decompressed data. decompress Type: Function. Description: Decompresses a CompressedData or previously compressed string or Data object. Signature: decompress: function(container: string, compressed: CompressedData): ByteData Parameters: ParameterTypeDescriptioncontainerstringWhat type to return the decompressed data as.compressedCompressedDataThe compressed data to decompress. Returns: Return TypeDescriptionByteDatadecompressedData — Data/string containing the raw decompressed data. decompress Type: Function. Description: Decompresses a CompressedData or previously compressed string or Data object. Signature: decompress: function(container: string, format: CompressionFormat, source: string | Data): string Parameters: ParameterTypeDescriptioncontainerstringWhat type to return the decompressed data as.formatCompressionFormatThe format that was used to compress the given data.sourcestringData Returns: Return TypeDescriptionstringdecompressedData — Data/string containing the raw decompressed data. decompress Type: Function. Description: Decompresses a CompressedData or previously compressed string or Data object. Signature: decompress: function(container: string, format: CompressionFormat, source: string | Data): ByteData Parameters: ParameterTypeDescriptioncontainerstringWhat type to return the decompressed data as.formatCompressionFormatThe format that was used to compress the given data.sourcestringData Returns: Return TypeDescriptionByteDatadecompressedData — Data/string containing the raw decompressed data. pack Type: Function. Description: Packs (serializes) simple Lua values. -- This function behaves the same as Lua 5.3's string.pack. Signature: pack: function(container: string, format: string, values: any...): string Parameters: ParameterTypeDescriptioncontainerstringWhat type to return the encoded data as.formatstringA string determining how the values are packed. Follows the rules of Lua 5.3's string.pack format strings.valuesany...The first value (number, boolean, or string) to serialize. Returns: Return TypeDescriptionstringdata — Data/string which contains the serialized data. pack Type: Function. Description: Packs (serializes) simple Lua values. -- This function behaves the same as Lua 5.3's string.pack. Signature: pack: function(container: string, format: string, values: any...): ByteData Parameters: ParameterTypeDescriptioncontainerstringWhat type to return the encoded data as.formatstringA string determining how the values are packed. Follows the rules of Lua 5.3's string.pack format strings.valuesany...The first value (number, boolean, or string) to serialize. Returns: Return TypeDescriptionByteDatadata — Data/string which contains the serialized data. unpack Type: Function. Description: Unpacks (deserializes) a byte-string or Data into simple Lua values. -- This function behaves the same as Lua 5.3's string.unpack. Signature: unpack: function(format: string, source: string, position?: integer): any... Parameters: ParameterTypeDescriptionformatstringA string determining how the values were packed. Follows the rules of Lua 5.3's string.pack format strings.sourcestringA string containing the packed (serialized) data.positionintegerWhere to start reading in the string. Negative values can be used to read relative from the end of the string. (Default: 1.) Returns: Return TypeDescriptionany...v1 — The first value (number, boolean, or string) that was unpacked. unpack Type: Function. Description: Unpacks (deserializes) a byte-string or Data into simple Lua values. -- This function behaves the same as Lua 5.3's string.unpack. Signature: unpack: function(format: string, source: Data, position?: integer): any... Parameters: ParameterTypeDescriptionformatstringA string determining how the values were packed. Follows the rules of Lua 5.3's string.pack format strings.sourceDataA Data object containing the packed (serialized) data.positioninteger1-based index indicating where to start reading in the Data. Negative values can be used to read relative from the end of the Data object. (Default: 1.) Returns: Return TypeDescriptionany...v1 — The first value (number, boolean, or string) that was unpacked. getPackedSize Type: Function. Description: Gets the size in bytes that a given format used with love.data.pack will use. This function behaves the same as Lua 5.3's string.packsize. Overload details: The format string cannot have the variable-length options 's' or 'z'. Signature: getPackedSize: function(format: string): integer Parameters: ParameterTypeDescriptionformatstringA string determining how the values are packed. Follows the rules of Lua 5.3's string.pack format strings. Returns: Return TypeDescriptionintegerThe size in bytes that the packed data will use. hash Type: Function. Description: Compute the message digest of a string using a specified hash algorithm. Signature: hash: function(hash_function: HashFunction, source: string): string Parameters: ParameterTypeDescriptionhash_functionHashFunctionHash algorithm to use.sourcestringString to hash. Returns: Return TypeDescriptionstringrawdigest — Raw message digest string. hash Type: Function. Description: Compute the message digest of a string using a specified hash algorithm. Signature: hash: function(hash_function: HashFunction, source: Data): string Parameters: ParameterTypeDescriptionhash_functionHashFunctionHash algorithm to use.sourceDataData to hash. Returns: Return TypeDescriptionstringrawdigest — Raw message digest string.