Modding
You can "mod" Quebec by creating custom lifecycle events. It is recommended to create a lifecycles
folder in either a shared, client or server folder for easy access.
Creating A Custom Lifecycle
We provide a Quebec.lifecycle
function to easily create a lifecycle:
local Quebec = require(PATH_TO_QUEBEC)
local Lifecycle = Quebec.lifecycle({
defaultMethod = "onPlayerAdded"
})
type Lifecycle = Quebec.CustomLifecycle<typeof(Lifecycle)> -- not mandatory, but useful
function Lifecycle.run(self: Lifecycle)
-- this code will run after all singletons have loaded which attach to your lifecycle
for _, player in Players:GetPlayers() do
-- this invokes the lifecycle on all singletons which use it
self:invokeAll(player)
end
Players.PlayerAdded:Connect(function(player)
-- the same as "invokeAll", but it runs the methods in the same thread
self:invokeAllSameThread(player)
end)
end
return Lifecycle
Using Custom Lifecycles
It's basically the same as registering normal lifecycle events, but instead of the lifecycle name, you require it:
local Quebec = require(PATH_TO_QUEBEC)
local Service = Quebec.singleton({
lifecycles = {
-- this applies the default method of the lifecycle
-- note: the path can be whatever you want
require(script.Parent.Parent.lifecycles.PlayerAdded),
}
})
function Service.onPlayerAdded(self: typeof(Service), player: Player)
-- ...
end
Of course, you can also remap the lifecycle:
local Quebec = require(PATH_TO_QUEBEC)
local Service = Quebec.singleton({
lifecycles = {
-- this remaps the lifecycle to a custom "playerJoined" method
-- it's essentially just a rename
-- note: the path can be whatever you want
[require(script.Parent.Parent.lifecycles.PlayerAdded)] = "playerJoined",
}
})
function Service.playerJoined(self: typeof(Service), player: Player)
-- ...
end
Last updated