dreamworkAPI
Ctrl K
GitHub
libraryDocs / pack

pack

librarysharedmenusource

Library that packs & unpacks types as strings, same as bytepack does with bytes.

Functions with a size in their name (readUInt16BE, writeFloatLE, readNullTerminatedString, ...) read from a 1-based byte index of the string, same as string.byte, and write a new string:

lua
local data = pack.writeUInt16BE( 300 ) .. pack.writeFloatLE( 1.5 ) --> "\1\44\0\0\192\63"

pack.readUInt16BE( data, 1 ) --> 300
pack.readFloatLE( data, 3 ) --> 1.5

Bit functions (readBit, readBoolean, readBytes, readUInt, readInt, readFixedPoint, readUnsignedFixedPoint) read from a 0-based bit_position instead, so they also read fields that are not aligned to bytes.

Bits are stored LSB-first (bit 0 of the data is the lowest bit of the first byte), and little endian integers are stored lowest bit first, same as Source's bf_write/bf_read, so data is compatible with gmod net.Write*/net.Read*.

All reads throw EndOfFileError when the string is too short.

stack_level of local functions is the level relative to their caller, public functions that tail call them pass 1 (tail calls drop the frame), others pass 2.

Functions

pack.readBitReads one bit from the string.
pack.readBooleanReads one bit from the string as a boolean, same as net.ReadBool.
pack.readBytesReads bytes from any bit position of the string.
pack.readCountedStringReads the string prefixed with its length.
pack.readDateBEReads 2-byte (16 bit) DOS date from big endian bytes of the string.
pack.readDateLEReads 2-byte (16 bit) DOS date from little endian bytes of the string.
pack.readDoubleBEReads double precision (8-byte, 64 bit) floating point number from big endian bytes of the string.
pack.readDoubleLEReads double precision (8-byte, 64 bit) floating point number from little endian bytes of the string.
pack.readFixedPointReads signed fixed-point number (m integer bits including the sign bit and n fractional bits) from any bit position of…
pack.readFixedStringReads the string of a fixed size.
pack.readFloatBEReads single precision (4-byte, 32 bit) floating point number from big endian bytes of the string.
pack.readFloatLEReads single precision (4-byte, 32 bit) floating point number from little endian bytes of the string.
pack.readIntReads signed (two's complement) integer of any size from any bit position of the string.
pack.readInt16BEReads signed 2-byte (16 bit) integer from big endian bytes of the string.
pack.readInt16LEReads signed 2-byte (16 bit) integer from little endian bytes of the string.
pack.readInt24BEReads signed 3-byte (24 bit) integer from big endian bytes of the string.
pack.readInt24LEReads signed 3-byte (24 bit) integer from little endian bytes of the string.
pack.readInt32BEReads signed 4-byte (32 bit) integer from big endian bytes of the string.
pack.readInt32LEReads signed 4-byte (32 bit) integer from little endian bytes of the string.
pack.readInt40BEReads signed 5-byte (40 bit) integer from big endian bytes of the string.
pack.readInt40LEReads signed 5-byte (40 bit) integer from little endian bytes of the string.
pack.readInt48BEReads signed 6-byte (48 bit) integer from big endian bytes of the string.
pack.readInt48LEReads signed 6-byte (48 bit) integer from little endian bytes of the string.
pack.readInt56BEReads signed 7-byte (56 bit) integer from big endian bytes of the string.
pack.readInt56LEReads signed 7-byte (56 bit) integer from little endian bytes of the string.
pack.readInt64BEReads signed 8-byte (64 bit) integer from big endian bytes of the string.
pack.readInt64LEReads signed 8-byte (64 bit) integer from little endian bytes of the string.
pack.readInt8Reads signed 1-byte (8 bit) integer from the string.
pack.readLineTerminatedStringReads the line terminated by \n (a trailing \r is removed), or the rest of the data if there is no \n.
pack.readNullTerminatedStringReads C-style string, the null terminator (\0) is required.
pack.readTerminatedStringReads bytes until the terminator byte, or the rest of the data if there is no terminator.
pack.readTimeBEReads 2-byte (16 bit) DOS time from big endian bytes of the string.
pack.readTimeLEReads 2-byte (16 bit) DOS time from little endian bytes of the string.
pack.readUIntReads unsigned integer of any size from any bit position of the string.
pack.readUInt16BEReads unsigned 2-byte (16 bit) integer from big endian bytes of the string.
pack.readUInt16LEReads unsigned 2-byte (16 bit) integer from little endian bytes of the string.
pack.readUInt24BEReads unsigned 3-byte (24 bit) integer from big endian bytes of the string.
pack.readUInt24LEReads unsigned 3-byte (24 bit) integer from little endian bytes of the string.
pack.readUInt32BEReads unsigned 4-byte (32 bit) integer from big endian bytes of the string.
pack.readUInt32LEReads unsigned 4-byte (32 bit) integer from little endian bytes of the string.
pack.readUInt40BEReads unsigned 5-byte (40 bit) integer from big endian bytes of the string.
pack.readUInt40LEReads unsigned 5-byte (40 bit) integer from little endian bytes of the string.
pack.readUInt48BEReads unsigned 6-byte (48 bit) integer from big endian bytes of the string.
pack.readUInt48LEReads unsigned 6-byte (48 bit) integer from little endian bytes of the string.
pack.readUInt56BEReads unsigned 7-byte (56 bit) integer from big endian bytes of the string.
pack.readUInt56LEReads unsigned 7-byte (56 bit) integer from little endian bytes of the string.
pack.readUInt64BEReads unsigned 8-byte (64 bit) integer from big endian bytes of the string.
pack.readUInt64LEReads unsigned 8-byte (64 bit) integer from little endian bytes of the string.
pack.readUInt8Reads unsigned 1-byte (8 bit) integer from the string.
pack.readUnsignedFixedPointReads unsigned fixed-point number (m integer bits and n fractional bits) from any bit position of the string.
pack.writeCountedStringWrites the string prefixed with its length.
pack.writeDateBEWrites 2-byte (16 bit) DOS date as big endian bytes.
pack.writeDateLEWrites 2-byte (16 bit) DOS date as little endian bytes.
pack.writeDoubleBEWrites double precision (8-byte, 64 bit) floating point number as big endian bytes.
pack.writeDoubleLEWrites double precision (8-byte, 64 bit) floating point number as little endian bytes.
pack.writeFixedStringWrites the string of a fixed size, shorter data is padded with \0 and longer data is cut.
pack.writeFloatBEWrites single precision (4-byte, 32 bit) floating point number as big endian bytes.
pack.writeFloatLEWrites single precision (4-byte, 32 bit) floating point number as little endian bytes.
pack.writeInt16BEWrites signed 2-byte (16 bit) integer as big endian bytes.
pack.writeInt16LEWrites signed 2-byte (16 bit) integer as little endian bytes.
pack.writeInt24BEWrites signed 3-byte (24 bit) integer as big endian bytes.
pack.writeInt24LEWrites signed 3-byte (24 bit) integer as little endian bytes.
pack.writeInt32BEWrites signed 4-byte (32 bit) integer as big endian bytes.
pack.writeInt32LEWrites signed 4-byte (32 bit) integer as little endian bytes.
pack.writeInt40BEWrites signed 5-byte (40 bit) integer as big endian bytes.
pack.writeInt40LEWrites signed 5-byte (40 bit) integer as little endian bytes.
pack.writeInt48BEWrites signed 6-byte (48 bit) integer as big endian bytes.
pack.writeInt48LEWrites signed 6-byte (48 bit) integer as little endian bytes.
pack.writeInt56BEWrites signed 7-byte (56 bit) integer as big endian bytes.
pack.writeInt56LEWrites signed 7-byte (56 bit) integer as little endian bytes.
pack.writeInt64BEWrites signed 8-byte (64 bit) integer as big endian bytes.
pack.writeInt64LEWrites signed 8-byte (64 bit) integer as little endian bytes.
pack.writeInt8Writes signed 1-byte (8 bit) integer as a string.
pack.writeLineTerminatedStringWrites the line, the string followed by \n.
pack.writeNullTerminatedStringWrites C-style string, the string followed by the null terminator (\0).
pack.writeTerminatedStringWrites the string followed by the terminator byte.
pack.writeTimeBEWrites 2-byte (16 bit) DOS time as big endian bytes.
pack.writeTimeLEWrites 2-byte (16 bit) DOS time as little endian bytes.
pack.writeUInt16BEWrites unsigned 2-byte (16 bit) integer as big endian bytes.
pack.writeUInt16LEWrites unsigned 2-byte (16 bit) integer as little endian bytes.
pack.writeUInt24BEWrites unsigned 3-byte (24 bit) integer as big endian bytes.
pack.writeUInt24LEWrites unsigned 3-byte (24 bit) integer as little endian bytes.
pack.writeUInt32BEWrites unsigned 4-byte (32 bit) integer as big endian bytes.
pack.writeUInt32LEWrites unsigned 4-byte (32 bit) integer as little endian bytes.
pack.writeUInt40BEWrites unsigned 5-byte (40 bit) integer as big endian bytes.
pack.writeUInt40LEWrites unsigned 5-byte (40 bit) integer as little endian bytes.
pack.writeUInt48BEWrites unsigned 6-byte (48 bit) integer as big endian bytes.
pack.writeUInt48LEWrites unsigned 6-byte (48 bit) integer as little endian bytes.
pack.writeUInt56BEWrites unsigned 7-byte (56 bit) integer as big endian bytes.
pack.writeUInt56LEWrites unsigned 7-byte (56 bit) integer as little endian bytes.
pack.writeUInt64BEWrites unsigned 8-byte (64 bit) integer as big endian bytes.
pack.writeUInt64LEWrites unsigned 8-byte (64 bit) integer as little endian bytes.
pack.writeUInt8Writes unsigned 1-byte (8 bit) integer as a string.

#pack.readBit

sharedmenunodiscardsource
function pack.readBit(str: string, bit_position?: integer): 0 | 1

Reads one bit from the string.

lua
readBit( "\5", 2 ) --> 1
Parameters
NameTypeDescription
strstringThe string to read from.
bit_positionoptionalintegerThe position of the bit (0-based), 0 by default.
Returns
TypeNameDescription
0 | 1valueThe bit.

#pack.readBoolean

sharedmenunodiscardsource
function pack.readBoolean(str: string, bit_position?: integer): boolean

Reads one bit from the string as a boolean, same as net.ReadBool.

Parameters
NameTypeDescription
strstringThe string to read from.
bit_positionoptionalintegerThe position of the bit (0-based), 0 by default.
Returns
TypeNameDescription
booleanvaluetrue if the bit is 1.

#pack.readBytes

sharedmenunodiscardsource
function pack.readBytes(str: string, bit_position?: integer, byte_count: integer): integer

Reads bytes from any bit position of the string.

lua
readBytes( "\16\32", 4, 1 ) --> 0x01
Parameters
NameTypeDescription
strstringThe string to read from.
bit_positionoptionalintegerThe position of the first bit (0-based), 0 by default.
byte_countintegerThe number of bytes to read.
Returns
TypeNameDescription
integer...The bytes.

#pack.readCountedString

sharedmenunodiscardsource
function pack.readCountedString(str: string, index?: integer, length_size: integer, is_little_endian?: boolean): string, integer

Reads the string prefixed with its length.

lua
readCountedString( "\3abc", 1, 1 ) --> "abc", 4
Parameters
NameTypeDescription
strstringThe string to read from.
indexoptionalintegerThe index of the first byte of the length (1-based), 1 by default.
length_sizeintegerThe size of the length in bytes (1 - 8).
is_little_endianoptionalbooleantrue if the length is little endian, false by default.
Returns
TypeNameDescription
stringdataThe string.
integerdata_lengthThe number of bytes read, including the length.

#pack.readDateBE

sharedmenunodiscardsource
function pack.readDateBE(str: string, index?: integer): integer, integer, integer

Reads 2-byte (16 bit) DOS date from big endian bytes of the string.

Parameters
NameTypeDescription
strstringThe string to read from.
indexoptionalintegerThe index of the first byte (1-based), 1 by default.
Returns
TypeNameDescription
integerdayThe day.
integermonthThe month.
integeryearThe year.

#pack.readDateLE

sharedmenunodiscardsource
function pack.readDateLE(str: string, index?: integer): integer, integer, integer

Reads 2-byte (16 bit) DOS date from little endian bytes of the string.

Parameters
NameTypeDescription
strstringThe string to read from.
indexoptionalintegerThe index of the first byte (1-based), 1 by default.
Returns
TypeNameDescription
integerdayThe day.
integermonthThe month.
integeryearThe year.

#pack.readDoubleBE

sharedmenunodiscardsource
function pack.readDoubleBE(str: string, index?: integer): number

Reads double precision (8-byte, 64 bit) floating point number from big endian bytes of the string.

Parameters
NameTypeDescription
strstringThe string to read from.
indexoptionalintegerThe index of the first byte (1-based), 1 by default.
Returns
TypeNameDescription
numbervalueThe floating point number.

#pack.readDoubleLE

sharedmenunodiscardsource
function pack.readDoubleLE(str: string, index?: integer): number

Reads double precision (8-byte, 64 bit) floating point number from little endian bytes of the string.

Parameters
NameTypeDescription
strstringThe string to read from.
indexoptionalintegerThe index of the first byte (1-based), 1 by default.
Returns
TypeNameDescription
numbervalueThe floating point number.

#pack.readFixedPoint

sharedmenunodiscardsource
function pack.readFixedPoint(str: string, bit_position?: integer, m: integer, n: integer, is_little_endian?: boolean): number

Reads signed fixed-point number (m integer bits including the sign bit and n fractional bits) from any bit position of the string.

Parameters
NameTypeDescription
strstringThe string to read from.
bit_positionoptionalintegerThe position of the first bit (0-based), 0 by default.
mintegerThe number of integer bits, including the sign bit.
nintegerThe number of fractional bits.
is_little_endianoptionalbooleantrue for little endian, false by default.
Returns
TypeNameDescription
numbervalueThe signed fixed-point number.

#pack.readFixedString

sharedmenunodiscardsource
function pack.readFixedString(str: string, index?: integer, length?: integer): string

Reads the string of a fixed size.

Parameters
NameTypeDescription
strstringThe string to read from.
indexoptionalintegerThe index of the first byte (1-based), 1 by default.
lengthoptionalintegerThe size of the string in bytes, the rest of the data by default.
Returns
TypeNameDescription
stringdataThe string.

#pack.readFloatBE

sharedmenunodiscardsource
function pack.readFloatBE(str: string, index?: integer): number

Reads single precision (4-byte, 32 bit) floating point number from big endian bytes of the string.

Parameters
NameTypeDescription
strstringThe string to read from.
indexoptionalintegerThe index of the first byte (1-based), 1 by default.
Returns
TypeNameDescription
numbervalueThe floating point number.

#pack.readFloatLE

sharedmenunodiscardsource
function pack.readFloatLE(str: string, index?: integer): number

Reads single precision (4-byte, 32 bit) floating point number from little endian bytes of the string.

Parameters
NameTypeDescription
strstringThe string to read from.
indexoptionalintegerThe index of the first byte (1-based), 1 by default.
Returns
TypeNameDescription
numbervalueThe floating point number.

#pack.readInt

sharedmenunodiscardsource
function pack.readInt(str: string, bit_position?: integer, bit_count: integer, is_little_endian?: boolean): integer

Reads signed (two's complement) integer of any size from any bit position of the string.

Byte order is the same as in readUInt.

Valid values without loss of precision: -9007199254740991 - 9007199254740991 (53 bits)

lua
readInt( "\255\255", 0, 16, true ) --> -1
Parameters
NameTypeDescription
strstringThe string to read from.
bit_positionoptionalintegerThe position of the first bit (0-based), 0 by default.
bit_countintegerThe size of the integer in bits (1 - 64).
is_little_endianoptionalbooleantrue for little endian, false by default.
Returns
TypeNameDescription
integervalueThe signed integer.

#pack.readInt16BE

sharedmenunodiscardsource
function pack.readInt16BE(str: string, index?: integer): integer

Reads signed 2-byte (16 bit) integer from big endian bytes of the string.

Valid values without loss of precision: -32768 - 32767

Parameters
NameTypeDescription
strstringThe string to read from.
indexoptionalintegerThe index of the first byte (1-based), 1 by default.
Returns
TypeNameDescription
integervalueThe signed 2-byte integer.

#pack.readInt16LE

sharedmenunodiscardsource
function pack.readInt16LE(str: string, index?: integer): integer

Reads signed 2-byte (16 bit) integer from little endian bytes of the string.

Valid values without loss of precision: -32768 - 32767

Parameters
NameTypeDescription
strstringThe string to read from.
indexoptionalintegerThe index of the first byte (1-based), 1 by default.
Returns
TypeNameDescription
integervalueThe signed 2-byte integer.

#pack.readInt24BE

sharedmenunodiscardsource
function pack.readInt24BE(str: string, index?: integer): integer

Reads signed 3-byte (24 bit) integer from big endian bytes of the string.

Valid values without loss of precision: -8388608 - 8388607

Parameters
NameTypeDescription
strstringThe string to read from.
indexoptionalintegerThe index of the first byte (1-based), 1 by default.
Returns
TypeNameDescription
integervalueThe signed 3-byte integer.

#pack.readInt24LE

sharedmenunodiscardsource
function pack.readInt24LE(str: string, index?: integer): integer

Reads signed 3-byte (24 bit) integer from little endian bytes of the string.

Valid values without loss of precision: -8388608 - 8388607

Parameters
NameTypeDescription
strstringThe string to read from.
indexoptionalintegerThe index of the first byte (1-based), 1 by default.
Returns
TypeNameDescription
integervalueThe signed 3-byte integer.

#pack.readInt32BE

sharedmenunodiscardsource
function pack.readInt32BE(str: string, index?: integer): integer

Reads signed 4-byte (32 bit) integer from big endian bytes of the string.

Valid values without loss of precision: -2147483648 - 2147483647

Parameters
NameTypeDescription
strstringThe string to read from.
indexoptionalintegerThe index of the first byte (1-based), 1 by default.
Returns
TypeNameDescription
integervalueThe signed 4-byte integer.

#pack.readInt32LE

sharedmenunodiscardsource
function pack.readInt32LE(str: string, index?: integer): integer

Reads signed 4-byte (32 bit) integer from little endian bytes of the string.

Valid values without loss of precision: -2147483648 - 2147483647

Parameters
NameTypeDescription
strstringThe string to read from.
indexoptionalintegerThe index of the first byte (1-based), 1 by default.
Returns
TypeNameDescription
integervalueThe signed 4-byte integer.

#pack.readInt40BE

sharedmenunodiscardsource
function pack.readInt40BE(str: string, index?: integer): integer

Reads signed 5-byte (40 bit) integer from big endian bytes of the string.

Valid values without loss of precision: -549755813888 - 549755813887

Parameters
NameTypeDescription
strstringThe string to read from.
indexoptionalintegerThe index of the first byte (1-based), 1 by default.
Returns
TypeNameDescription
integervalueThe signed 5-byte integer.

#pack.readInt40LE

sharedmenunodiscardsource
function pack.readInt40LE(str: string, index?: integer): integer

Reads signed 5-byte (40 bit) integer from little endian bytes of the string.

Valid values without loss of precision: -549755813888 - 549755813887

Parameters
NameTypeDescription
strstringThe string to read from.
indexoptionalintegerThe index of the first byte (1-based), 1 by default.
Returns
TypeNameDescription
integervalueThe signed 5-byte integer.

#pack.readInt48BE

sharedmenunodiscardsource
function pack.readInt48BE(str: string, index?: integer): integer

Reads signed 6-byte (48 bit) integer from big endian bytes of the string.

Valid values without loss of precision: -140737488355328 - 140737488355327

Parameters
NameTypeDescription
strstringThe string to read from.
indexoptionalintegerThe index of the first byte (1-based), 1 by default.
Returns
TypeNameDescription
integervalueThe signed 6-byte integer.

#pack.readInt48LE

sharedmenunodiscardsource
function pack.readInt48LE(str: string, index?: integer): integer

Reads signed 6-byte (48 bit) integer from little endian bytes of the string.

Valid values without loss of precision: -140737488355328 - 140737488355327

Parameters
NameTypeDescription
strstringThe string to read from.
indexoptionalintegerThe index of the first byte (1-based), 1 by default.
Returns
TypeNameDescription
integervalueThe signed 6-byte integer.

#pack.readInt56BE

sharedmenunodiscardsource
function pack.readInt56BE(str: string, index?: integer): integer

Reads signed 7-byte (56 bit) integer from big endian bytes of the string.

Valid values without loss of precision: -36028797018963968 - 36028797018963967

Parameters
NameTypeDescription
strstringThe string to read from.
indexoptionalintegerThe index of the first byte (1-based), 1 by default.
Returns
TypeNameDescription
integervalueThe signed 7-byte integer.

#pack.readInt56LE

sharedmenunodiscardsource
function pack.readInt56LE(str: string, index?: integer): integer

Reads signed 7-byte (56 bit) integer from little endian bytes of the string.

Valid values without loss of precision: -36028797018963968 - 36028797018963967

Parameters
NameTypeDescription
strstringThe string to read from.
indexoptionalintegerThe index of the first byte (1-based), 1 by default.
Returns
TypeNameDescription
integervalueThe signed 7-byte integer.

#pack.readInt64BE

sharedmenunodiscardsource
function pack.readInt64BE(str: string, index?: integer): integer

Reads signed 8-byte (64 bit) integer from big endian bytes of the string.

Valid values without loss of precision: -9007199254740991 - 9007199254740991

All values above will have problems when working with them.

Parameters
NameTypeDescription
strstringThe string to read from.
indexoptionalintegerThe index of the first byte (1-based), 1 by default.
Returns
TypeNameDescription
integervalueThe signed 8-byte integer.

#pack.readInt64LE

sharedmenunodiscardsource
function pack.readInt64LE(str: string, index?: integer): integer

Reads signed 8-byte (64 bit) integer from little endian bytes of the string.

Valid values without loss of precision: -9007199254740991 - 9007199254740991

All values above will have problems when working with them.

Parameters
NameTypeDescription
strstringThe string to read from.
indexoptionalintegerThe index of the first byte (1-based), 1 by default.
Returns
TypeNameDescription
integervalueThe signed 8-byte integer.

#pack.readInt8

sharedmenunodiscardsource
function pack.readInt8(str: string, index?: integer): integer

Reads signed 1-byte (8 bit) integer from the string.

Valid values without loss of precision: -128 - 127

Parameters
NameTypeDescription
strstringThe string to read from.
indexoptionalintegerThe index of the first byte (1-based), 1 by default.
Returns
TypeNameDescription
integervalueThe signed 1-byte integer.

#pack.readLineTerminatedString

sharedmenunodiscardsource
function pack.readLineTerminatedString(str: string, index?: integer): string, integer

Reads the line terminated by \n (a trailing \r is removed), or the rest of the data if there is no \n.

Parameters
NameTypeDescription
strstringThe string to read from.
indexoptionalintegerThe index of the first byte (1-based), 1 by default.
Returns
TypeNameDescription
stringlineThe line without \r\n or \n.
integerdata_lengthThe number of bytes read, including \r\n or \n.

#pack.readNullTerminatedString

sharedmenunodiscardsource
function pack.readNullTerminatedString(str: string, index?: integer): string, integer

Reads C-style string, the null terminator (\0) is required.

Parameters
NameTypeDescription
strstringThe string to read from.
indexoptionalintegerThe index of the first byte (1-based), 1 by default.
Returns
TypeNameDescription
stringdataThe bytes before the null terminator.
integerdata_lengthThe number of bytes read, including the null terminator.

#pack.readTerminatedString

sharedmenunodiscardsource
function pack.readTerminatedString(str: string, index?: integer, terminator: integer): string, integer, boolean

Reads bytes until the terminator byte, or the rest of the data if there is no terminator.

lua
readTerminatedString( "key=value", 1, 0x3D ) --> "key", 4, true
Parameters
NameTypeDescription
strstringThe string to read from.
indexoptionalintegerThe index of the first byte (1-based), 1 by default.
terminatorintegerThe terminator byte (0 - 255).
Returns
TypeNameDescription
stringdataThe bytes before the terminator.
integerdata_lengthThe number of bytes read, including the terminator if it was found.
booleanterminatedtrue if the terminator was found.

#pack.readTimeBE

sharedmenunodiscardsource
function pack.readTimeBE(str: string, index?: integer): integer, integer, integer

Reads 2-byte (16 bit) DOS time from big endian bytes of the string.

Parameters
NameTypeDescription
strstringThe string to read from.
indexoptionalintegerThe index of the first byte (1-based), 1 by default.
Returns
TypeNameDescription
integerhoursThe number of hours.
integerminutesThe number of minutes.
integersecondsThe number of seconds, will be rounded.

#pack.readTimeLE

sharedmenunodiscardsource
function pack.readTimeLE(str: string, index?: integer): integer, integer, integer

Reads 2-byte (16 bit) DOS time from little endian bytes of the string.

Parameters
NameTypeDescription
strstringThe string to read from.
indexoptionalintegerThe index of the first byte (1-based), 1 by default.
Returns
TypeNameDescription
integerhoursThe number of hours.
integerminutesThe number of minutes.
integersecondsThe number of seconds, will be rounded.

#pack.readUInt

sharedmenunodiscardsource
function pack.readUInt(str: string, bit_position?: integer, bit_count: integer, is_little_endian?: boolean): integer

Reads unsigned integer of any size from any bit position of the string.

Little endian integers are read lowest bit first, same as net.ReadUInt.

Big endian integers are read as the highest bit_count % 8 bits first, then whole bytes from the most significant to the least significant.

Valid values without loss of precision: 0 - 9007199254740991 (53 bits)

lua
readUInt( "\44\1", 0, 16, true ) --> 300
readUInt( "\5", 1, 2, true ) --> 2
Parameters
NameTypeDescription
strstringThe string to read from.
bit_positionoptionalintegerThe position of the first bit (0-based), 0 by default.
bit_countintegerThe size of the integer in bits (1 - 64).
is_little_endianoptionalbooleantrue for little endian, false by default.
Returns
TypeNameDescription
integervalueThe unsigned integer.

#pack.readUInt16BE

sharedmenunodiscardsource
function pack.readUInt16BE(str: string, index?: integer): integer

Reads unsigned 2-byte (16 bit) integer from big endian bytes of the string.

Valid values without loss of precision: 0 - 65535

Parameters
NameTypeDescription
strstringThe string to read from.
indexoptionalintegerThe index of the first byte (1-based), 1 by default.
Returns
TypeNameDescription
integervalueThe unsigned 2-byte integer.

#pack.readUInt16LE

sharedmenunodiscardsource
function pack.readUInt16LE(str: string, index?: integer): integer

Reads unsigned 2-byte (16 bit) integer from little endian bytes of the string.

Valid values without loss of precision: 0 - 65535

Parameters
NameTypeDescription
strstringThe string to read from.
indexoptionalintegerThe index of the first byte (1-based), 1 by default.
Returns
TypeNameDescription
integervalueThe unsigned 2-byte integer.

#pack.readUInt24BE

sharedmenunodiscardsource
function pack.readUInt24BE(str: string, index?: integer): integer

Reads unsigned 3-byte (24 bit) integer from big endian bytes of the string.

Valid values without loss of precision: 0 - 16777215

Parameters
NameTypeDescription
strstringThe string to read from.
indexoptionalintegerThe index of the first byte (1-based), 1 by default.
Returns
TypeNameDescription
integervalueThe unsigned 3-byte integer.

#pack.readUInt24LE

sharedmenunodiscardsource
function pack.readUInt24LE(str: string, index?: integer): integer

Reads unsigned 3-byte (24 bit) integer from little endian bytes of the string.

Valid values without loss of precision: 0 - 16777215

Parameters
NameTypeDescription
strstringThe string to read from.
indexoptionalintegerThe index of the first byte (1-based), 1 by default.
Returns
TypeNameDescription
integervalueThe unsigned 3-byte integer.

#pack.readUInt32BE

sharedmenunodiscardsource
function pack.readUInt32BE(str: string, index?: integer): integer

Reads unsigned 4-byte (32 bit) integer from big endian bytes of the string.

Valid values without loss of precision: 0 - 4294967295

Parameters
NameTypeDescription
strstringThe string to read from.
indexoptionalintegerThe index of the first byte (1-based), 1 by default.
Returns
TypeNameDescription
integervalueThe unsigned 4-byte integer.

#pack.readUInt32LE

sharedmenunodiscardsource
function pack.readUInt32LE(str: string, index?: integer): integer

Reads unsigned 4-byte (32 bit) integer from little endian bytes of the string.

Valid values without loss of precision: 0 - 4294967295

Parameters
NameTypeDescription
strstringThe string to read from.
indexoptionalintegerThe index of the first byte (1-based), 1 by default.
Returns
TypeNameDescription
integervalueThe unsigned 4-byte integer.

#pack.readUInt40BE

sharedmenunodiscardsource
function pack.readUInt40BE(str: string, index?: integer): integer

Reads unsigned 5-byte (40 bit) integer from big endian bytes of the string.

Valid values without loss of precision: 0 - 1099511627775

Parameters
NameTypeDescription
strstringThe string to read from.
indexoptionalintegerThe index of the first byte (1-based), 1 by default.
Returns
TypeNameDescription
integervalueThe unsigned 5-byte integer.

#pack.readUInt40LE

sharedmenunodiscardsource
function pack.readUInt40LE(str: string, index?: integer): integer

Reads unsigned 5-byte (40 bit) integer from little endian bytes of the string.

Valid values without loss of precision: 0 - 1099511627775

Parameters
NameTypeDescription
strstringThe string to read from.
indexoptionalintegerThe index of the first byte (1-based), 1 by default.
Returns
TypeNameDescription
integervalueThe unsigned 5-byte integer.

#pack.readUInt48BE

sharedmenunodiscardsource
function pack.readUInt48BE(str: string, index?: integer): integer

Reads unsigned 6-byte (48 bit) integer from big endian bytes of the string.

Valid values without loss of precision: 0 - 281474976710655

Parameters
NameTypeDescription
strstringThe string to read from.
indexoptionalintegerThe index of the first byte (1-based), 1 by default.
Returns
TypeNameDescription
integervalueThe unsigned 6-byte integer.

#pack.readUInt48LE

sharedmenunodiscardsource
function pack.readUInt48LE(str: string, index?: integer): integer

Reads unsigned 6-byte (48 bit) integer from little endian bytes of the string.

Valid values without loss of precision: 0 - 281474976710655

Parameters
NameTypeDescription
strstringThe string to read from.
indexoptionalintegerThe index of the first byte (1-based), 1 by default.
Returns
TypeNameDescription
integervalueThe unsigned 6-byte integer.

#pack.readUInt56BE

sharedmenunodiscardsource
function pack.readUInt56BE(str: string, index?: integer): integer

Reads unsigned 7-byte (56 bit) integer from big endian bytes of the string.

Valid values without loss of precision: 0 - 9007199254740991

All values above will have problems when working with them.

Parameters
NameTypeDescription
strstringThe string to read from.
indexoptionalintegerThe index of the first byte (1-based), 1 by default.
Returns
TypeNameDescription
integervalueThe unsigned 7-byte integer.

#pack.readUInt56LE

sharedmenunodiscardsource
function pack.readUInt56LE(str: string, index?: integer): integer

Reads unsigned 7-byte (56 bit) integer from little endian bytes of the string.

Valid values without loss of precision: 0 - 9007199254740991

All values above will have problems when working with them.

Parameters
NameTypeDescription
strstringThe string to read from.
indexoptionalintegerThe index of the first byte (1-based), 1 by default.
Returns
TypeNameDescription
integervalueThe unsigned 7-byte integer.

#pack.readUInt64BE

sharedmenunodiscardsource
function pack.readUInt64BE(str: string, index?: integer): integer

Reads unsigned 8-byte (64 bit) integer from big endian bytes of the string.

Valid values without loss of precision: 0 - 9007199254740991

All values above will have problems when working with them.

Parameters
NameTypeDescription
strstringThe string to read from.
indexoptionalintegerThe index of the first byte (1-based), 1 by default.
Returns
TypeNameDescription
integervalueThe unsigned 8-byte integer.

#pack.readUInt64LE

sharedmenunodiscardsource
function pack.readUInt64LE(str: string, index?: integer): integer

Reads unsigned 8-byte (64 bit) integer from little endian bytes of the string.

Valid values without loss of precision: 0 - 9007199254740991

All values above will have problems when working with them.

Parameters
NameTypeDescription
strstringThe string to read from.
indexoptionalintegerThe index of the first byte (1-based), 1 by default.
Returns
TypeNameDescription
integervalueThe unsigned 8-byte integer.

#pack.readUInt8

sharedmenunodiscardsource
function pack.readUInt8(str: string, index?: integer): integer

Reads unsigned 1-byte (8 bit) integer from the string.

Valid values without loss of precision: 0 - 255

Parameters
NameTypeDescription
strstringThe string to read from.
indexoptionalintegerThe index of the first byte (1-based), 1 by default.
Returns
TypeNameDescription
integervalueThe unsigned 1-byte integer.

#pack.readUnsignedFixedPoint

sharedmenunodiscardsource
function pack.readUnsignedFixedPoint(str: string, bit_position?: integer, m: integer, n: integer, is_little_endian?: boolean): number

Reads unsigned fixed-point number (m integer bits and n fractional bits) from any bit position of the string.

Parameters
NameTypeDescription
strstringThe string to read from.
bit_positionoptionalintegerThe position of the first bit (0-based), 0 by default.
mintegerThe number of integer bits.
nintegerThe number of fractional bits.
is_little_endianoptionalbooleantrue for little endian, false by default.
Returns
TypeNameDescription
numbervalueThe unsigned fixed-point number.

#pack.writeCountedString

sharedmenunodiscardsource
function pack.writeCountedString(data: string, length_size: integer, is_little_endian?: boolean): string

Writes the string prefixed with its length.

Throws an error if the string is too long for the length size.

lua
writeCountedString( "abc", 1 ) --> "\3abc"
Parameters
NameTypeDescription
datastringThe string to write.
length_sizeintegerThe size of the length in bytes (1 - 8).
is_little_endianoptionalbooleantrue to write the length as little endian, false by default.
Returns
TypeNameDescription
stringdataThe counted string.

#pack.writeDateBE

sharedmenunodiscardsource
function pack.writeDateBE(day?: integer, month?: integer, year?: integer): string

Writes 2-byte (16 bit) DOS date as big endian bytes.

Parameters
NameTypeDescription
dayoptionalintegerThe day.
monthoptionalintegerThe month.
yearoptionalintegerThe year.
Returns
TypeNameDescription
stringdataThe 2-byte string.

#pack.writeDateLE

sharedmenunodiscardsource
function pack.writeDateLE(day?: integer, month?: integer, year?: integer): string

Writes 2-byte (16 bit) DOS date as little endian bytes.

Parameters
NameTypeDescription
dayoptionalintegerThe day.
monthoptionalintegerThe month.
yearoptionalintegerThe year.
Returns
TypeNameDescription
stringdataThe 2-byte string.

#pack.writeDoubleBE

sharedmenunodiscardsource
function pack.writeDoubleBE(value: number): string

Writes double precision (8-byte, 64 bit) floating point number as big endian bytes.

Parameters
NameTypeDescription
valuenumberThe floating point number.
Returns
TypeNameDescription
stringdataThe 8-byte string.

#pack.writeDoubleLE

sharedmenunodiscardsource
function pack.writeDoubleLE(value: number): string

Writes double precision (8-byte, 64 bit) floating point number as little endian bytes.

Parameters
NameTypeDescription
valuenumberThe floating point number.
Returns
TypeNameDescription
stringdataThe 8-byte string.

#pack.writeFixedString

sharedmenunodiscardsource
function pack.writeFixedString(data: string, length: integer): string

Writes the string of a fixed size, shorter data is padded with \0 and longer data is cut.

lua
writeFixedString( "abc", 5 ) --> "abc\0\0"
writeFixedString( "abcdef", 5 ) --> "abcde"
Parameters
NameTypeDescription
datastringThe string to write.
lengthintegerThe size of the string in bytes.
Returns
TypeNameDescription
stringdataThe length-byte string.

#pack.writeFloatBE

sharedmenunodiscardsource
function pack.writeFloatBE(value: number): string

Writes single precision (4-byte, 32 bit) floating point number as big endian bytes.

Parameters
NameTypeDescription
valuenumberThe floating point number.
Returns
TypeNameDescription
stringdataThe 4-byte string.

#pack.writeFloatLE

sharedmenunodiscardsource
function pack.writeFloatLE(value: number): string

Writes single precision (4-byte, 32 bit) floating point number as little endian bytes.

Parameters
NameTypeDescription
valuenumberThe floating point number.
Returns
TypeNameDescription
stringdataThe 4-byte string.

#pack.writeInt16BE

sharedmenunodiscardsource
function pack.writeInt16BE(value: integer): string

Writes signed 2-byte (16 bit) integer as big endian bytes.

Valid values without loss of precision: -32768 - 32767

Parameters
NameTypeDescription
valueintegerThe signed 2-byte integer.
Returns
TypeNameDescription
stringdataThe 2-byte string.

#pack.writeInt16LE

sharedmenunodiscardsource
function pack.writeInt16LE(value: integer): string

Writes signed 2-byte (16 bit) integer as little endian bytes.

Valid values without loss of precision: -32768 - 32767

Parameters
NameTypeDescription
valueintegerThe signed 2-byte integer.
Returns
TypeNameDescription
stringdataThe 2-byte string.

#pack.writeInt24BE

sharedmenunodiscardsource
function pack.writeInt24BE(value: integer): string

Writes signed 3-byte (24 bit) integer as big endian bytes.

Valid values without loss of precision: -8388608 - 8388607

Parameters
NameTypeDescription
valueintegerThe signed 3-byte integer.
Returns
TypeNameDescription
stringdataThe 3-byte string.

#pack.writeInt24LE

sharedmenunodiscardsource
function pack.writeInt24LE(value: integer): string

Writes signed 3-byte (24 bit) integer as little endian bytes.

Valid values without loss of precision: -8388608 - 8388607

Parameters
NameTypeDescription
valueintegerThe signed 3-byte integer.
Returns
TypeNameDescription
stringdataThe 3-byte string.

#pack.writeInt32BE

sharedmenunodiscardsource
function pack.writeInt32BE(value: integer): string

Writes signed 4-byte (32 bit) integer as big endian bytes.

Valid values without loss of precision: -2147483648 - 2147483647

Parameters
NameTypeDescription
valueintegerThe signed 4-byte integer.
Returns
TypeNameDescription
stringdataThe 4-byte string.

#pack.writeInt32LE

sharedmenunodiscardsource
function pack.writeInt32LE(value: integer): string

Writes signed 4-byte (32 bit) integer as little endian bytes.

Valid values without loss of precision: -2147483648 - 2147483647

Parameters
NameTypeDescription
valueintegerThe signed 4-byte integer.
Returns
TypeNameDescription
stringdataThe 4-byte string.

#pack.writeInt40BE

sharedmenunodiscardsource
function pack.writeInt40BE(value: integer): string

Writes signed 5-byte (40 bit) integer as big endian bytes.

Valid values without loss of precision: -549755813888 - 549755813887

Parameters
NameTypeDescription
valueintegerThe signed 5-byte integer.
Returns
TypeNameDescription
stringdataThe 5-byte string.

#pack.writeInt40LE

sharedmenunodiscardsource
function pack.writeInt40LE(value: integer): string

Writes signed 5-byte (40 bit) integer as little endian bytes.

Valid values without loss of precision: -549755813888 - 549755813887

Parameters
NameTypeDescription
valueintegerThe signed 5-byte integer.
Returns
TypeNameDescription
stringdataThe 5-byte string.

#pack.writeInt48BE

sharedmenunodiscardsource
function pack.writeInt48BE(value: integer): string

Writes signed 6-byte (48 bit) integer as big endian bytes.

Valid values without loss of precision: -140737488355328 - 140737488355327

Parameters
NameTypeDescription
valueintegerThe signed 6-byte integer.
Returns
TypeNameDescription
stringdataThe 6-byte string.

#pack.writeInt48LE

sharedmenunodiscardsource
function pack.writeInt48LE(value: integer): string

Writes signed 6-byte (48 bit) integer as little endian bytes.

Valid values without loss of precision: -140737488355328 - 140737488355327

Parameters
NameTypeDescription
valueintegerThe signed 6-byte integer.
Returns
TypeNameDescription
stringdataThe 6-byte string.

#pack.writeInt56BE

sharedmenunodiscardsource
function pack.writeInt56BE(value: integer): string

Writes signed 7-byte (56 bit) integer as big endian bytes.

Valid values without loss of precision: -36028797018963968 - 36028797018963967

Parameters
NameTypeDescription
valueintegerThe signed 7-byte integer.
Returns
TypeNameDescription
stringdataThe 7-byte string.

#pack.writeInt56LE

sharedmenunodiscardsource
function pack.writeInt56LE(value: integer): string

Writes signed 7-byte (56 bit) integer as little endian bytes.

Valid values without loss of precision: -36028797018963968 - 36028797018963967

Parameters
NameTypeDescription
valueintegerThe signed 7-byte integer.
Returns
TypeNameDescription
stringdataThe 7-byte string.

#pack.writeInt64BE

sharedmenunodiscardsource
function pack.writeInt64BE(value: integer): string

Writes signed 8-byte (64 bit) integer as big endian bytes.

Valid values without loss of precision: -9007199254740991 - 9007199254740991

All values above will have problems when working with them.

Parameters
NameTypeDescription
valueintegerThe signed 8-byte integer.
Returns
TypeNameDescription
stringdataThe 8-byte string.

#pack.writeInt64LE

sharedmenunodiscardsource
function pack.writeInt64LE(value: integer): string

Writes signed 8-byte (64 bit) integer as little endian bytes.

Valid values without loss of precision: -9007199254740991 - 9007199254740991

All values above will have problems when working with them.

Parameters
NameTypeDescription
valueintegerThe signed 8-byte integer.
Returns
TypeNameDescription
stringdataThe 8-byte string.

#pack.writeInt8

sharedmenunodiscardsource
function pack.writeInt8(value: integer): string

Writes signed 1-byte (8 bit) integer as a string.

Valid values without loss of precision: -128 - 127

Parameters
NameTypeDescription
valueintegerThe signed 1-byte integer.
Returns
TypeNameDescription
stringdataThe 1-byte string.

#pack.writeLineTerminatedString

sharedmenunodiscardsource
function pack.writeLineTerminatedString(data: string): string

Writes the line, the string followed by \n.

Throws an error if the string contains \n.

Parameters
NameTypeDescription
datastringThe string to write.
Returns
TypeNameDescription
stringdataThe line.

#pack.writeNullTerminatedString

sharedmenunodiscardsource
function pack.writeNullTerminatedString(data: string): string

Writes C-style string, the string followed by the null terminator (\0).

Throws an error if the string contains \0.

Parameters
NameTypeDescription
datastringThe string to write.
Returns
TypeNameDescription
stringdataThe null terminated string.

#pack.writeTerminatedString

sharedmenunodiscardsource
function pack.writeTerminatedString(data: string, terminator: integer): string

Writes the string followed by the terminator byte.

Throws an error if the string contains the terminator.

Parameters
NameTypeDescription
datastringThe string to write.
terminatorintegerThe terminator byte (0 - 255).
Returns
TypeNameDescription
stringdataThe terminated string.

#pack.writeTimeBE

sharedmenunodiscardsource
function pack.writeTimeBE(hours?: integer, minutes?: integer, seconds?: integer): string

Writes 2-byte (16 bit) DOS time as big endian bytes.

Parameters
NameTypeDescription
hoursoptionalintegerThe number of hours.
minutesoptionalintegerThe number of minutes.
secondsoptionalintegerThe number of seconds, will be rounded.
Returns
TypeNameDescription
stringdataThe 2-byte string.

#pack.writeTimeLE

sharedmenunodiscardsource
function pack.writeTimeLE(hours?: integer, minutes?: integer, seconds?: integer): string

Writes 2-byte (16 bit) DOS time as little endian bytes.

Parameters
NameTypeDescription
hoursoptionalintegerThe number of hours.
minutesoptionalintegerThe number of minutes.
secondsoptionalintegerThe number of seconds, will be rounded.
Returns
TypeNameDescription
stringdataThe 2-byte string.

#pack.writeUInt16BE

sharedmenunodiscardsource
function pack.writeUInt16BE(value: integer): string

Writes unsigned 2-byte (16 bit) integer as big endian bytes.

Valid values without loss of precision: 0 - 65535

Parameters
NameTypeDescription
valueintegerThe unsigned 2-byte integer.
Returns
TypeNameDescription
stringdataThe 2-byte string.

#pack.writeUInt16LE

sharedmenunodiscardsource
function pack.writeUInt16LE(value: integer): string

Writes unsigned 2-byte (16 bit) integer as little endian bytes.

Valid values without loss of precision: 0 - 65535

Parameters
NameTypeDescription
valueintegerThe unsigned 2-byte integer.
Returns
TypeNameDescription
stringdataThe 2-byte string.

#pack.writeUInt24BE

sharedmenunodiscardsource
function pack.writeUInt24BE(value: integer): string

Writes unsigned 3-byte (24 bit) integer as big endian bytes.

Valid values without loss of precision: 0 - 16777215

Parameters
NameTypeDescription
valueintegerThe unsigned 3-byte integer.
Returns
TypeNameDescription
stringdataThe 3-byte string.

#pack.writeUInt24LE

sharedmenunodiscardsource
function pack.writeUInt24LE(value: integer): string

Writes unsigned 3-byte (24 bit) integer as little endian bytes.

Valid values without loss of precision: 0 - 16777215

Parameters
NameTypeDescription
valueintegerThe unsigned 3-byte integer.
Returns
TypeNameDescription
stringdataThe 3-byte string.

#pack.writeUInt32BE

sharedmenunodiscardsource
function pack.writeUInt32BE(value: integer): string

Writes unsigned 4-byte (32 bit) integer as big endian bytes.

Valid values without loss of precision: 0 - 4294967295

Parameters
NameTypeDescription
valueintegerThe unsigned 4-byte integer.
Returns
TypeNameDescription
stringdataThe 4-byte string.

#pack.writeUInt32LE

sharedmenunodiscardsource
function pack.writeUInt32LE(value: integer): string

Writes unsigned 4-byte (32 bit) integer as little endian bytes.

Valid values without loss of precision: 0 - 4294967295

Parameters
NameTypeDescription
valueintegerThe unsigned 4-byte integer.
Returns
TypeNameDescription
stringdataThe 4-byte string.

#pack.writeUInt40BE

sharedmenunodiscardsource
function pack.writeUInt40BE(value: integer): string

Writes unsigned 5-byte (40 bit) integer as big endian bytes.

Valid values without loss of precision: 0 - 1099511627775.

Parameters
NameTypeDescription
valueintegerThe unsigned 5-byte integer.
Returns
TypeNameDescription
stringdataThe 5-byte string.

#pack.writeUInt40LE

sharedmenunodiscardsource
function pack.writeUInt40LE(value: integer): string

Writes unsigned 5-byte (40 bit) integer as little endian bytes.

Valid values without loss of precision: 0 - 1099511627775.

Parameters
NameTypeDescription
valueintegerThe unsigned 5-byte integer.
Returns
TypeNameDescription
stringdataThe 5-byte string.

#pack.writeUInt48BE

sharedmenunodiscardsource
function pack.writeUInt48BE(value: integer): string

Writes unsigned 6-byte (48 bit) integer as big endian bytes.

Valid values without loss of precision: 0 - 281474976710655

Parameters
NameTypeDescription
valueintegerThe unsigned 6-byte integer.
Returns
TypeNameDescription
stringdataThe 6-byte string.

#pack.writeUInt48LE

sharedmenunodiscardsource
function pack.writeUInt48LE(value: integer): string

Writes unsigned 6-byte (48 bit) integer as little endian bytes.

Valid values without loss of precision: 0 - 281474976710655

Parameters
NameTypeDescription
valueintegerThe unsigned 6-byte integer.
Returns
TypeNameDescription
stringdataThe 6-byte string.

#pack.writeUInt56BE

sharedmenunodiscardsource
function pack.writeUInt56BE(value: integer): string

Writes unsigned 7-byte (56 bit) integer as big endian bytes.

Valid values without loss of precision: 0 - 9007199254740991

All values above will have problems when working with them.

Parameters
NameTypeDescription
valueintegerThe unsigned 7-byte integer.
Returns
TypeNameDescription
stringdataThe 7-byte string.

#pack.writeUInt56LE

sharedmenunodiscardsource
function pack.writeUInt56LE(value: integer): string

Writes unsigned 7-byte (56 bit) integer as little endian bytes.

Valid values without loss of precision: 0 - 9007199254740991

All values above will have problems when working with them.

Parameters
NameTypeDescription
valueintegerThe unsigned 7-byte integer.
Returns
TypeNameDescription
stringdataThe 7-byte string.

#pack.writeUInt64BE

sharedmenunodiscardsource
function pack.writeUInt64BE(value: integer): string

Writes unsigned 8-byte (64 bit) integer as big endian bytes.

Valid values without loss of precision: 0 - 9007199254740991

All values above will have problems when working with them.

Parameters
NameTypeDescription
valueintegerThe unsigned 8-byte integer.
Returns
TypeNameDescription
stringdataThe 8-byte string.

#pack.writeUInt64LE

sharedmenunodiscardsource
function pack.writeUInt64LE(value: integer): string

Writes unsigned 8-byte (64 bit) integer as little endian bytes.

Valid values without loss of precision: 0 - 9007199254740991

All values above will have problems when working with them.

Parameters
NameTypeDescription
valueintegerThe unsigned 8-byte integer.
Returns
TypeNameDescription
stringdataThe 8-byte string.

#pack.writeUInt8

sharedmenunodiscardsource
function pack.writeUInt8(value: integer): string

Writes unsigned 1-byte (8 bit) integer as a string.

Valid values without loss of precision: 0 - 255

Parameters
NameTypeDescription
valueintegerThe unsigned 1-byte integer.
Returns
TypeNameDescription
stringdataThe 1-byte string.
Generated from the dreamwork meta branch.