Controllers
Controllers are used to define a basic controller for the framework loader.
Every controller must have isFrameworkLoader
to be defined as a controller, otherwise it will return a warning.
Example
-- PlayerScripts/Controllers/MyController.luau
-- client
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Controller = require(ReplicatedStorage.Controller).new()
function Controller:Init()
self.myVariable = true
self.printService = self:GetService("PrintService")
self.playerService = self:GetService("Players")
end
function Controller:Start()
self.printService(self.myVariable) -- prints 'true'
self.printService(self.playerService.LocalPlayer.Name) -- prints player name
end
return Controller
This is a basic example of a controller. You can create as many controllers as you need.
Keep in mind that these functions are blocking (they yield). If the init
function yields, the start
function will not be called until the yield is complete.
API
ControllerModule.new()
-> Controller
Constructs a new controller structure
Properties
Read only
Controller.isFrameworkLoader
-> boolean
Determines whether the required module is a framework loader. This value should not be modified.
Controller.installizedIn
-> number
Returns the number of seconds it took for the controller to be installed.
Controller.startedIn
-> number
Returns the number of seconds it took for the controller to start.
Methods
Controller:Init()
-> Controller
Initialize the basic requirements for the controller
Controller:Start()
-> Controller
This function is called whenever the controller starts.
Controller:GetService(serviceName : string)
-> Controller
Returns the required service from the service folder.
If a service doesn’t exist in the service folder, it will search through Roblox’s built-in services.
Example:
Controller:GetService("Players")
-> Returns Players service by roblox.
If a service with the same name exists in the service folder (e.g. Services/Players.module.luau), it will be used instead of Roblox’s built-in service.