Install the FDK module in ReplicatedStorage. The easiest way to do this is to the use FDK installer plugin, which can be found at:
Roblox Plugin: https://www.roblox.com/library/3410089003/FDK-Installer
Source: https://github.com/TheFlamingBlaster/FDK/blob/master/src/Plugin.lua
After this is complete, click the "Install Master" button on the FDK toolbar. The FDK module and base class should be located in ReplicatedStorage.
local fdkModule = game:GetService("ReplicatedStorage"):FindFirstChild("FDK")
local fdk = require(fdkModule)
fdk:wrapEnvironment(getfenv()) -- Add the BaseClass Class and the Import function into the current enviroment.
Packages are simply ModuleScripts which return a function. The function is automatically wrapped in the FDK enviroment to allow for the BaseClass Class and the Import function to be used.
A basic "Hello, world!" class:
-- In a package located in either ServerScriptService.ServerPackages or ReplicatedStorage.ClientPackages
-- FDK will automatically provide packages based on the enviroment where the module is running.
return function()
local helloWorld = BaseClass:new("HelloWorld")
helloWorld.Hello = function()
print("Hello, world!")
end
return helloWorld
end
In the script requiring FDK:
local fdkModule = game:GetService("ReplicatedStorage"):FindFirstChild("FDK")
local fdk = require(fdkModule)
fdk.wrapEnvironment(getfenv()) -- Add the BaseClass Class and the Import function into the current enviroment.
local helloWorld = import("HelloWorld")
helloWorld.Hello() -- > Should print "Hello, world"
Classes can have their variables carried over onto new classes by using the Extend() function of BaseClass.
local originalClass = BaseClass:new("OriginalClass")
originalClass.Demo = true
local newClass = originalClass:extend("ExtendedClass")
print(newClass.Demo == true) --> Should return true.
Like many other programming languages, classes can be initalised:
return function()
initClass = BaseClass:new("Init")
intClass.Init = function(newClass) -- The init function for a class is the same as the name of the class.
--newClass is the same is initClass:Extend({}). All of the variables added to the proto class are carried over into the new class
newClass.Initalised = true
return newClass
end
return initClass
end
Packages can be located in folders and subfolders. You can index them using "."
In this example, you could import camera by importing game.user.camera
import("game.usr.camera")