-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Runs when the PlayerModule is required thus allowing developers to inject custom code modules into the PlayerModule scripts before anything is initialized. This helps a fair bit when you want to make lasting changes that can build on top of each other.
- Loading branch information
Showing
6 changed files
with
99 additions
and
7 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...PlayerScripts/PlayerModule/Lua/Header.lua → ...s/PlayerModule/Lua/CameraModuleHeader.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--!strict | ||
|
||
local PlayerModule = script.Parent | ||
|
||
local module = {} | ||
|
||
function module.add(modifier: ModuleScript, priority: number?) | ||
local copy = modifier:Clone() | ||
copy:SetAttribute("Priority", priority) | ||
copy.Parent = script | ||
end | ||
|
||
function module.apply() | ||
local children = script:GetChildren() :: {ModuleScript} | ||
|
||
table.sort(children, function(a, b) | ||
local pa = a:GetAttribute("Priority") :: number? | ||
local pb = b:GetAttribute("Priority") :: number? | ||
|
||
if pa and pb then | ||
return pa < pb | ||
elseif pb then | ||
return false | ||
end | ||
|
||
return true | ||
end) | ||
|
||
for _, child in children do | ||
local callback = require(child) :: (ModuleScript) -> () | ||
callback(PlayerModule) | ||
end | ||
end | ||
|
||
return module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
local modifiersModule = script:FindFirstChild("Modifiers") | ||
local modifiers = modifiersModule and require(modifiersModule) | ||
|
||
if modifiers then | ||
modifiers.apply() | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters