diff --git a/Useful Modules/Util/UniqueIds.luau b/Useful Modules/Util/UniqueIds.luau index 17e2fa2..76f1553 100644 --- a/Useful Modules/Util/UniqueIds.luau +++ b/Useful Modules/Util/UniqueIds.luau @@ -35,11 +35,11 @@ function UniqueIds.new(bytes: number, b93: boolean?, idsInUse: {string}?): Uniqu if idsInUse then for _, id in idsInUse do - numUniqueIds = math.max(numUniqueIds, UniqueIds:GetIndexFromId(bytes, id, b93) + 1) + numUniqueIds = math.max(numUniqueIds, UniqueIds.GetIndexFromId(bytes, id, b93) + 1) end for index = 1, numUniqueIds do - local id = UniqueIds:GetIdFromIndex(bytes, index - 1, b93) + local id = UniqueIds.GetIdFromIndex(bytes, index - 1, b93) if not table.find(idsInUse, id) then table.insert(unusedIds, id) numUnusedIds += 1 @@ -54,14 +54,14 @@ function UniqueIds.new(bytes: number, b93: boolean?, idsInUse: {string}?): Uniqu numUnusedIds -= 1 return id else - local id = UniqueIds:GetIdFromIndex(bytes, numUniqueIds, b93) + local id = UniqueIds.GetIdFromIndex(bytes, numUniqueIds, b93) numUniqueIds += 1 return id end end; FreeId = function(self: UniqueIds, id: string): () - local index = UniqueIds:GetIndexFromId(bytes, id, b93) + local index = UniqueIds.GetIndexFromId(bytes, id, b93) assert(index < numUniqueIds and not table.find(unusedIds, id), "ID not in use") table.insert(unusedIds, id) numUnusedIds += 1 @@ -74,7 +74,7 @@ end --- @param id -- The unique ID string. --- @param b93 -- Whether or not to use the Base93 format. --- @return number -- The index of the unique ID string. -function UniqueIds:GetIndexFromId(bytes: number, id: string, b93: boolean?): number +function UniqueIds.GetIndexFromId(bytes: number, id: string, b93: boolean?): number return if b93 then Base93.B93ToInt(id) else string.unpack("I" .. bytes, id) end @@ -83,7 +83,7 @@ end --- @param index -- The index of the unique ID string. --- @param b93 -- Whether or not to use the Base93 format. --- @return string -- The unique ID string. -function UniqueIds:GetIdFromIndex(bytes: number, index: number, b93: boolean?): string +function UniqueIds.GetIdFromIndex(bytes: number, index: number, b93: boolean?): string return if b93 then Base93.IntToB93(index, bytes) else string.pack("I" .. bytes, index) end