ReturnedTrue / NebulaFramework

Shelved framework

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NebulaFramework

An early in development feature-rich framework which makes communication between scripts seamless.

Inspired by AGF.

Installation

-- Roblox Studio --

The roblox file, located in the latest release or on the Roblox website, will contain three folders named with where their contents must be placed.

-- Rojo --

In the zip file of the latest release, src/ will contain three folders (Client, Server, Shared). Rename each to NebulaInternal and sync into Studio as follows:

Client - StarterPlayerScripts
Server - ServerScriptService
Shared - ReplicatedStorage

Usage

NebulaFramework currently in early-development, please use with caution

A folder named Nebula must be placed under certain services depending on the context. Nebula will run any ModuleScript under these folders.

On the server: ServerScriptService, ServerStorage or ReplicatedStorage.
On the client: StarterPlayerScripts, ReplicatedFirst or ReplicatedStorage.

-- Table injected properties --
If a table is returned by a module, attribute Nebula_NormalModule is false/nil (see below), then these properties are injected.

Both contexts:

AddModule - a static method to add any module into Nebula, pass the ModuleScript and which table to add it to (ie. self.Server)
Services - a table of all the Roblox services, ie. Services.Players
Replicated - contains all the modules from ReplicatedStorage/Nebula (these modules won't be injected nor ran in Nebula either)

Server:

Server - contains all the modules from ServerScriptService/Nebula
Storage - contains all the modules from ServerStorage/Nebula

Client:

Server - contains all the modules from ServerScriptService/Nebula but only of the methods which are prefixed with Client_ (the prefix is removed)
Client - contains all the modules from StarterPlayerScripts/Nebula
ClientStorage - contains all the modules from ReplicatedFirst/Nebula

Then, the table's optional Load method will be called. Once all Load methods are called on, the optional Start method will be called. This is the best place to use other modules. Afterwards, the table's optional Update method will be called on either Heartbeat (server) or RenderStepped (client).

However, if a function is returned then it will be called at the same time as when the Start methods are called with the injected properties passed as a table.

-- Attributes --

Modules with certain attributes can have different functionalities:

Nebula_Ignore (boolean) - the module will be ignored by Nebula if true, it won't be loaded even when LoadModule is called on it
Nebula_NormalModule (boolean) - the module won't be injected nor will any methods used by nebula be called
Nebula_TopLevel (boolean) - the module will be added at top level (ie. self.Module or Nebula.Module), as well as under it's holding table. It is not recommended to use this on modules loaded with LoadModule, it will only be added to the top level of modules after it.

Examples

ServerStorage/Nebula/EventDispatcher

local EventDispatcher = {};

function EventDispatcher:GetEvent()
	return self.Event;
end

function EventDispatcher:Load()
	self.Event = self.Services.Players.PlayerAdded;
end

return EventDispatcher;

ServerScriptService/Nebula/EventConnector

return function(Nebula)
	local event = Nebula.Storage.EventDispatcher:GetEvent();
	
	event:Connect(function(player)
		print(player, "has joined!");
	end)
end

OR

local EventConnector = {};

function EventConnector:Start()
	local event = self.Storage.EventDispatcher:GetEvent();
	
	event:Connect(function(player)
		print(player, "has joined!");
	end)
end

return EventConnector;

ServerScriptService/Nebula/MessageGiver

local MessageGiver = {};

function MessageGiver:Client_GetMessage(player, theirMessage)
	return self.InnerMessage:format(player.Name, theirMessage);
end

function MessageGiver:Load()
	self.InnerMessage = "Hello, %s! You told me: %s";
end

return MessageGiver;

StarterPlayerScripts/Nebula/MessageAnnouncer

local MessageAnnouncer = {};

function MessageAnnouncer:Start()
	print(self.Server.MessageGiver:GetMessage("hi"));
end

return MessageAnnouncer;

ServerScriptService/Nebula/PlayerEvents

local PlayerEvents = {};

function PlayerEvents:Load()
	self:CreateEvents({"Joined", "Left"});

	self.Services.Players.PlayerAdded:Connect(function(player)
		self.Events.Joined:FireEveryClient(player.Name);
	end)

	self.Services.Players.PlayerRemoving:Connect(function(player)
		self.Events.Left:FireEveryClient(player.Name);
	end)
end

return PlayerEvents

StarterPlayerScripts/Nebula/PlayerWatcher

local PlayerWatcher = {};

function PlayerWatcher:Start()
	local PlayerEvents = self.Server.PlayerEvents;

	PlayerEvents.Joined:Connect(function(playerName)
		print(playerName, "has joined");
	end)

	PlayerEvents.Left:Connect(function(playerName)
		print(playerName, "has left");
	end)
end

return PlayerWatcher;

About

Shelved framework

License:MIT License


Languages

Language:Lua 100.0%