diff --git a/LUA_API.rst b/LUA_API.rst index f40b786d2..2859f8678 100644 --- a/LUA_API.rst +++ b/LUA_API.rst @@ -491,6 +491,13 @@ Currently it defines the following features: Compares to coroutine.resume like dfhack.safecall vs pcall. +* ``dfhack.run_script(name[,args...])`` + + Run a lua script in hack/scripts/, as if it was started from dfhack command-line. + The ``name`` argument should be the name stem, as would be used on the command line. + Note that the script is re-read from the file every time it is called, and errors + are propagated to the caller. + * ``dfhack.with_suspend(f[,args...])`` Calls ``f`` with arguments after grabbing the DF core suspend lock. @@ -1148,6 +1155,11 @@ Internal API These functions are intended for the use by dfhack developers, and are only documented here for completeness: +* ``dfhack.internal.scripts`` + + The table used by ``dfhack.run_script()`` to give every script its own + global environment, persistent between calls to the script. + * ``dfhack.internal.getAddress(name)`` Returns the global address ``name``, or *nil*. diff --git a/Lua API.html b/Lua API.html index 5574c55b8..047457985 100644 --- a/Lua API.html +++ b/Lua API.html @@ -766,6 +766,12 @@ returning. Intended as a convenience function.
dfhack.saferesume(coroutine[,args...])
Compares to coroutine.resume like dfhack.safecall vs pcall.
dfhack.run_script(name[,args...])
+Run a lua script in hack/scripts/, as if it was started from dfhack command-line. +The name argument should be the name stem, as would be used on the command line. +Note that the script is re-read from the file every time it is called, and errors +are propagated to the caller.
+dfhack.with_suspend(f[,args...])
Calls f with arguments after grabbing the DF core suspend lock. Suspending is necessary for accessing a consistent state of DF memory.
@@ -1310,6 +1316,10 @@ Returns true, was_only_planned if removed; or false if none foThese functions are intended for the use by dfhack developers, and are only documented here for completeness:
dfhack.internal.scripts
+The table used by dfhack.run_script() to give every script its own +global environment, persistent between calls to the script.
+dfhack.internal.getAddress(name)
Returns the global address name, or nil.