File tree Expand file tree Collapse file tree 1 file changed +21
-4
lines changed
Expand file tree Collapse file tree 1 file changed +21
-4
lines changed Original file line number Diff line number Diff line change 1- local function clearfile (path , needRequire )
1+ local function clearfile (path , needRequire , resetGValueOrName )
22 path = string.gsub (path , " [\\ /]" , " ." )
33 path = string.gsub (path , " %.lua$" , " " )
4- print (path )
4+ -- print(path)
55 package.loaded [path ] = nil
6- if needRequire then
7- require (path )
6+ if not needRequire then return end
7+
8+ local gValName = resetGValueOrName
9+ if resetGValueOrName == true then
10+ gValName = string.gsub ( path , " .*%." , " " )
11+ end
12+ local gValue = gValName and _G [gValName ]
13+
14+ require (path )
15+
16+ if gValue and type (gValue ) == " table" then
17+ local newGVal = _G [gValName ]
18+ if type (newGVal ) == " table" then
19+ for k , v in pairs (newGVal ) do
20+ if type (v ) ~= " function" then
21+ newGVal [k ] = v
22+ end
23+ end
24+ end
825 end
926end
1027
You can’t perform that action at this time.
0 commit comments