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