summaryrefslogtreecommitdiff
path: root/Lua API.html
diff options
context:
space:
mode:
authorAlexander Gavrilov2012-04-06 19:56:19 +0400
committerAlexander Gavrilov2012-04-06 19:56:19 +0400
commit0daafef690d6a9e44f7caa7f61b89a63a3870cf9 (patch)
treef1e433a244965af860fbf125a497d018a5988e80 /Lua API.html
parent2640addf49d48092104b1ba14518895a5765359d (diff)
downloaddfhack-0daafef690d6a9e44f7caa7f61b89a63a3870cf9.tar.gz
dfhack-0daafef690d6a9e44f7caa7f61b89a63a3870cf9.tar.bz2
dfhack-0daafef690d6a9e44f7caa7f61b89a63a3870cf9.tar.xz
Wrap MaterialInfo for lua.
Diffstat (limited to 'Lua API.html')
-rw-r--r--Lua API.html60
1 files changed, 52 insertions, 8 deletions
diff --git a/Lua API.html b/Lua API.html
index ab64eea9..379432a7 100644
--- a/Lua API.html
+++ b/Lua API.html
@@ -335,10 +335,11 @@ ul.auto-toc {
</li>
<li><a class="reference internal" href="#dfhack-utilities" id="id10">DFHack utilities</a><ul>
<li><a class="reference internal" href="#persistent-configuration-storage" id="id11">Persistent configuration storage</a></li>
-<li><a class="reference internal" href="#c-function-wrappers" id="id12">C++ function wrappers</a><ul>
-<li><a class="reference internal" href="#gui-module" id="id13">Gui module</a></li>
-<li><a class="reference internal" href="#job-module" id="id14">Job module</a></li>
-<li><a class="reference internal" href="#units-module" id="id15">Units module</a></li>
+<li><a class="reference internal" href="#material-info-lookup" id="id12">Material info lookup</a></li>
+<li><a class="reference internal" href="#c-function-wrappers" id="id13">C++ function wrappers</a><ul>
+<li><a class="reference internal" href="#gui-module" id="id14">Gui module</a></li>
+<li><a class="reference internal" href="#job-module" id="id15">Job module</a></li>
+<li><a class="reference internal" href="#units-module" id="id16">Units module</a></li>
</ul>
</li>
</ul>
@@ -759,8 +760,51 @@ and automatically stored in the save game, these save and retrieval
functions can just copy values in memory without doing any actual I/O.
However, currently every entry has a 180+-byte dead-weight overhead.</p>
</div>
+<div class="section" id="material-info-lookup">
+<h2><a class="toc-backref" href="#id12">Material info lookup</a></h2>
+<p>A material info record has fields:</p>
+<ul>
+<li><p class="first"><tt class="docutils literal">type</tt>, <tt class="docutils literal">index</tt>, <tt class="docutils literal">material</tt></p>
+<p>DF material code pair, and a reference to the material object.</p>
+</li>
+<li><p class="first"><tt class="docutils literal">mode</tt></p>
+<p>One of <tt class="docutils literal">'builtin'</tt>, <tt class="docutils literal">'inorganic'</tt>, <tt class="docutils literal">'plant'</tt>, <tt class="docutils literal">'creature'</tt>.</p>
+</li>
+<li><p class="first"><tt class="docutils literal">inorganic</tt>, <tt class="docutils literal">plant</tt>, <tt class="docutils literal">creature</tt></p>
+<p>If the material is of the matching type, contains a reference to the raw object.</p>
+</li>
+<li><p class="first"><tt class="docutils literal">figure</tt></p>
+<p>For a specific creature material contains a ref to the historical figure.</p>
+</li>
+</ul>
+<p>Functions:</p>
+<ul>
+<li><p class="first"><tt class="docutils literal">dfhack.matinfo.decode(type,index)</tt></p>
+<p>Looks up material info for the given number pair; if not found, returs <em>nil</em>.</p>
+</li>
+<li><p class="first"><tt class="docutils literal"><span class="pre">....decode(matinfo)</span></tt>, <tt class="docutils literal"><span class="pre">....decode(item)</span></tt>, <tt class="docutils literal"><span class="pre">....decode(obj)</span></tt></p>
+<p>Uses <tt class="docutils literal">matinfo.type</tt>/<tt class="docutils literal">matinfo.index</tt>, item getter vmethods,
+or <tt class="docutils literal">obj.mat_type</tt>/<tt class="docutils literal">obj.mat_index</tt> to get the code pair.</p>
+</li>
+<li><p class="first"><tt class="docutils literal"><span class="pre">dfhack.matinfo.find(token[,token...])</span></tt></p>
+<p>Looks up material by a token string, or a pre-split string token sequence.</p>
+</li>
+<li><p class="first"><tt class="docutils literal"><span class="pre">dfhack.matinfo.getToken(...)</span></tt>, <tt class="docutils literal">info:getToken()</tt></p>
+<p>Applies <tt class="docutils literal">decode</tt> and constructs a string token.</p>
+</li>
+<li><p class="first"><tt class="docutils literal"><span class="pre">info:toString([temperature[,named]])</span></tt></p>
+<p>Returns the human-readable name at the given temperature.</p>
+</li>
+<li><p class="first"><tt class="docutils literal">info:getCraftClass()</tt></p>
+<p>Returns the classification used for craft skills.</p>
+</li>
+<li><p class="first"><tt class="docutils literal">info:matches(obj)</tt></p>
+<p>Checks if the material matches job_material_category or job_item.</p>
+</li>
+</ul>
+</div>
<div class="section" id="c-function-wrappers">
-<h2><a class="toc-backref" href="#id12">C++ function wrappers</a></h2>
+<h2><a class="toc-backref" href="#id13">C++ function wrappers</a></h2>
<p>Thin wrappers around C++ functions, similar to the ones for virtual methods.</p>
<ul>
<li><p class="first"><tt class="docutils literal">dfhack.TranslateName(name,in_english,only_last_name)</tt></p>
@@ -768,7 +812,7 @@ However, currently every entry has a 180+-byte dead-weight overhead.</p>
</li>
</ul>
<div class="section" id="gui-module">
-<h3><a class="toc-backref" href="#id13">Gui module</a></h3>
+<h3><a class="toc-backref" href="#id14">Gui module</a></h3>
<ul>
<li><p class="first"><tt class="docutils literal">dfhack.gui.getSelectedWorkshopJob(silent)</tt></p>
<p>When a job is selected in <em>'q'</em> mode, returns the job, else
@@ -797,7 +841,7 @@ The is_bright boolean actually seems to invert the brightness.</p>
</ul>
</div>
<div class="section" id="job-module">
-<h3><a class="toc-backref" href="#id14">Job module</a></h3>
+<h3><a class="toc-backref" href="#id15">Job module</a></h3>
<ul>
<li><p class="first"><tt class="docutils literal">dfhack.job.cloneJobStruct(job)</tt></p>
<p>Creates a deep copy of the given job.</p>
@@ -817,7 +861,7 @@ The is_bright boolean actually seems to invert the brightness.</p>
</ul>
</div>
<div class="section" id="units-module">
-<h3><a class="toc-backref" href="#id15">Units module</a></h3>
+<h3><a class="toc-backref" href="#id16">Units module</a></h3>
<ul>
<li><p class="first"><tt class="docutils literal">dfhack.units.getVisibleName(unit)</tt></p>
<p>Returns the name visible in game, accounting for false identities.</p>