Introduction To The Rex Framework
| GitHub | Model |
The rex framework is a framework inspired by knit (I basically got bored and was really inspired to go out of my way to make this). The framework was named after @EDmaster24 (a friend) and because of how short it is it’s easy to type and remember.
The purpose of the Rex Framework is to provide pre-made resources and to cutdown on manual remote setup. When creating this framework, the main goal in mind was to create this for anime-like games, however, it can be used in any environment. The Rex Framework allows for individuals to create “Modules” for it to be shared and retrievable by any other script. If a module is created on the server, the client will be able to call functions on the client table of the module. If a module is created on the client, all the other client scripts will have access to retrieve the module. For a better understanding and an example, please take a look at Example Use Case.
TIP:
When working with the Rex Framework, in order for other scripts to know when modules are able to be retrieved, you must run Rex:Start()
on both a main Client and Server script. Before Rex:Start(), you want to create any custom modules, rewrite any pre-build modules and also create any Databases.
Information
I’ve separated this into multiple categories to be a bit neater. Please do look over the following categories below before asking any questions. I am more than happy to answer them!
Example Use Case
Introduction
I’ll show an example of the Rex Framework in use with one of my own games in production, The Rex Framework is constantly being changed as needed for ease of use as well as clarity and functionality.
Here’s a game I’m working on that you can check out how I’ve set up the Rex Framework:
Square Piecce 2.rbxl (204.6 KB)
The format in the place file is what I find best to work with. It allows me to add new modules and databases with extreme flexibility on both Server and Client sides.
Prebuilt Modules
Introduction
These are prebuilt modules made by mostly by me that I found extremely useful. I did not list every single module and function because that’s too much work. Below is an example on how to retrieved a module:
local Module = Rex:GetModule("ModuleName")
When reading the methods, <>
means required, []
means optional.
RayService
RayService
Example:
local Rex = require(game.ReplicatedStorage.Rex)
local RayService = Rex:GetModule("RayService")
local Result = RayService:Cast(Vector3.new(0,0,0), CFrame.new(0,100,0), {}, FilterType, IgnoreWater, CollisionGroup)
RayService:Visualize(CFrame.new(0,0,0), Vector3.new(0,100,0), Color3RGB)
Methods:
local Rex = require(game.ReplicatedStorage.Rex)
local RayService = Rex:GetModule("RayService")
local Result = RayService:Cast(
<Vector3 or CFrame> StartPoint,
<Vector3 or CFrame> EndPoint,
[Array] IgnoreList Or WhiteList,
[RayFilterType Enumueration] FilterType,
[Boolean] IgnoreWater,
[String] CollisionGroup
)
RayService:Visualize(
<Vector3 or CFrame> StartPoint,
<Vector3 or CFrame> EndPoint,
[Color3RGB] RayColor,
)
LerpService
LerpService
Lerp Service is basically an exact replica of TweenService however, it does NOT create a new thread per every new tween. The format maintains the same and everything is automatically garbage collected.
Example:
local Rex = require(game.ReplicatedStorage.Rex)
local LerpService = Rex:GetModule("LerpService")
wait(7)
local Animation = LerpService:Create(game.Workspace.Part, TweenInfo.new(5,Enum.EasingStyle.Linear), {Color = Color3.fromRGB(255,0,0)})
Animation:Play()
wait(5)
Animation:Stop()
wait(5)
Animation:Resume()
wait(10)
Methods
local Rex = require(game.ReplicatedStorage.Rex)
local LerpService = Rex:GetModule("LerpService")
local Tween = LerpService:Create(Object Or List Of Objects, TweenInfo or Dictonary or List, goal) -- Creates The Tween
Tween:Play() --> Plays The Tween
Tween:Stop() --> Stops The Tween
Tween:Resume() --> Continues the tween
HitboxService
HitboxService
The purpose of HitboxService was to introduce an easy way to create Hitboxes for magical skills and bullets. HitboxService can be primarily used for Area Of Effect
or Projectile
hitboxes.
Hitbox:CastProjectileHitbox({
Points = {CFrame1, CFrame2},
Direction = Vector3.new(),
Velocity = 10,
Lifetime = 1,
Iterations = 1,
Visualize = true,
Function = function(RaycastResult)
end,
Ignore = {}
})
Here’s a visual example:
Methods:
local Rex = require(game.ReplicatedStorage.Rex)
local HitboxService = Rex:GetService("HitboxService")
HitboxService:CastProjectileHitbox({ -- Everything is required
Points = {}, -- Array Of CFrames
Direction = Vector3.new(), -- Direction
Velocity = 10, -- Velocity Of Projectile
Lifetime = 1, -- Total Duration
Iterations = 1, -- Amount of times it's splitted,
Visualize = true, -- Visualizes the hitbox using RayService
Function = function(RaycastResult) -- Callback
end,
Ignore = {} -- Array Of Objects To be Ignored
})
local ValidTargets = HitboxService:GetEntitiesFromPoint(
<Vector3 or CFrame> Point Of Explosion,
<List> All Valid Entities,
<Dictionary> Ignore List Using Object as Index,
<Number> Radius Of Explosion,
[Boolean] Raycasts to find obstacles,
) -- Returns an array of valid entities within range
local RadialPoints = HitboxService:GetRadialPoints(
<CFrame> Orgin,
<Number> Amount Of Points,
<Number> Radius
) -- Returns an array of cframes that form a circle
local SquarePoints = HitboxService:GetSquarePoints(
<CFrame> Orgin,
<Number> Width,
<Number> Height,
) -- Returns an array of cframes that form a square grid
VFXService
VFXService
VFX Service contains a bunch of pre-built special effects.
Example usage:
local VFXService = Rex:GetModule("VFXService")
VFXService.Shake("Explosion") -- If you want only the player
TIP:
VFX Service should only be used on the Client.
Methods
local Rex = require(game.ReplicatedStorage.Rex)
local VFXService = Rex:GetModule("VFXService")
VFXService.Blur(
<Number> TotalDuration,
<Number> Blur Size,
)
VFXService.Shake(
<String> Shake Preset, -- Uses Crazyman's camera shake
)
VFXService.FOV(
<Number> TotalDuration,
<Number> FOV,
)
TaskScheduler
TaskScheduler
TaskScheduler allows you run callbacks without yielding with accurate delays. This is a replacement for the Roblox delay
function, if you need delays often it’s recommended to use this.
Methods
local Rex = require(game.ReplicatedStorage.Rex)
local TaskScheduler = Rex:GetModule("TaskScheduler")
TaskScheduler:AddItem(Time, Callback);
TaskScheduler:AddTask(Time, Callback);
DebrisService
DebrisService
DebrisService was created to allow users to delete items or disconnect connections in replacement of using spawn
, delay
and even Roblox’s Debris
service.
Methods
local Rex = require(game.ReplicatedStorage.Rex)
local DebrisService = Rex:GetService("DebrisService")
DebrisService:AddItem(
<RBX Object or RBX Connection or Array> Things To Be Cleaned Up,
[Number] Time Until Destroyed,
[Function] Callback when cleaned,
)
Documentation
Documentation
Rex:Start()
Initiates the framework allowing other other scripts to safety retrieve custom modules. Prebuilt modules will can be required before hand.
Rex:GetModule([ModuleName])
Retrieves the module with a Module Name. If Module does not exist it will return nil
Rex:GetAllModules()
Retrieves all the modules in a dictionary format
Rex:CreateModule([ModuleName], [ServerFunctions], [ClientFunctions])
Creates a module with a table of Server Functions (to be called from other server scripts), Client Functions to be called from Local Scripts.
Rex:GetDatabase([Database Name])
Retrieves Database with the Database Name. Databases are basically shared tables across the server client boundary, the client can write to the table but can read from it.
Rex:CreateDatabase([Database], [Data])
Creates a database with the name of the Database and with the Data.
Rex:GetAllDatabases()
Retrieves all the available databases in a dictionary format
Rex:Write(DatabaseId, Directory, Value)
Writes to a database (replicating it to the client). Example:
local Rex = require(game.ReplicatedStorage.Rex)
local Database = Rex:CreateDatabase("Hi", {
Example = {
SubTable = {Val = 1};
}
})
Rex:Write("Hi", {"Example", "SubTable", "Val"}, 5) -- Will set the Val in SubTable to 5
Tips
TIP 1:
Do you hate long scripts? You can utilize modules to create services, databases organizing your code. Here’s an example:
Format:
Server Script:
--|| Server ||--
--|| Services ||--
local ReplicatedStorage = game.ReplicatedStorage;
local Rex = require(ReplicatedStorage.Rex);
local Modules = script.Modules:GetChildren()
for i = 1, #Modules do
local Module = Modules[i];
local Contents = require(Module);
Rex:CreateModule(Module.Name, Contents.Server, Contents.Client);
end
local Databases = script.Databases:GetChildren()
for i = 1, #Databases do
local Database = Databases[i];
Rex:CreateDatabase(Database.Name, require(Database));
end
Rex:Start();
In InputService:
local ServerStorage = game.ServerStorage;
local Players = game.Players
local ReplicatedStorage = game.ReplicatedStorage;
local Globals = require(ReplicatedStorage.Modules.Globals);
local RecognizedKeybinds = {
Q = "Dash";
}
local AbilitiesCache = {};
local Abilities = ServerStorage.Abilities:GetDescendants()
for i = 1, #Abilities do
local Desc = Abilities[i];
if Desc:IsA("ModuleScript") then
local Suc, Err = pcall(function()
AbilitiesCache[Desc] = require(Desc)
end)
if not Suc then
warn("An error has occured attempting to require "..Desc.Name, Err);
end
end
end
local module = {
Server = {};
Client = {
HotbarEquip = function(Player, Input)
if not Globals.IsAlive(Player.Character) then return false end;
local States = Player.States;
States["Equipped Hotbar Slot"].Value = Input;
--| Prompt Equip
return true
end,
HotbarUnequip = function(Player)
if not Globals.IsAlive(Player.Character) then return false end;
local States = Player.States;
--| Unequip
States["Equipped Hotbar Slot"].Value = "None";
return true
end,
ReadInput = function(Player, Input, MouseHit)
if not Globals.IsAlive(Player.Character) then return false end;
local States = Player.States;
local Stats = Player.Stats;
local Hotbar = Player.Hotbar;
local EquippedHotbarSlot = States["Equipped Hotbar Slot"].Value
if EquippedHotbarSlot ~= "None" then
local HotbarEquippedId = Hotbar[EquippedHotbarSlot].Id.Value
local Type, Data = Globals.GetCategoryFromId(HotbarEquippedId);
if Data[Input] then
return AbilitiesCache[ServerStorage.Abilities[Type][HotbarEquippedId][Data[Input].Id]](Player, Data[Input], MouseHit)
end
elseif RecognizedKeybinds[Input] then
return AbilitiesCache[ServerStorage.Abilities.General[RecognizedKeybinds[Input]]](Player, MouseHit)
end
end;
};
}
return module
In a database:
local module = {}
return module
TIP 2:
Do you have third party modules in your game? Do you hate requiring them to end up like this:
local Datastore = require(game.ServerScriptService.Datastore.Datastore)
local Rex = require(game.ReplicatedStorage.Rex)
Well, you can do this!
--|| Services ||--
local Datastore = require(game.ServerScriptService.Datastore.Datastore)
local Rex = require(game.ReplicatedStorage.Rex)
local Server = Datastore; -- Now the service "Datastore" has access to the Datastore module.
local Client = {};
local Service = Rex:CreateService(script.Name, Server, Client);
return Server
You can also share functions into the Client table (not one’s that handle saving, loading for security reasons but retrieving data.)
Last Updated: 2021-01-28T05:00:00Z