sm.uuid
Associated object type: Uuid
A Universally Unique Identifier (UUID) is a 128-bit number that can guarantee uniqueness across space and time.
To generate one, use sm.uuid.new.
Functions
generateNamed
local uuid = sm.uuid.generateNamed(namespace, name)
Generates a named (version 5) UUID.
The namespace UUID makes sure any equal names from different namespaces do not collide.
Provided the same namespace and name in repeated calls, the generated UUID will be the same.
Parameters:
namespace(Uuid): A namespace UUID.name(string): A name, to generate a UUID from.
Returns:
uuid(Uuid): The created UUID.
generateRandom
local uuid = sm.uuid.generateRandom()
Generates a random (version 4) UUID.
Returns:
uuid(Uuid): The created UUID.
getNil
local uuid = sm.uuid.getNil()
Creates a nil UUID 00000000-0000-0000-0000-000000000000.
Returns:
uuid(Uuid): The created UUID.
new
local uuid = sm.uuid.new(uuidString)
Creates a UUID from a string or generates a random UUID (version 4).
Parameters:
uuidStr(string, optional): The UUID string. Defaults to random.
Returns:
uuid(Uuid): The created UUID.
isNil
local isNil = sm.uuid.isNil(uuid)
Checks if the given UUID is a nil UUID (00000000-0000-0000-0000-000000000000).
This does the same as calling Uuid:isNil(), but can have better performance in certain cases.
Parameters:
uuid(Uuid): The UUID.
Returns:
isNil(boolean): Whether the UUID is nil or not.