Skip to content

Commit

Permalink
Formatted
Browse files Browse the repository at this point in the history
  • Loading branch information
crazyRBLX11 committed Nov 24, 2024
1 parent 4f4d5f3 commit fae4c7c
Show file tree
Hide file tree
Showing 17 changed files with 201 additions and 153 deletions.
4 changes: 2 additions & 2 deletions src/Atom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ else
if AtomServer and RunService:IsRunning() then
AtomServer:Destroy()
end

return require(script:FindFirstChild("AtomClient_OOP", true))
end
end
24 changes: 12 additions & 12 deletions src/AtomModuleContents/AtomClient_OOP.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ 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

local started = false

-- Make Types for tables and arrays as they don't officially have types.
type tab = { [string] : string | boolean | Instance }
type array<typ> = { [number] : typ }
type tab = { [string]: string | boolean | Instance }
type array<typ> = { [number]: typ }

-- Set Important Directories
local Controllers = AtomRoot.Controllers
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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

Expand All @@ -174,5 +174,5 @@ return {
versiondetails = { major = 0, minor = 6, isrelease = false },
AtomRoot = AtomRoot,
Core = Core,
Main = AtomMain
}
Main = AtomMain,
}
27 changes: 14 additions & 13 deletions src/AtomModuleContents/AtomServer_OOP.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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),
}
2 changes: 1 addition & 1 deletion src/AtomModuleContents/ClientBootstrapper.client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ local Atom = require(script.Parent)
local Main = Atom.Main

Main.Start()
print(Atom.versiondetails)
print(Atom.versiondetails)
4 changes: 2 additions & 2 deletions src/AtomModuleContents/Core/Badges.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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

Expand Down
55 changes: 40 additions & 15 deletions src/AtomModuleContents/Core/MemoryStoreOperations.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -33,49 +48,59 @@ 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)
end)
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)
end)
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
return MemoryStoreOperations
2 changes: 1 addition & 1 deletion src/AtomModuleContents/Core/Serializer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
Loading

0 comments on commit fae4c7c

Please sign in to comment.