Global Framework
Download Plugin | Download Library | Video Tutorial | Discord Server
Features
Global Types "Access types from all other scripts"
Global Variables "Access variables from all other scripts"
Strict Mode "--!strict"
Circler Dependencies "Circler types + circler variables"
Inheritance "Inherit via 2 modes [Clone, Metatable]"
Automatic inherit dependency sorting "No mater what order your scripts run in"
Automatic generic dependency sorting "Global generic types will be listed in the correct order"
Diagnostics "Warnings if you define the same type or variable"
Comments Within Comments "O_O"
Metatable Shortcut "Metatable types are very easy to type"
Style Flexibility "Does not enforce a specific style of writing code"
Modular "Only use parts of the global library you want"
Customizable "Very easy to add/modify/remove framework functions"
Support My Work
If you liked my work and want to donate to me you can do so here
SourceCode
You can get the sourcecode to this plugin/module herePermission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted.
Quick Start
Step 1
"Make a ModuleScript and give it a attribute called GlobalTypes and set it to true"
Step 2
"Make a Script and require the ModuleScript we just made"
Step 3
"Make a type and block comment it out using --[[type]]"
Step 4
"Add a value into Global and set its type"
Done
"Congratulations you now have a global value that you can access in other scripts"
CLASS WITH METATABLE EXAMPLE
--!strict
--[[type MyGlobalClassType = {
__index: MyGlobalClassType,
new: (name: string, age: number) -> MyGlobalObjectType,
SetName: (self: MyGlobalObjectType, name: string) -> (),
SetAge: (self: MyGlobalObjectType, age: number) -> (),
}]]
--[[type MyGlobalObjectType = {
Name: string,
Age: number,
} MyGlobalClassType]]
local Global = require(game.PathTo.ModuleScript)
local class = Global("MyGlobalIndex") :: Global.MyGlobalClassType
class.__index = class
function class.new(name, age)
local self = setmetatable({}, class)
self.Name = name
self.Age = age
return self
end
function class:SetName(name)
self.Name = name
end
function class:SetAge(age)
self.Age = age
end
CLASS WITHOUT METATABLE EXAMPLE
--!strict
--[[type MyGlobalObjectType = {
Name: string,
Age: number,
new: (name: string, age: number) -> MyGlobalObjectType ,
SetName: (self: MyGlobalObjectType, name: string) -> (),
SetAge: (self: MyGlobalObjectType, age: number) -> (),
}]]
local Global = require(game.PathTo.ModuleScript)
local class = Global("MyGlobalIndex", Global.Metatable()) :: Global.MyGlobalObjectType
function class.new(name, age)
local self = Global.Metatable(class) :: Global.MyGlobalObjectType
self.Name = name
self.Age = age
return self
end
function class:SetName(name)
self.Name = name
end
function class:SetAge(age)
self.Age = age
end
CLASS WITHOUT NEW EXAMPLE
--!strict
--[[type MyGlobalObjectType = {
Name: string,
Age: number,
SetName: (self: MyGlobalObjectType, name: string) -> (),
SetAge: (self: MyGlobalObjectType, age: number) -> (),
}]]
local Global = require(game.PathTo.ModuleScript)
local class = Global.Metatable() :: Global.MyGlobalObjectType
Global("MyGlobalIndex", function(name, age)
local self = Global.Metatable(class) :: Global.MyGlobalObjectType
self.Name = name
self.Age = age
return self
end :: (name: string, age: number) -> Global.MyGlobalObjectType)
function class:SetName(name)
self.Name = name
end
function class:SetAge(age)
self.Age = age
end