diff options
| author | Alexander Gavrilov | 2012-05-01 18:55:30 +0400 |
|---|---|---|
| committer | Alexander Gavrilov | 2012-05-01 18:55:30 +0400 |
| commit | 4cffb6428d5e25b0c3cb09044f65dbf5d43667e9 (patch) | |
| tree | 5a78cac5f5c3bfb1e9004c451f97adcae4b6571d /Lua API.html | |
| parent | 2303a25bdefab30bea67f32d27d35e5002448e8a (diff) | |
| download | dfhack-4cffb6428d5e25b0c3cb09044f65dbf5d43667e9.tar.gz dfhack-4cffb6428d5e25b0c3cb09044f65dbf5d43667e9.tar.bz2 dfhack-4cffb6428d5e25b0c3cb09044f65dbf5d43667e9.tar.xz | |
Update building creation code with new knowledge, and fix zone.
Also, document new lua api, and add a more convenient wrapper.
Diffstat (limited to 'Lua API.html')
| -rw-r--r-- | Lua API.html | 77 |
1 files changed, 67 insertions, 10 deletions
diff --git a/Lua API.html b/Lua API.html index fd2004b8..69a0ab12 100644 --- a/Lua API.html +++ b/Lua API.html @@ -343,17 +343,18 @@ ul.auto-toc { <li><a class="reference internal" href="#items-module" id="id17">Items module</a></li> <li><a class="reference internal" href="#maps-module" id="id18">Maps module</a></li> <li><a class="reference internal" href="#burrows-module" id="id19">Burrows module</a></li> +<li><a class="reference internal" href="#buildings-module" id="id20">Buildings module</a></li> </ul> </li> -<li><a class="reference internal" href="#core-interpreter-context" id="id20">Core interpreter context</a><ul> -<li><a class="reference internal" href="#event-type" id="id21">Event type</a></li> +<li><a class="reference internal" href="#core-interpreter-context" id="id21">Core interpreter context</a><ul> +<li><a class="reference internal" href="#event-type" id="id22">Event type</a></li> </ul> </li> </ul> </li> -<li><a class="reference internal" href="#plugins" id="id22">Plugins</a><ul> -<li><a class="reference internal" href="#burrows" id="id23">burrows</a></li> -<li><a class="reference internal" href="#sort" id="id24">sort</a></li> +<li><a class="reference internal" href="#plugins" id="id23">Plugins</a><ul> +<li><a class="reference internal" href="#burrows" id="id24">burrows</a></li> +<li><a class="reference internal" href="#sort" id="id25">sort</a></li> </ul> </li> </ul> @@ -1061,9 +1062,65 @@ burrows, or the presence of invaders.</p> </li> </ul> </div> +<div class="section" id="buildings-module"> +<h3><a class="toc-backref" href="#id20">Buildings module</a></h3> +<ul> +<li><p class="first"><tt class="docutils literal">dfhack.buildings.getSize(building)</tt></p> +<p>Returns <em>width, height, centerx, centery</em>.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.buildings.getCorrectSize(width, height, type, subtype, custom, direction)</tt></p> +<p>Computes correct dimensions for the specified building type and orientation, +using width and height for flexible dimensions. +Returns <em>is_flexible, width, height, center_x, center_y</em>.</p> +</li> +<li><p class="first"><tt class="docutils literal"><span class="pre">dfhack.buildings.checkFreeTiles(pos,size[,extents,change_extents,allow_occupied])</span></tt></p> +<p>Checks if the rectangle defined by <tt class="docutils literal">pos</tt> and <tt class="docutils literal">size</tt>, and possibly extents, +can be used for placing a building. If <tt class="docutils literal">change_extents</tt> is true, bad tiles +are removed from extents. If <tt class="docutils literal">allow_occupied</tt>, the occupancy test is skipped.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.buildings.countExtentTiles(extents,defval)</tt></p> +<p>Returns the number of tiles included by extents, or defval.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.buildings.hasSupport(pos,size)</tt></p> +<p>Checks if a bridge constructed at specified position would have +support from terrain, and thus won't collapse if retracted.</p> +</li> +</ul> +<p>Low-level building creation functions;</p> +<ul> +<li><p class="first"><tt class="docutils literal">dfhack.buildings.allocInstance(pos, type, subtype, custom)</tt></p> +<p>Creates a new building instance of given type, subtype and custom type, +at specified position. Returns the object, or <em>nil</em> in case of an error.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.buildings.setSize(building, width, height, direction)</tt></p> +<p>Configures an object returned by <tt class="docutils literal">allocInstance</tt>, using specified +parameters wherever appropriate. If the building has fixed size along +any dimension, the corresponding input parameter will be ignored. +Returns <em>nil</em> if the building cannot be placed, or <em>true, width, +height, rect_area, true_area</em>. Returned width and height are the +final values used by the building; true_area is less than rect_area +if any tiles were removed from designation.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.buildings.constructWithItems(building, items)</tt></p> +<p>Links a fully configured object created by <tt class="docutils literal">allocInstance</tt> into the +world for construction, using a list of specific items as material. +Returns <em>true</em>, or <em>false</em> if impossible.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.buildings.constructWithFilters(building, job_items)</tt></p> +<p>Links a fully configured object created by <tt class="docutils literal">allocInstance</tt> into the +world for construction, using a list of job_item filters as inputs. +Returns <em>true</em>, or <em>false</em> if impossible. Filter objects are claimed +and possibly destroyed in any case. +Use a negative <tt class="docutils literal">quantity</tt> field value to auto-compute the amount +from the size of the building.</p> +</li> +</ul> +<p>More high-level functions are implemented in lua and can be loaded by +<tt class="docutils literal"><span class="pre">require('dfhack.buildings')</span></tt>. See <tt class="docutils literal">hack/lua/dfhack/buildings.lua</tt>.</p> +</div> </div> <div class="section" id="core-interpreter-context"> -<h2><a class="toc-backref" href="#id20">Core interpreter context</a></h2> +<h2><a class="toc-backref" href="#id21">Core interpreter context</a></h2> <p>While plugins can create any number of interpreter instances, there is one special context managed by dfhack core. It is the only context that can receive events from DF and plugins.</p> @@ -1077,7 +1134,7 @@ only context that can receive events from DF and plugins.</p> </li> </ul> <div class="section" id="event-type"> -<h3><a class="toc-backref" href="#id21">Event type</a></h3> +<h3><a class="toc-backref" href="#id22">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. @@ -1103,14 +1160,14 @@ order using <tt class="docutils literal">dfhack.safecall</tt>.</p> </div> </div> <div class="section" id="plugins"> -<h1><a class="toc-backref" href="#id22">Plugins</a></h1> +<h1><a class="toc-backref" href="#id23">Plugins</a></h1> <p>DFHack plugins may export native functions and events to lua contexts. They are automatically imported by <tt class="docutils literal"><span class="pre">mkmodule('plugins.<name>')</span></tt>; this means that a lua module file is still necessary for <tt class="docutils literal">require</tt> to read.</p> <p>The following plugins have lua support.</p> <div class="section" id="burrows"> -<h2><a class="toc-backref" href="#id23">burrows</a></h2> +<h2><a class="toc-backref" href="#id24">burrows</a></h2> <p>Implements extended burrow manipulations.</p> <p>Events:</p> <ul> @@ -1148,7 +1205,7 @@ set is the same as used by the command line.</p> <p>The lua module file also re-exports functions from <tt class="docutils literal">dfhack.burrows</tt>.</p> </div> <div class="section" id="sort"> -<h2><a class="toc-backref" href="#id24">sort</a></h2> +<h2><a class="toc-backref" href="#id25">sort</a></h2> <p>Does not export any native functions as of now. Instead, it calls lua code to perform the actual ordering of list items.</p> </div> |
