Introducing Nexus game framework!

Nexus!
My very first game framework.
This is a pretty straight-forward framework, I’ll be working on bug fixes, optimization, new implementation regularly as I’ve been using this framework for quite awhile now.

Link : https://create.roblox.com/marketplace/asset/13417781262

Now follow through as this is quite a long explanation on what is the module and what it does

What is Nexus?
Nexus is a communication-based framework, meaning its there to ease server-client communication.

In this post, I’ll be giving primary usage examples

Link to GitHub: GitHub - Padnot/Nexus

Use cases:
Proxies, Proxies are essentially a simplified version of a one-way communication from client to server or act as a shared module (server-server,client-client)

Client-Server communication :

--server.lua
local nexus = require(nexus) --Path to nexus, you get it
local server, client = nexus.LoadProxy("MyProxy") --remember this string, as it is the name of the proxy which the client needs to get
function client:PrintHi(plr, str)
  --Note, when doing client-server communication with proxies, the function must be a method and not an index function! (e.g module:Function instead of module.Function)
  --When hooking a method to client tab, player will always be passed as the first argument, aka the player who triggered the function
  print(`Client {plr} said {str}!`)
end

--client.lua
local nexus = require(nexus)
local client = nexus.GetProxy("MyProxy")
client:PrintHi("Hello server")

When you run this code, it will print Client yourname said Hello server! in the server, see how this simplifies simple communication systems with just a few lines? Thats exactly what proxies are mainly used for.

Using remoteevents/functions:
In this framework, server are referred to as “Host” and clients are referred to as “Nodes”

Now, I added a lot of security measures (Which is easy to bypass from exploiters if they know the internals), This is to be a simple (even though ineffective) measure to atleast get afew skids who try to fire remotes incorrectly.

Hosts and Nodes

Theres a lot of function between these two, I’ll cover the non-remote-based ones and I’ll be covering the functions of the remotes right after

The main security measure here is LinkFalseFire, you pass a function as an argument of which the function will be passed 3 params : player of which the node represents, the node’s name and the host name that the falsefire tried to fire to a specific host.

What is FalseFire? FalseFire is a security measure of which when an unmatched link fired it, But wait! That did not make any sense does it? We’ll get to it in a bit.

Lets start by linking, but first, we need to know how to create both host and nodes

nexus.LoadHost(“Name”) Creates a host
nexus.LoadNode(“Name”) Creates a node
nexus.GetHost(“Name”) gets a host by the name
nexus.GetNode(“Name”) gets a node by the name
(Keep in mind that host is for servers and nodes are for clients)

now, theres actually a second parameter to both LoadHost and LoadNode!
The parameter is linkName, it is the link between a host and a node so that when an outsider node tries to fire to that host, it triggers falsefire, Heres what i mean

--server.lua
local host = nexus.LoadHost("MyHost","MyNode") --links MyHost to MyNode
host:LinkFalseFire(function(plr,nodeName,hostName)
  plr:Kick("Node MyNode is supposed to fire not "..nodeName)
end)
host:KitEvent("Hi",function(plr)
  print("yay player said hi!!!")
end) --I'll cover kitevent shortly

--client.lua
local node = nexus.LoadNode("MyNode","MyHost")
node:FireEvent("Hi")

Now, when you run this function properly, it should print player said hi because the link is proper and theres no mismatch, however, if you were to change the first argument in LoadNode aka the nodeName, you will be kicked because its the wrong node firing to the host, instead of “MyNode”

Links are mainly optional, when you put no parameters at the link, It’ll automatically be able to receive input from all nodes/hosts without having to filter at all

Now, there is other minor arg-type checker and such but uhm I’ll make a documentation on that later on, just do know this is what linking and falsefire is.

Using RemoteEvents/RemoteFunctions:

Now, Lets go over how to kit a basic communication.
Register (Event and function)
Connect (Event and function)
Disconnect (Event and function)
Fire / Invoke
And Kit (Event and function)

I’ll thoroughly explain trough each of them specifically
Note : All example assumes that you have required the framework and named it nexus! And also to have your proper remote events/remote functions registered!

RegisterEvent/RegisterFunction:
Creates a RemoteEvent/RemoteFunction with given name and a certain connectors to the name
Note : This can only be called on the server/host, as clients can not make their own remotes
(Server-only)
Ex :

host:RegisterEvent("Hi")
host:RegisterFunction("Hi")

ConnectEvent/ConnectFunction:
Connects / hooks a function to a remote
Ex :

host:ConnectEvent("Hi",function(plr)
  --do
end)
node:ConnectFunction("Hi",function(...)
  --do
end)

DisconnectEvent/DisconnectFunction:
Disconnect a connected function from a remote, has an optional parameter of which it destroy and unregisters that specific remote
Ex :

host:DisconnectEvent("Hi")
host:DisconnectFunction("Hi",true)
node:DisconnectEvent("Hi")

FireEvent / InvokeFunction:
Fire / Invokes a remote with passed arguments
Ex :

host:FireEvent("Hi",playerObject,"Yi") --in server, playerObject (2nd arg) must be a player!
--An optional method for the server, (:FireAllClients)
host:FireEventAll("Hi",false)
node:InvokeFunction("Hi",true)

And finally,
KitEvent/KitFunction :
These are just register and connect mushed into one singular function
(Server-only)
Ex :

host:KitEvent("Hi",function(plr)
  --do
end)

Phew, thats it! Thats all the basis covered from this, now i know i should have probably made a documentation somewhere, I’ll do that sometime later on github maybe, But here it is.
(Everything inside this module was written by myself, it comes with a few extra modules such as that promise, signal, maid, and many more! Which you can find under Nexus → Utilities or Tools)
Feel free to ask if you have any question regarding the module!

3 Likes

From the looks of it this is just a glorified remote wrapper, which I understand most frameworks are but they usually serve other purposes. Can your remote wrapper support sanitation checking or middleman functions like Knit?

Also this project shares the name of Nexus Unit Testing, it may be of interest to rename it to remove confusion or even support Nexus tests with your created functions and events, it would make this stand out from other frameworks.

3 Likes

the name makes people think it’s from TheNexusAvenger as he usually puts “Nexus” in his project names

5 Likes

Exactly what I was thinking when I got the notification!

2 Likes

Hey! Thank you for the notice, I’ll most likely change the framework name to something else

For now, the framework only consist of client<>server communication, Currently the module have two function to typecheck the arguments (both type and typeof)

It’ll help greatly if you could mention more sanity-checking methods

Im currently thinking about it, since the internals of the framework has post-processing to process the links, maybe I’ll add it sometime in the future