diff --git a/src/Atom.lua b/src/Atom.lua index 07e4ab8..5a9a49c 100644 --- a/src/Atom.lua +++ b/src/Atom.lua @@ -7,6 +7,6 @@ else if AtomServer and RunService:IsRunning() then AtomServer:Destroy() end - + return require(script:FindFirstChild("AtomClient_OOP", true)) -end \ No newline at end of file +end diff --git a/src/AtomModuleContents/AtomClient_OOP.lua b/src/AtomModuleContents/AtomClient_OOP.lua index be62ad7..6a84697 100644 --- a/src/AtomModuleContents/AtomClient_OOP.lua +++ b/src/AtomModuleContents/AtomClient_OOP.lua @@ -8,7 +8,7 @@ Tools Used in Atom Development: VSCode Insider Edition, Argon Code Sync. ]] --- Initialize the Module Script table to allow external access +-- Initialize the Module Script table to allow external access -- to the API and making a reference to where everything SHOULD be stored. local AtomMain = {} local AtomRoot = script.Parent.Parent @@ -16,8 +16,8 @@ local AtomRoot = script.Parent.Parent local started = false -- Make Types for tables and arrays as they don't officially have types. -type tab = { [string] : string | boolean | Instance } -type array = { [number] : typ } +type tab = { [string]: string | boolean | Instance } +type array = { [number]: typ } -- Set Important Directories local Controllers = AtomRoot.Controllers @@ -91,12 +91,12 @@ Origin:Init() ]] function AtomMain.Start() - if _VERSION ~= "Luau" then - ErrorSignal:Fire("Running on an External Lua Runtime.") - return + if _VERSION ~= "Luau" then + ErrorSignal:Fire("Running on an External Lua Runtime.") + return end - if started then - return Promise.reject("Atom has already started.") + if started then + return Promise.reject("Atom has already started.") end local InitJanitor = Janitor.new() @@ -153,8 +153,8 @@ function AtomMain.Start() local EndSubTick = SubTick() onCompletedSignal:Fire("Atom has started succesfully.") local InitTick = tostring(EndTick - StartTick) - local InitSubTick = tostring(EndSubTick - StartSubTick) - print("Atom Started with a tick of "..InitTick.." and a sub tick of "..InitSubTick..".") + local InitSubTick = tostring(EndSubTick - StartSubTick) + print("Atom Started with a tick of " .. InitTick .. " and a sub tick of " .. InitSubTick .. ".") end) end @@ -174,5 +174,5 @@ return { versiondetails = { major = 0, minor = 6, isrelease = false }, AtomRoot = AtomRoot, Core = Core, - Main = AtomMain -} \ No newline at end of file + Main = AtomMain, +} diff --git a/src/AtomModuleContents/AtomServer_OOP.lua b/src/AtomModuleContents/AtomServer_OOP.lua index e38457e..73c0ed7 100644 --- a/src/AtomModuleContents/AtomServer_OOP.lua +++ b/src/AtomModuleContents/AtomServer_OOP.lua @@ -18,16 +18,17 @@ AtomRoot.Parent = game:GetService("ReplicatedStorage") local started: boolean = false -- Set Important Directories -local Services : Folder = AtomRoot.Services -- Needed for custom require and it will be needed further in the script. -local Controllers : Folder = AtomRoot.Controllers -local Components : Folder = AtomRoot.Components +local Services: Folder = AtomRoot.Services -- Needed for custom require and it will be needed further in the script. +local Controllers: Folder = AtomRoot.Controllers +local Components: Folder = AtomRoot.Components local Packages = AtomRoot:WaitForChild("Packages") -- Overwrite Functions -- local ModuleLoader = require(script.Parent.Utils.ModuleLoader) -- Needed for custom require. --[[local function require(Directory:Instance, ScriptName:string) return ModuleLoader:require(Directory, ScriptName) -end ]] -- Removed while I try fix the Intellisense issues it causes. +end ]] +-- Removed while I try fix the Intellisense issues it causes. function SubTick() return tick() / 2 @@ -98,12 +99,12 @@ Atom.Start() ]] function AtomMain.Start() - if started then - return Promise.reject("Atom has already started.") + if started then + return Promise.reject("Atom has already started.") end - if _VERSION ~= "Luau" then - ErrorSignal:Fire("Atom can't run on non Luau Runtimes.") - return + if _VERSION ~= "Luau" then + ErrorSignal:Fire("Atom can't run on non Luau Runtimes.") + return end local StartTick = tick() @@ -181,8 +182,8 @@ end function AtomMain.GetService(ServiceName: string) for i, v in ipairs(Services:GetChildren()) do print(i) - if v.ClassName ~= "ModuleScript" and v.Name ~= ServiceName then - continue + if v.ClassName ~= "ModuleScript" and v.Name ~= ServiceName then + continue end return require(Services:WaitForChild(ServiceName)) end @@ -201,7 +202,7 @@ function AtomMain.CreateUnreliableRemoteEvent(RemoteName: string) end function AtomMain.GetSignal(SignalName: string, SignalType: string) - return Remotes:WaitForChild(SignalType.."s"):FindFirstChild(SignalName) + return Remotes:WaitForChild(SignalType .. "s"):FindFirstChild(SignalName) end local Core = script.Parent.Core @@ -215,5 +216,5 @@ return { Badges = require(Core.Badges), DataStores = require(Core.DataStore).DataStores, MemoryStoreOperations = require(Core.MemoryStoreOperations), - Serializer = require(Core.Serializer) + Serializer = require(Core.Serializer), } diff --git a/src/AtomModuleContents/ClientBootstrapper.client.lua b/src/AtomModuleContents/ClientBootstrapper.client.lua index 4d3ee16..cb55372 100644 --- a/src/AtomModuleContents/ClientBootstrapper.client.lua +++ b/src/AtomModuleContents/ClientBootstrapper.client.lua @@ -4,4 +4,4 @@ local Atom = require(script.Parent) local Main = Atom.Main Main.Start() -print(Atom.versiondetails) \ No newline at end of file +print(Atom.versiondetails) diff --git a/src/AtomModuleContents/Core/Badges.lua b/src/AtomModuleContents/Core/Badges.lua index db24b59..2dac801 100644 --- a/src/AtomModuleContents/Core/Badges.lua +++ b/src/AtomModuleContents/Core/Badges.lua @@ -7,7 +7,7 @@ function Badges:GetBadgeService() return game:GetService("BadgeService") end -function Badges:AwardBadge(player:Player, BadgeID:number) +function Badges:AwardBadge(player: Player, BadgeID: number) local BadgeService = Badges:GetBadgeService() local DoesThePlayerHaveTheBadge = BadgeService:UserHasBadgeAsync(player.UserId, BadgeID) @@ -18,7 +18,7 @@ function Badges:AwardBadge(player:Player, BadgeID:number) end) if not success then - player:Kick("Error with BadgeService. "..errormessage) + player:Kick("Error with BadgeService. " .. errormessage) end end diff --git a/src/AtomModuleContents/Core/MemoryStoreOperations.lua b/src/AtomModuleContents/Core/MemoryStoreOperations.lua index e956c02..0e8d23a 100644 --- a/src/AtomModuleContents/Core/MemoryStoreOperations.lua +++ b/src/AtomModuleContents/Core/MemoryStoreOperations.lua @@ -8,23 +8,38 @@ function MemoryStoreOperations:GetMemoryStoreService() return game:GetService("MemoryStoreService") end -function MemoryStoreOperations:CreateMemoryStoreQueue(QueueName:string) +function MemoryStoreOperations:CreateMemoryStoreQueue(QueueName: string) return game:GetService("MemoryStoreService"):GetQueue(QueueName) end -function MemoryStoreOperations:GetSortedMap(name:string) +function MemoryStoreOperations:GetSortedMap(name: string) return game:GetService("MemoryStoreService"):GetSortedMap(name) end -function MemoryStoreOperations:AddToMemoryStoreQueue(Queue:MemoryStoreQueue, Value:any, Expiration:number, Priority:number) +function MemoryStoreOperations:AddToMemoryStoreQueue( + Queue: MemoryStoreQueue, + Value: any, + Expiration: number, + Priority: number +) Queue:AddAsync(Value, Expiration, Priority) end -function MemoryStoreOperations:AddToSortedMap(SortedMap:MemoryStoreSortedMap, Key:string, Value:any, Expiration:number) +function MemoryStoreOperations:AddToSortedMap( + SortedMap: MemoryStoreSortedMap, + Key: string, + Value: any, + Expiration: number +) SortedMap:SetAsync(Key, Value, Expiration) end -function MemoryStoreOperations:GetMemoryIdentifier(Queue:MemoryStoreQueue, count:number, allOrNothing:boolean, waitTimeout:number) +function MemoryStoreOperations:GetMemoryIdentifier( + Queue: MemoryStoreQueue, + count: number, + allOrNothing: boolean, + waitTimeout: number +) local results, identifier = Queue:ReadAsync(count, allOrNothing, waitTimeout) if not results then return nil @@ -33,16 +48,21 @@ function MemoryStoreOperations:GetMemoryIdentifier(Queue:MemoryStoreQueue, count end end -function MemoryStoreOperations:RemoveFromMemoryStoreQueue(Queue:MemoryStoreQueue, Identifier:string) +function MemoryStoreOperations:RemoveFromMemoryStoreQueue(Queue: MemoryStoreQueue, Identifier: string) local success, errormessage = pcall(function() Queue:RemoveAsync(Identifier) end) if not success then - warn("Error removing from MemoryStoreQueue. "..errormessage) + warn("Error removing from MemoryStoreQueue. " .. errormessage) end end -function MemoryStoreOperations:ReadFromMemoryStoreQueue(Queue:MemoryStoreQueue, count:number, allOrNothing:boolean, waitTimeout:number) +function MemoryStoreOperations:ReadFromMemoryStoreQueue( + Queue: MemoryStoreQueue, + count: number, + allOrNothing: boolean, + waitTimeout: number +) local results = nil local success, errormessage = pcall(function() results = Queue:ReadAsync(count, allOrNothing, waitTimeout) @@ -50,15 +70,15 @@ function MemoryStoreOperations:ReadFromMemoryStoreQueue(Queue:MemoryStoreQueue, if success then return results elseif not success then - warn("Error reading MemoryStoreQueue. "..errormessage) + warn("Error reading MemoryStoreQueue. " .. errormessage) return nil else - warn("Error with function "..errormessage) + warn("Error with function " .. errormessage) return nil end end -function MemoryStoreOperations:ReadFromSortedMap(SortedMap:MemoryStoreSortedMap, Key:string) +function MemoryStoreOperations:ReadFromSortedMap(SortedMap: MemoryStoreSortedMap, Key: string) local SortedMapData = nil local success, errormessage = pcall(function() SortedMapData = SortedMap:GetAsync(Key) @@ -66,16 +86,21 @@ function MemoryStoreOperations:ReadFromSortedMap(SortedMap:MemoryStoreSortedMap, if success then return SortedMapData elseif not success then - warn("Error getting Value! "..errormessage) + warn("Error getting Value! " .. errormessage) return nil else - warn("Error with function! "..errormessage) + warn("Error with function! " .. errormessage) return nil end end -function MemoryStoreOperations:UpdateSortedMapValue(SortedMap:MemoryStoreSortedMap, Key, transformFunction, Expiration:number) +function MemoryStoreOperations:UpdateSortedMapValue( + SortedMap: MemoryStoreSortedMap, + Key, + transformFunction, + Expiration: number +) SortedMap:UpdateAsync(Key, transformFunction, Expiration) end -return MemoryStoreOperations \ No newline at end of file +return MemoryStoreOperations diff --git a/src/AtomModuleContents/Core/Serializer.lua b/src/AtomModuleContents/Core/Serializer.lua index f9e9589..2ab2381 100644 --- a/src/AtomModuleContents/Core/Serializer.lua +++ b/src/AtomModuleContents/Core/Serializer.lua @@ -20,7 +20,7 @@ function Serializer.serialize(Buffer: buffer, offset: number, DataType: string, case("table")(function() for i, v in ipairs(Data) do - print("Atom Serializer "..i) + print("Atom Serializer " .. i) Serializer.serialize(Buffer, offset, DataType, v) -- recursively serialize each element in the table end end), diff --git a/src/AtomModuleContents/Core/Switch.lua b/src/AtomModuleContents/Core/Switch.lua index 93e8dea..97673dd 100644 --- a/src/AtomModuleContents/Core/Switch.lua +++ b/src/AtomModuleContents/Core/Switch.lua @@ -1,42 +1,44 @@ local bypassIndex = math.huge -- As a heads up, NEVER set your case value to this. It will break things! -local self; self = { +local self +self = { [1] = function(condition) -- Switch -- The first thing we want to do is get that condition, and NOT call the case function, so we will just -- return another function with the functionality of a case - + return function(cases) for index, case in ipairs(cases) do local conditionResult, caseFunction = case(condition) if typeof(conditionResult) == "function" then -- If conditionResult is a function, we can assume we just came across a default statement - + if index ~= #cases then error("Attempted to use a default statement in an index that was not the last") - else conditionResult() break end - elseif typeof(conditionResult) == "boolean" then -- If conditionResult is a boolean, we can assume we just came across a case statement - + if conditionResult then if caseFunction then -- If the case has its own defined function, immediately call it - - caseFunction() + caseFunction() else -- Otherwise, let's look for the next case attached to a function - + while true do index += 1 if cases[index] == self[3] then - warn("Case " .. condition .. " does not ever break, and ends in a default statement. Did you forget to include a function somewhere?") + warn( + "Case " + .. condition + .. " does not ever break, and ends in a default statement. Did you forget to include a function somewhere?" + ) break end @@ -45,9 +47,12 @@ local self; self = { if newCaseFunction then newCaseFunction() break - elseif index > #cases then - warn("Case " .. condition .. " does not ever break. Did you forget to include a function somewhere?") + warn( + "Case " + .. condition + .. " does not ever break. Did you forget to include a function somewhere?" + ) break end end @@ -55,14 +60,12 @@ local self; self = { break end - else -- We should expect cases to return a boolean userdata value, and a function userdata value for default statements -- Anything else is unacceptable because its not a compatible statement - + error("Attempted to use a non-valid statement in the switch statement") end - end end end, @@ -71,15 +74,15 @@ local self; self = { -- The first thing we want is to get the checked comparison -- Of course, we don't want to run the case function, so let's -- return a parent function - + return function(caseFunction) return function(conditionValue) -- In here, we check if the condition meets the case required value - -- If so, the switch statement will recognize this by recieving a + -- If so, the switch statement will recognize this by recieving a -- true value, and this finding the first occuring attached function. -- If not, the switch statement will recieve a false value and ignore -- the case. - + if conditionValue == bypassIndex or conditionValue == requiredValue then return true, caseFunction else @@ -92,7 +95,7 @@ local self; self = { [3] = function() -- Default -- This works almost exactly like a case, except we do not check a condition -- This is similar to an "else" statement in lua/luau - + return function(defaultFunction) return function() return defaultFunction @@ -101,4 +104,4 @@ local self; self = { end, } -return self \ No newline at end of file +return self diff --git a/src/AtomModuleContents/ServerBootstrapper.server.lua b/src/AtomModuleContents/ServerBootstrapper.server.lua index 4d3ee16..cb55372 100644 --- a/src/AtomModuleContents/ServerBootstrapper.server.lua +++ b/src/AtomModuleContents/ServerBootstrapper.server.lua @@ -4,4 +4,4 @@ local Atom = require(script.Parent) local Main = Atom.Main Main.Start() -print(Atom.versiondetails) \ No newline at end of file +print(Atom.versiondetails) diff --git a/src/AtomModuleContents/Utils/ModuleLoader.lua b/src/AtomModuleContents/Utils/ModuleLoader.lua index f2c5507..5ecc05b 100644 --- a/src/AtomModuleContents/Utils/ModuleLoader.lua +++ b/src/AtomModuleContents/Utils/ModuleLoader.lua @@ -3,13 +3,13 @@ local ModuleLoader = {} ModuleLoader.__index = ModuleLoader -function ModuleLoader:require(Directory, ScriptName:string) +function ModuleLoader:require(Directory, ScriptName: string) local Modules = Directory:GetChildren() for i, v in ipairs(Modules) do if v:IsA("ModuleScript") and v.Name == ScriptName then - print("Module Loader: "..i..". Requiring "..v:GetFullName()) - local mod : ModuleScript = require(v) + print("Module Loader: " .. i .. ". Requiring " .. v:GetFullName()) + local mod: ModuleScript = require(v) return mod end end @@ -17,4 +17,4 @@ function ModuleLoader:require(Directory, ScriptName:string) return nil end -return ModuleLoader \ No newline at end of file +return ModuleLoader diff --git a/src/Components/RemoteEvent.lua b/src/Components/RemoteEvent.lua index 3a6c63a..f2e3838 100644 --- a/src/Components/RemoteEvent.lua +++ b/src/Components/RemoteEvent.lua @@ -5,7 +5,7 @@ ServerRemoteEvent.__index = ServerRemoteEvent local RunService = game:GetService("RunService") -local function serialize(Buffer : buffer, offset : number, DataType:string , Data) +local function serialize(Buffer: buffer, offset: number, DataType: string, Data) local dataType = string.lower(DataType) if dataType == "number" then @@ -18,7 +18,7 @@ local function serialize(Buffer : buffer, offset : number, DataType:string , Dat end elseif dataType == "table" then for i, v in ipairs(Data) do - print("Atom Serializer "..i) + print("Atom Serializer " .. i) serialize(Buffer, offset, DataType, v) -- recursively serialize each element in the table end else @@ -26,21 +26,21 @@ local function serialize(Buffer : buffer, offset : number, DataType:string , Dat end end -function ServerRemoteEvent.new(RemoteName:string, Parent:Instance) +function ServerRemoteEvent.new(RemoteName: string, Parent: Instance) local ServerRemoteEventInstance = Instance.new("RemoteEvent") ServerRemoteEventInstance.Parent = Parent ServerRemoteEventInstance.Name = RemoteName return ServerRemoteEventInstance end -function ClientRemoteEvent.new(RemoteName:string, Parent:Instance) +function ClientRemoteEvent.new(RemoteName: string, Parent: Instance) local ClientRemoteEventInstance = Instance.new("RemoteEvent") ClientRemoteEventInstance.Parent = Parent ClientRemoteEventInstance.Name = RemoteName return ClientRemoteEventInstance end -function ServerRemoteEvent:FireClient(player:Player, Remote:RemoteEvent, Data:any) +function ServerRemoteEvent:FireClient(player: Player, Remote: RemoteEvent, Data: any) Remote:FireClient(player, Data) end @@ -50,4 +50,4 @@ elseif RunService:IsClient() then return ClientRemoteEvent else return warn("Unable to detect runtime environment.") -end \ No newline at end of file +end diff --git a/src/Packages/GoodSignal.lua b/src/Packages/GoodSignal.lua index 4090e39..a09297f 100644 --- a/src/Packages/GoodSignal.lua +++ b/src/Packages/GoodSignal.lua @@ -39,7 +39,7 @@ local function acquireRunnerThreadAndCallEventHandler(fn, ...) freeRunnerThread = acquiredRunnerThread end --- Coroutine runner that we create coroutines of. The coroutine can be +-- Coroutine runner that we create coroutines of. The coroutine can be -- repeatedly resumed with functions to run followed by the argument to run -- them with. local function runEventHandlerInFreeThread() @@ -93,7 +93,7 @@ setmetatable(Connection, { end, __newindex = function(key) error(("Attempt to set Connection::%s (not a valid member)"):format(tostring(key)), 2) - end + end, }) -- Signal class @@ -146,7 +146,7 @@ end -- a Signal:Connect() which disconnects itself. function Signal:Wait() local waitingCoroutine = coroutine.running() - local cn; + local cn cn = self:Connect(function(...) cn:Disconnect() task.spawn(waitingCoroutine, ...) @@ -157,7 +157,7 @@ end -- Implement Signal:Once() in terms of a connection which disconnects -- itself before running the handler. function Signal:Once(fn) - local cn; + local cn cn = self:Connect(function(...) if cn._connected then cn:Disconnect() @@ -174,7 +174,7 @@ setmetatable(Signal, { end, __newindex = function(key) error(("Attempt to set Signal::%s (not a valid member)"):format(tostring(key)), 2) - end + end, }) return Signal diff --git a/src/Packages/Janitor.lua b/src/Packages/Janitor.lua index 362887a..5b5ad86 100644 --- a/src/Packages/Janitor.lua +++ b/src/Packages/Janitor.lua @@ -12,13 +12,13 @@ local Promise = require(script.Parent.Promise) local IndicesReference = setmetatable({}, { __tostring = function() return "IndicesReference" - end; + end, }) local LinkToInstanceIndex = setmetatable({}, { __tostring = function() return "LinkToInstanceIndex" - end; + end, }) local INVALID_METHOD_NAME = @@ -59,9 +59,9 @@ Janitor.__index = Janitor ]=] local TypeDefaults = { - ["function"] = true; - thread = true; - RBXScriptConnection = "Disconnect"; + ["function"] = true, + thread = true, + RBXScriptConnection = "Disconnect", } --[=[ @@ -70,8 +70,8 @@ local TypeDefaults = { ]=] function Janitor.new(): Janitor return setmetatable({ - CurrentlyCleaning = false; - [IndicesReference] = nil; + CurrentlyCleaning = false, + [IndicesReference] = nil, }, Janitor) :: any end @@ -235,15 +235,19 @@ function Janitor:AddPromise(PromiseObject) if PromiseObject:getStatus() == Promise.Status.Started then local Id = newproxy(false) - local NewPromise = self:Add(Promise.new(function(Resolve, _, OnCancel) - if OnCancel(function() - PromiseObject:cancel() - end) then - return - end + local NewPromise = self:Add( + Promise.new(function(Resolve, _, OnCancel) + if OnCancel(function() + PromiseObject:cancel() + end) then + return + end - Resolve(PromiseObject) - end), "cancel", Id) + Resolve(PromiseObject) + end), + "cancel", + Id + ) NewPromise:finallyCall(self.Remove, self, Id) return NewPromise @@ -551,7 +555,7 @@ end @since v1.15.1 @return {[any]: any} ]=] -function Janitor:GetAll(): {[any]: any} +function Janitor:GetAll(): { [any]: any } local This = self[IndicesReference] return if This then table.freeze(table.clone(This)) else {} end @@ -694,9 +698,13 @@ Janitor.__call = Janitor.Cleanup function Janitor:LinkToInstance(Object: Instance, AllowMultiple: boolean?): RBXScriptConnection local IndexToUse = if AllowMultiple then newproxy(false) else LinkToInstanceIndex - return self:Add(Object.Destroying:Connect(function() - self:Cleanup() - end), "Disconnect", IndexToUse) + return self:Add( + Object.Destroying:Connect(function() + self:Cleanup() + end), + "Disconnect", + IndexToUse + ) end Janitor.LegacyLinkToInstance = Janitor.LinkToInstance @@ -740,7 +748,7 @@ export type Janitor = { RemoveListNoClean: (self: Janitor, ...any) -> Janitor, Get: (self: Janitor, Index: any) -> any?, - GetAll: (self: Janitor) -> {[any]: any}, + GetAll: (self: Janitor) -> { [any]: any }, Cleanup: (self: Janitor) -> (), Destroy: (self: Janitor) -> (), diff --git a/src/Packages/Sourceesque.lua b/src/Packages/Sourceesque.lua index 7d49b17..fbdd169 100644 --- a/src/Packages/Sourceesque.lua +++ b/src/Packages/Sourceesque.lua @@ -11,12 +11,12 @@ ---- Settings ---- type BaseValues = number | Vector3 -export type ValueWrapper = () -> (BaseValues) +export type ValueWrapper = () -> BaseValues export type SupportedValues = BaseValues & ValueWrapper local TRUE = 0b1 local FALSE = 0b0 -local NAN = 0/0 +local NAN = 0 / 0 local NAN_VECTOR = Vector3.new(NAN, NAN, NAN) local COMPRESSION_TYPES = { @@ -29,13 +29,13 @@ local COMPRESSION_TYPES = { Integer = "j", UnsignedByte = "B", UnsignedShort = "H", - UnsignedInteger = "J" + UnsignedInteger = "J", } ---- Constants ---- local Utility = { - CompressionTypes = COMPRESSION_TYPES + CompressionTypes = COMPRESSION_TYPES, } ---- Variables ---- @@ -58,13 +58,13 @@ end ---- Public Functions ---- -function Utility.Always(Value: BaseValues): () -> (BaseValues) +function Utility.Always(Value: BaseValues): () -> BaseValues return function() return Value end end -function Utility.ReconcileWithDeltaTable(DeltaTable: {BaseValues}, BaseTable: {BaseValues}) +function Utility.ReconcileWithDeltaTable(DeltaTable: { BaseValues }, BaseTable: { BaseValues }) for Index, BaseValue in BaseTable do local DeltaValue = DeltaTable[Index] if type(BaseValue) == "number" then @@ -77,7 +77,7 @@ function Utility.ReconcileWithDeltaTable(DeltaTable: {BaseValues}, BaseTable: {B DeltaValue.X ~= DeltaValue.X and BaseValue.X or DeltaValue.X, DeltaValue.Y ~= DeltaValue.Y and BaseValue.Y or DeltaValue.Y, DeltaValue.Z ~= DeltaValue.Z and BaseValue.Z or DeltaValue.Z - ) + ) end end @@ -85,7 +85,7 @@ function Utility.ReconcileWithDeltaTable(DeltaTable: {BaseValues}, BaseTable: {B end end -function Utility.CreateCompressionTable(Types: {string}) +function Utility.CreateCompressionTable(Types: { string }) local Format = table.concat(Types) local RawTypes = Types local DeltaFormat = GetDeltaFormat(#Format) @@ -95,10 +95,10 @@ function Utility.CreateCompressionTable(Types: {string}) return { Size = string.packsize(DeltaFormat .. Format), - Compress = function(Values: {SupportedValues}, PreviousValues: {BaseValues}): (string, number) + Compress = function(Values: { SupportedValues }, PreviousValues: { BaseValues }): (string, number) local Stream = "" local StreamFormat = "" - local ChangedValues: {BaseValues} = table.create(#Values) + local ChangedValues: { BaseValues } = table.create(#Values) --> Remove wrappers for Index, Value in Values do @@ -107,7 +107,7 @@ function Utility.CreateCompressionTable(Types: {string}) Values[Index] = Raw if PreviousValues then PreviousValues[Index] = GetSubstituteType(Raw) - end + end end end @@ -151,16 +151,16 @@ function Utility.CreateCompressionTable(Types: {string}) VectorBits += bit32.lshift(ZBit, 2) --> Insert changed axes - if XBit == TRUE then - table.insert(ChangedValues, Current.X) + if XBit == TRUE then + table.insert(ChangedValues, Current.X) end - if YBit == TRUE then - table.insert(ChangedValues, Current.Y) + if YBit == TRUE then + table.insert(ChangedValues, Current.Y) end - if ZBit == TRUE then - table.insert(ChangedValues, Current.Z) + if ZBit == TRUE then + table.insert(ChangedValues, Current.Z) end --> Add to delta bits & update format @@ -172,7 +172,7 @@ function Utility.CreateCompressionTable(Types: {string}) TypeCursor += 1 DeltaCursor += 1 - if HasValueChanged then + if HasValueChanged then StreamFormat ..= Types[TypeCursor] table.insert(ChangedValues, Current) end @@ -185,12 +185,12 @@ function Utility.CreateCompressionTable(Types: {string}) return Stream, string.packsize(DeltaFormat .. StreamFormat) end, - Decompress = function(Stream: string): ({BaseValues}, number) + Decompress = function(Stream: string): ({ BaseValues }, number) local StreamFormat = "" - local Values: {BaseValues} = table.create(#Types, NAN) - local ValueIndices: {number} = {} - local VectorIndices: {number} = {} + local Values: { BaseValues } = table.create(#Types, NAN) + local ValueIndices: { number } = {} + local VectorIndices: { number } = {} --> Construct stream format from delta compressed portion local Offset = 0 @@ -218,7 +218,7 @@ function Utility.CreateCompressionTable(Types: {string}) if YBit == TRUE then StreamIndex += 1 ValueIndices[StreamIndex] = ValueIndex + 1 - end + end if ZBit == TRUE then StreamIndex += 1 @@ -238,7 +238,7 @@ function Utility.CreateCompressionTable(Types: {string}) end --> Unpack the compressed stream, read with X bytes offset (first X bytes are used by the delta compression) - local UnpackedValues = {string.unpack(StreamFormat, Stream, DeltaFormatOffset)} + local UnpackedValues = { string.unpack(StreamFormat, Stream, DeltaFormatOffset) } --> Remove the extra value returned by string.unpack UnpackedValues[#UnpackedValues] = nil @@ -254,11 +254,11 @@ function Utility.CreateCompressionTable(Types: {string}) Values[ReadIndex] :: number, table.remove(Values, ReadIndex + 1) :: number, table.remove(Values, ReadIndex + 1) :: number - ) + ) end return Values, string.packsize(DeltaFormat .. StreamFormat) - end + end, } end @@ -266,4 +266,4 @@ end ---- Connections ---- -return Utility \ No newline at end of file +return Utility diff --git a/src/Packages/Switch.lua b/src/Packages/Switch.lua index 93e8dea..97673dd 100644 --- a/src/Packages/Switch.lua +++ b/src/Packages/Switch.lua @@ -1,42 +1,44 @@ local bypassIndex = math.huge -- As a heads up, NEVER set your case value to this. It will break things! -local self; self = { +local self +self = { [1] = function(condition) -- Switch -- The first thing we want to do is get that condition, and NOT call the case function, so we will just -- return another function with the functionality of a case - + return function(cases) for index, case in ipairs(cases) do local conditionResult, caseFunction = case(condition) if typeof(conditionResult) == "function" then -- If conditionResult is a function, we can assume we just came across a default statement - + if index ~= #cases then error("Attempted to use a default statement in an index that was not the last") - else conditionResult() break end - elseif typeof(conditionResult) == "boolean" then -- If conditionResult is a boolean, we can assume we just came across a case statement - + if conditionResult then if caseFunction then -- If the case has its own defined function, immediately call it - - caseFunction() + caseFunction() else -- Otherwise, let's look for the next case attached to a function - + while true do index += 1 if cases[index] == self[3] then - warn("Case " .. condition .. " does not ever break, and ends in a default statement. Did you forget to include a function somewhere?") + warn( + "Case " + .. condition + .. " does not ever break, and ends in a default statement. Did you forget to include a function somewhere?" + ) break end @@ -45,9 +47,12 @@ local self; self = { if newCaseFunction then newCaseFunction() break - elseif index > #cases then - warn("Case " .. condition .. " does not ever break. Did you forget to include a function somewhere?") + warn( + "Case " + .. condition + .. " does not ever break. Did you forget to include a function somewhere?" + ) break end end @@ -55,14 +60,12 @@ local self; self = { break end - else -- We should expect cases to return a boolean userdata value, and a function userdata value for default statements -- Anything else is unacceptable because its not a compatible statement - + error("Attempted to use a non-valid statement in the switch statement") end - end end end, @@ -71,15 +74,15 @@ local self; self = { -- The first thing we want is to get the checked comparison -- Of course, we don't want to run the case function, so let's -- return a parent function - + return function(caseFunction) return function(conditionValue) -- In here, we check if the condition meets the case required value - -- If so, the switch statement will recognize this by recieving a + -- If so, the switch statement will recognize this by recieving a -- true value, and this finding the first occuring attached function. -- If not, the switch statement will recieve a false value and ignore -- the case. - + if conditionValue == bypassIndex or conditionValue == requiredValue then return true, caseFunction else @@ -92,7 +95,7 @@ local self; self = { [3] = function() -- Default -- This works almost exactly like a case, except we do not check a condition -- This is similar to an "else" statement in lua/luau - + return function(defaultFunction) return function() return defaultFunction @@ -101,4 +104,4 @@ local self; self = { end, } -return self \ No newline at end of file +return self diff --git a/src/Packages/TextLib.lua b/src/Packages/TextLib.lua index 0b050c0..d19bb82 100644 --- a/src/Packages/TextLib.lua +++ b/src/Packages/TextLib.lua @@ -2,9 +2,9 @@ -- Written by crazyattaker1. 29/10/2024. Lightweight RichText Implementation. local TextLib = {} -type Properties = { Bold:boolean, StrikeThrough:boolean, Underline:boolean, Italics:boolean } +type Properties = { Bold: boolean, StrikeThrough: boolean, Underline: boolean, Italics: boolean } -function TextLib.Update(Text:string, PropertiesTable:Properties) +function TextLib.Update(Text: string, PropertiesTable: Properties) local BoldPrefix = "" local BoldSuffix = "" local StrikePrefix = "" @@ -30,7 +30,15 @@ function TextLib.Update(Text:string, PropertiesTable:Properties) ItalicsSuffix = "" end task.wait(1) - return BoldPrefix..StrikePrefix..UnderlinePrefix..ItalicsPrefix..Text..ItalicsSuffix..UnderlineSuffix..StrikeSuffix..BoldSuffix + return BoldPrefix + .. StrikePrefix + .. UnderlinePrefix + .. ItalicsPrefix + .. Text + .. ItalicsSuffix + .. UnderlineSuffix + .. StrikeSuffix + .. BoldSuffix end return TextLib diff --git a/src/Services/TemplateService.lua b/src/Services/TemplateService.lua index a1e66e4..c4a3c0c 100644 --- a/src/Services/TemplateService.lua +++ b/src/Services/TemplateService.lua @@ -10,7 +10,7 @@ function Template.new() function self.Start() print("Atom TemplateService started.") end - + return self end