Skip to content

Commit c6e0c98

Browse files
committed
Functions OriginalDoFile, OriginalLoadFile, and OriginalRequire, which are what they sound like, removed from global scope with "do end" blocks in lua.
1 parent 5c457c1 commit c6e0c98

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Source/Managers/LuaMan.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,11 +249,11 @@ void LuaStateWrapper::Initialize() {
249249
// Override "math.random" in the lua state to use RTETools MT19937 implementation. Preserve return types of original to not break all the things.
250250
"math.random = function(lower, upper) if lower ~= nil and upper ~= nil then return LuaMan:SelectRand(lower, upper); elseif lower ~= nil then return LuaMan:SelectRand(1, lower); else return LuaMan:PosRand(); end end\n"
251251
// Override "dofile"/"loadfile" to be able to account for Data/ or Mods/ directory.
252-
"OriginalDoFile = dofile; dofile = function(filePath) filePath = PresetMan:GetFullModulePath(filePath); if filePath ~= '' then return OriginalDoFile(filePath); end end;\n"
253-
"OriginalLoadFile = loadfile; loadfile = function(filePath) filePath = PresetMan:GetFullModulePath(filePath); if filePath ~= '' then return OriginalLoadFile(filePath); end end;\n"
252+
"do local OriginalDoFile = dofile; dofile = function(filePath) filePath = PresetMan:GetFullModulePath(filePath); if filePath ~= '' then return OriginalDoFile(filePath); end end; end\n"
253+
"do local OriginalLoadFile = loadfile; loadfile = function(filePath) filePath = PresetMan:GetFullModulePath(filePath); if filePath ~= '' then return OriginalLoadFile(filePath); end end; end\n"
254254
// Override "require" to be able to track loaded packages so we can clear them when scripts are reloaded.
255255
"_RequiredPackages = {};\n"
256-
"OriginalRequire = require; require = function(filePath) _RequiredPackages[filePath] = true; return OriginalRequire(filePath); end;\n"
256+
"do local OriginalRequire = require; require = function(filePath) _RequiredPackages[filePath] = true; return OriginalRequire(filePath); end; end\n"
257257
"_ClearRequiredPackages = function() for k, v in pairs(_RequiredPackages) do package.loaded[k] = nil; end; _RequiredPackages = {}; end;\n"
258258
// Internal helper functions to add callbacks for async pathing requests
259259
"_AsyncPathCallbacks = {};\n"

0 commit comments

Comments
 (0)