|
|
|
@ -344,7 +344,10 @@ ul.auto-toc {
|
|
|
|
|
<li><a class="reference internal" href="#maps-module" id="id18">Maps module</a></li>
|
|
|
|
|
</ul>
|
|
|
|
|
</li>
|
|
|
|
|
<li><a class="reference internal" href="#core-interpreter-context" id="id19">Core interpreter context</a></li>
|
|
|
|
|
<li><a class="reference internal" href="#core-interpreter-context" id="id19">Core interpreter context</a><ul>
|
|
|
|
|
<li><a class="reference internal" href="#event-type" id="id20">Event type</a></li>
|
|
|
|
|
</ul>
|
|
|
|
|
</li>
|
|
|
|
|
</ul>
|
|
|
|
|
</li>
|
|
|
|
|
</ul>
|
|
|
|
@ -513,7 +516,7 @@ possible.</p>
|
|
|
|
|
</li>
|
|
|
|
|
<li><p class="first"><tt class="docutils literal">ref:insert(index,item)</tt></p>
|
|
|
|
|
<p>Inserts a new item at the specified index. To add at the end,
|
|
|
|
|
use <tt class="docutils literal">#ref</tt> as index.</p>
|
|
|
|
|
use <tt class="docutils literal">#ref</tt>, or just <tt class="docutils literal">'#'</tt> as index.</p>
|
|
|
|
|
</li>
|
|
|
|
|
<li><p class="first"><tt class="docutils literal">ref:erase(index)</tt></p>
|
|
|
|
|
<p>Removes the element at the given valid index.</p>
|
|
|
|
@ -705,6 +708,10 @@ works with DFHack output infrastructure.</p>
|
|
|
|
|
<li><p class="first"><tt class="docutils literal"><span class="pre">dfhack.lineedit([prompt[,history_filename]])</span></tt></p>
|
|
|
|
|
<p>If the thread owns the interactive console, shows a prompt
|
|
|
|
|
and returns the entered string. Otherwise returns <em>nil, error</em>.</p>
|
|
|
|
|
<p>Depending on the context, this function may actually yield the
|
|
|
|
|
running coroutine and let the C++ code release the core suspend
|
|
|
|
|
lock. Using an explicit <tt class="docutils literal">dfhack.with_suspend</tt> will prevent
|
|
|
|
|
this, forcing the function to block on input with lock held.</p>
|
|
|
|
|
</li>
|
|
|
|
|
<li><p class="first"><tt class="docutils literal"><span class="pre">dfhack.interpreter([prompt[,env[,history_filename]]])</span></tt></p>
|
|
|
|
|
<p>Starts an interactive lua interpreter, using the specified prompt
|
|
|
|
@ -722,6 +729,9 @@ in C++, and dfhack.safecall.</p>
|
|
|
|
|
<p>Just like pcall, but also prints the error using printerr before
|
|
|
|
|
returning. Intended as a convenience function.</p>
|
|
|
|
|
</li>
|
|
|
|
|
<li><p class="first"><tt class="docutils literal"><span class="pre">dfhack.saferesume(coroutine[,args...])</span></tt></p>
|
|
|
|
|
<p>Compares to coroutine.resume like dfhack.safecall vs pcall.</p>
|
|
|
|
|
</li>
|
|
|
|
|
<li><p class="first"><tt class="docutils literal"><span class="pre">dfhack.with_suspend(f[,args...])</span></tt></p>
|
|
|
|
|
<p>Calls <tt class="docutils literal">f</tt> with arguments after grabbing the DF core suspend lock.
|
|
|
|
|
Suspending is necessary for accessing a consistent state of DF memory.</p>
|
|
|
|
@ -1021,9 +1031,36 @@ only context that can receive events from DF and plugins.</p>
|
|
|
|
|
<li><p class="first"><tt class="docutils literal">dfhack.is_core_context</tt></p>
|
|
|
|
|
<p>Boolean value; <em>true</em> in the core context.</p>
|
|
|
|
|
</li>
|
|
|
|
|
<li><p class="first"><tt class="docutils literal">dfhack.onStateChange.foo = function(code)</tt></p>
|
|
|
|
|
<p>Event. Receives the same codes as plugin_onstatechange in C++.</p>
|
|
|
|
|
</li>
|
|
|
|
|
</ul>
|
|
|
|
|
<div class="section" id="event-type">
|
|
|
|
|
<h3><a class="toc-backref" href="#id20">Event type</a></h3>
|
|
|
|
|
<p>An event is just a lua table with a predefined metatable that
|
|
|
|
|
contains a __call metamethod. When it is invoked, it loops
|
|
|
|
|
through the table with next and calls all contained values.
|
|
|
|
|
This is intended as an extensible way to add listeners.</p>
|
|
|
|
|
<p>This type itself is available in any context, but only the
|
|
|
|
|
core context has the actual events defined by C++ code.</p>
|
|
|
|
|
<p>Features:</p>
|
|
|
|
|
<ul>
|
|
|
|
|
<li><p class="first"><tt class="docutils literal">dfhack.event.new()</tt></p>
|
|
|
|
|
<p>Creates a new instance of an event.</p>
|
|
|
|
|
</li>
|
|
|
|
|
<li><p class="first"><tt class="docutils literal">event[key] = function</tt></p>
|
|
|
|
|
<p>Sets the function as one of the listeners.</p>
|
|
|
|
|
<p><strong>NOTE</strong>: The <tt class="docutils literal">df.NULL</tt> key is reserved for the use by
|
|
|
|
|
the C++ owner of the event, and has some special semantics.</p>
|
|
|
|
|
</li>
|
|
|
|
|
<li><p class="first"><tt class="docutils literal"><span class="pre">event(args...)</span></tt></p>
|
|
|
|
|
<p>Invokes all listeners contained in the event in an arbitrary
|
|
|
|
|
order using <tt class="docutils literal">dfhack.safecall</tt>.</p>
|
|
|
|
|
</li>
|
|
|
|
|
</ul>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</body>
|
|
|
|
|
</html>
|
|
|
|
|