Skip to content

Commit

Permalink
Atom required packages added
Browse files Browse the repository at this point in the history
Added most of the packages Atom uses to the source. Fixed some of the issues flagged by Selene and Roblox LSP and moved the old update logs from the Atom modules to it's own .MD file.
  • Loading branch information
crazyRBLX11 committed Oct 29, 2024
1 parent 380c012 commit 97dbf11
Show file tree
Hide file tree
Showing 13 changed files with 3,459 additions and 85 deletions.
18 changes: 18 additions & 0 deletions Pre-0.5-Update-Logs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
V0.1
Implemented a simple module loader.

V0.2
Moved some of the code in the main script into modular code for readability.
Added SubTicks.
Temporarily removed my ModuleLoader as it broke intellisense.
Added the serializer.

V0.4
Implemented the AtomMain.GetService() function,
Implemented the AtomMain.CreateRemoteEvent() function,
Implemented the AtomMain.CreateUnreliableEvent() function,
Implented the Atom.GetSignal() function,

V0.5
Moved the serializer to a seperate script for modularity and added a copy of it's requirements to it.
Fixed the cylical dependency bug in the Module Loader.
6 changes: 3 additions & 3 deletions src/Atom/Atom.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
local RunService = game:GetService("RunService")

if RunService:IsServer() then
return require(script.AtomServer_OOP)
return require(script:FindFirstChild("AtomServer_OOP", true))
else
local AtomServer = script:FindFirstChild("AtomServer_OOP")
local AtomServer = script:FindFirstChild("AtomServer_OOP", true)
if AtomServer and RunService:IsRunning() then
AtomServer:Destroy()
end

return require(script.AtomClient_OOP)
return require(script:FindFirstChild("AtomClient_OOP", true))
end
16 changes: 5 additions & 11 deletions src/Atom/AtomModuleContents/AtomClient_OOP.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ local AtomMain = {}
local AtomRoot = script.Parent.Parent

local started = false
local startComplete = false

-- Make Types for tables and arrays as they don't officially have types.
type tab = { [string] : string | boolean | Instance }
Expand All @@ -30,12 +29,7 @@ local Packages = AtomRoot:WaitForChild("Packages")
--[[local function require(Directory:Instance, ScriptName:string)
return ModuleLoader.new(Directory, ScriptName)
end ]]
local function wait(seconds:number)
return task.wait(seconds)
end
local function Wait(duration:number)
return task.wait(duration)
end

local function SubTick()
return tick() / 2
end
Expand Down Expand Up @@ -154,7 +148,7 @@ function AtomMain.Start()
controllerInitPromises,
Promise.new(function(r)
debug.setmemorycategory(Controller.Name)
local controllertouse = require(Controllers, Controller.Name)
local controllertouse = require(Controllers)
controllertouse.new()
controllertouse:Init()
r()
Expand All @@ -175,7 +169,7 @@ function AtomMain.Start()
controllersStartPromises,
Promise.new(function(r)
debug.setmemorycategory(controller.Name)
local controllertouse = require(Controllers, controller.Name)
local controllertouse = require(Controllers)
controllertouse.new()
controllertouse:Start()
r()
Expand All @@ -184,7 +178,7 @@ function AtomMain.Start()
end
end

startComplete = true
started = true
local EndTick = tick()
local EndSubTick = SubTick()
onCompletedSignal:Fire("Atom has started succesfully.")
Expand All @@ -204,7 +198,7 @@ end
end
end ]]

local Core = script.Parent.Core.Client
local Core = script.Parent.Core

return {
versiondetails = { major = 0, minor = 1, isrelease = false },
Expand Down
79 changes: 13 additions & 66 deletions src/Atom/AtomModuleContents/AtomServer_OOP.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,7 @@
Rewrite of my 2019-2021 framework.
~31/10/2023 crazyattaker1
V0.1
Started Development.
V0.2
Moved some of the code in the main script into modular code for readability.
Added SubTicks.
Temporarily removed my ModuleLoader as it broke intellisense.
Added the serializer.
V0.4
Implemented the AtomMain.GetService() function,
Implemented the AtomMain.CreateRemoteEvent() function,
Implemented the AtomMain.CreateUnreliableEvent() function,
Implented the Atom.GetSignal() function,
V0.5
Moved the serializer to a seperate script for modularity and added a copy of it's requirements to it.
Fixed the cylical dependency bug in the Module Loader.
Tools Used in Atom Development: VSCode Insider Edition, Argon Code Sync.
Tools Used in Atom Development: VSCode Insider Edition, GitHub, GitHub Desktop, Git, Roblox Studio and Argon Code Sync.
]]

Expand All @@ -35,45 +16,27 @@ local AtomRoot = script.Parent.Parent
AtomRoot.Parent = game:GetService("ReplicatedStorage")

local started: boolean = false
local startComplete: boolean = false

-- Set Important Directories
local Services = AtomRoot.Services -- Needed for custom require and it will be needed further in the script.
local Controllers = AtomRoot.Controllers
local Components = 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")

local Utility = Packages.Utility

