This commit is contained in:
2024-04-20 16:46:10 -04:00
parent b82606d64c
commit 36625162a1
3 changed files with 36 additions and 36 deletions

View File

@@ -3,8 +3,11 @@
--!strict
type CharacterSharedFolder = Folder
type Character = Model
type TCP = RemoteEvent
type include<T> = (this: LuaSourceContainer, FunName: string, ...T) -> T
local CharacterModule = {}
CharacterModule.__index = CharacterModule
@@ -13,25 +16,29 @@ local Storage = game:GetService("ReplicatedStorage")
local ClientStorage = Storage:WaitForChild("Client") :: Folder
local preprocessor = {}
local CharacterShared: Folder
local function client_preprocessor<T>(Character: Character): (include<T>, CharacterSharedFolder)
local preprocessor = {}
local CharacterShared = Character:WaitForChild("shared") :: CharacterSharedFolder
function preprocessor.CharacterShared(): CharacterSharedFolder
return CharacterShared
end
_G.include = function(this: LuaSourceContainer, FunName: string, ...)
if this:IsDescendantOf(script) then --getfenv is being removed
local switch = preprocessor[FunName]
return type(switch) == "function" and switch(...) or switch
else
warn(`Preprocessor append failed "{FunName}"`, debug.traceback())
return nil
function preprocessor.CharacterShared(): CharacterSharedFolder
return CharacterShared
end
_G.include = function<T>(this: LuaSourceContainer, FunName: string, ...: T)
if this:IsDescendantOf(script) then --getfenv is being removed
local switch = preprocessor[FunName]
return type(switch) == "function" and switch(...) or switch
else
warn(`Preprocessor append failed "{FunName}"`, debug.traceback())
return nil
end
end
return _G.include, CharacterShared
end
function CharacterModule.constructor(Character)
CharacterShared = Character:WaitForChild("shared")
local _, CharacterShared = client_preprocessor(Character)
local HumanoidRPSettings = require(script:WaitForChild("HumanoidRootPart"))
local CameraModule = require(script:WaitForChild("Camera"))
@@ -52,6 +59,11 @@ function CharacterModule.constructor(Character)
self.HumanoidSettings = HumanoidModule.constructor(Humanoid)
self.SpineMovement = SpineModule.constructor(self.CurrentCamera)
pcall(table.clear, _G)
pcall(table.freeze, _G)
pcall(table.clear, shared)
pcall(table.freeze, shared)
return setmetatable(self, CharacterModule)
end
@@ -120,6 +132,4 @@ function CharacterModule:EnableSpineMovement()
self.SpineMovement:Enable()
end
_G.include = nil
return CharacterModule