Skip to content

Commit 37f391e

Browse files
committed
Don't store runScript() in script environments
1 parent 337598e commit 37f391e

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

library/lua/dfhack.lua

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -383,10 +383,12 @@ local internal = dfhack.internal
383383
internal.scripts = internal.scripts or {}
384384
internal.scriptPath = internal.scriptPath or {}
385385
internal.scriptMtime = internal.scriptMtime or {}
386+
internal.scriptRun = internal.scriptRun or {}
386387

387388
local scripts = internal.scripts
388389
local scriptPath = internal.scriptPath
389390
local scriptMtime = internal.scriptMtime
391+
local scriptRun = internal.scriptRun
390392

391393
local hack_path = dfhack.getHackPath()
392394

@@ -443,8 +445,8 @@ function dfhack.run_script_with_env(envVars,name,...)
443445
local f
444446
local perr
445447
local time = dfhack.filesystem.mtime(file)
446-
if time == scriptMtime[file] then
447-
f = scripts[file].__runScript__
448+
if time == scriptMtime[file] and scriptRun[file] then
449+
f = scriptRun[file]
448450
else
449451
--reload
450452
f, perr = loadfile(file, 't', env)
@@ -455,7 +457,7 @@ function dfhack.run_script_with_env(envVars,name,...)
455457
scriptMtime[file] = time
456458
end
457459
scripts[file] = env
458-
env.__runScript__ = f
460+
scriptRun[file] = f
459461
return f(...), env
460462
end
461463

0 commit comments

Comments
 (0)