Don't store runScript() in script environments

develop
lethosor 2015-02-10 17:22:16 -05:00
parent 337598e0d6
commit 37f391ea6d
1 changed files with 5 additions and 3 deletions

@ -383,10 +383,12 @@ local internal = dfhack.internal
internal.scripts = internal.scripts or {}
internal.scriptPath = internal.scriptPath or {}
internal.scriptMtime = internal.scriptMtime or {}
internal.scriptRun = internal.scriptRun or {}
local scripts = internal.scripts
local scriptPath = internal.scriptPath
local scriptMtime = internal.scriptMtime
local scriptRun = internal.scriptRun
local hack_path = dfhack.getHackPath()
@ -443,8 +445,8 @@ function dfhack.run_script_with_env(envVars,name,...)
local f
local perr
local time = dfhack.filesystem.mtime(file)
if time == scriptMtime[file] then
f = scripts[file].__runScript__
if time == scriptMtime[file] and scriptRun[file] then
f = scriptRun[file]
else
--reload
f, perr = loadfile(file, 't', env)
@ -455,7 +457,7 @@ function dfhack.run_script_with_env(envVars,name,...)
scriptMtime[file] = time
end
scripts[file] = env
env.__runScript__ = f
scriptRun[file] = f
return f(...), env
end