-- 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 ]]
end ]] -- Removed while I try fix the Intellisense issues it causes.

function SubTick()
return tick() / 2
end

--[[ Currently unused as it broke intellisense. [[
local BSON = require(Packages, "BSON")
local ByteNet = require(Packages, "ByteNet")
local GoodSignal = require(Packages, "GoodSignal")
local Janitor = require(Packages, "Janitor")
local Promise = require(Packages, "Promise")
local Proto = require(Packages, "proto")
local ProfileService = require(Packages, "ProfileService")
local Sourceesque = require(Packages, "Sourceesque")
local Warp = require(Packages, "Warp")
local RestrictRead = require(Utility, "restrictRead")
local Switch, case, default = unpack(require(Packages, "Switch")) ]]

local BSON = require(Packages.BSON)
local ByteNet = require(Packages.ByteNet)
local GoodSignal = require(Packages.GoodSignal)
local Janitor = require(Packages.Janitor)
local Promise = require(Packages.Promise)
local Proto = require(Packages.proto)
local ProfileService = require(Packages.ProfileService)
local Sourceesque = require(Packages.Sourceesque)
local Warp = require(Packages.Warp)
Expand Down Expand Up @@ -115,6 +78,11 @@ function Clean(WorkingJanitor)
return "Cleaned."
end

function AtomMain.Clean(WorkingJanitor)
WorkingJanitor:Cleanup()
return "Cleaned."
end

--[[
Start the framework.
Expand All @@ -130,13 +98,11 @@ Atom.Start()
]]
function AtomMain.Start()
if started then return Promise.reject("Atom has already started.") end
if _VERSION ~= "Luau" then ErrorSignal:Fire("Running on an External Lua Runtime.") return end
if _VERSION ~= "Luau" then ErrorSignal:Fire("Atom can't run on non Luau Runtimes.") return end

local StartTick = tick()
local StartSubTick = SubTick()

started = true

return Promise.new(function(resolve)
-- Create a Janitor to clean unneeded files post setup.
local InitJanitor = Janitor.new()
Expand All @@ -161,10 +127,8 @@ function AtomMain.Start()
if CurrentFolderItterations < MaxFolderItterations then
CurrentFolderItterations = CurrentFolderItterations + 1
print("Currently on the " .. CurrentFolderItterations .. " itteration.")
if v:IsA("Folder") then -- If it's a Folder, continue.
if v:IsA("Folder") then
if v:GetAttribute("Cleanable") ~= false then
-- Reads through the directory to find any files to be moved before
-- preparing it to be cleaned.
for _, scriptObject in pairs(v:GetChildren()) do
InitJanitor:Add(v)
end
Expand Down Expand Up @@ -196,24 +160,7 @@ function AtomMain.Start()
print(Clean(InitJanitor))
resolve(Promise.all(servicesInitPromises))
end):andThen(function()
--[[local servicesStartPromises = {}
for _, service in ipairs(Services:GetDescendants()) do
if service:IsA("ModuleScript") and service.Name:match("Service$") then
table.insert(
servicesStartPromises,
Promise.new(function(r)
debug.setmemorycategory(service.Name)
local servicetouse = require(Services:WaitForChild(service.Name))
local serviceClass = servicetouse.new()
serviceClass:Start()
r()
end)
)
end
end ]]

startComplete = true
started = true
local EndTick = tick()
local EndSubTick = SubTick()
onCompletedSignal:Fire("Atom has started succesfully.")
Expand Down
1 change: 1 addition & 0 deletions src/Atom/AtomModuleContents/Core/Serializer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +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)
Serializer.serialize(Buffer, offset, DataType, v) -- recursively serialize each element in the table
end
end),
Expand Down
7 changes: 4 additions & 3 deletions src/Atom/AtomModuleContents/Utils/ModuleLoader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ ModuleLoader.__index = ModuleLoader

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())
return require(v)
local mod : ModuleScript = require(v)
return mod
end
end

return nil
end

Expand Down
7 changes: 5 additions & 2 deletions src/Atom/Components/RemoteEvent.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +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)
serialize(Buffer, offset, DataType, v) -- recursively serialize each element in the table
end
else
Expand All @@ -26,13 +27,15 @@ local function serialize(Buffer : buffer, offset : number, DataType:string , Dat
end

function ServerRemoteEvent.new(RemoteName:string, Parent:Instance)
local ServerRemoteEventInstance = Instance.new("RemoteEvent", Parent)
local ServerRemoteEventInstance = Instance.new("RemoteEvent")
ServerRemoteEventInstance.Parent = Parent
ServerRemoteEventInstance.Name = RemoteName
return ServerRemoteEventInstance
end

function ClientRemoteEvent.new(RemoteName:string, Parent:Instance)
local ClientRemoteEventInstance = Instance.new("RemoteEvent", Parent)
local ClientRemoteEventInstance = Instance.new("RemoteEvent")
ClientRemoteEventInstance.Parent = Parent
ClientRemoteEventInstance.Name = RemoteName
return ClientRemoteEventInstance
end
Expand Down
Loading

0 comments on commit 97dbf11

Please sign in to comment.