minetest_modding_book/lua_api.html

5079 lines
334 KiB
HTML
Raw Normal View History

2014-12-28 22:26:49 +03:00
---
2014-12-31 19:43:27 +03:00
title: Lua Modding API Reference
2014-12-28 22:26:49 +03:00
layout: default
---
<div class='notice'>
<h2>This is lua_api.txt nicely formated: I did not write this</h2>
2017-02-19 16:15:50 +03:00
This page was last updated 19/February/2017.<br />See <a href="https://github.com/minetest/minetest/blob/master/doc/lua_api.txt">doc/lua_api.txt</a> for the latest version (in plaintext).<br />Generated using <a href="https://github.com/rubenwardy/minetest_modding_book/blob/gh-pages/update_lua_api.py">a Python script</a>.</div>
<h2 id="table-of-contents">Table of Contents</h2>
2014-12-28 22:55:14 +03:00
<div class="toc">
<ul>
<li><a href="#introduction">Introduction</a></li>
<li><a href="#programming-in-lua">Programming in Lua</a></li>
<li><a href="#startup">Startup</a></li>
<li><a href="#paths">Paths</a></li>
2015-08-12 16:54:11 +03:00
<li><a href="#games">Games</a><ul>
<li><a href="#menu-images">Menu images</a></li>
</ul>
</li>
2014-12-28 22:55:14 +03:00
<li><a href="#mod-load-path">Mod load path</a></li>
<li><a href="#mod-load-path-for-world-specific-games">Mod load path for world-specific games</a></li>
<li><a href="#modpack-support">Modpack support</a></li>
<li><a href="#mod-directory-structure">Mod directory structure</a><ul>
<li><a href="#modname">modname</a></li>
<li><a href="#dependstxt">depends.txt</a></li>
<li><a href="#screenshotpng">screenshot.png</a></li>
<li><a href="#descriptiontxt">description.txt</a></li>
2015-10-26 03:16:41 +03:00
<li><a href="#settingtypestxt">settingtypes.txt</a></li>
2014-12-28 22:55:14 +03:00
<li><a href="#initlua">init.lua</a></li>
<li><a href="#models">models</a></li>
<li><a href="#textures-sounds-media">textures, sounds, media</a></li>
</ul>
</li>
<li><a href="#naming-convention-for-registered-textual-names">Naming convention for registered textual names</a><ul>
<li><a href="#example">Example</a></li>
<li><a href="#aliases">Aliases</a></li>
</ul>
</li>
<li><a href="#textures">Textures</a></li>
<li><a href="#texture-modifiers">Texture modifiers</a><ul>
<li><a href="#texture-overlaying">Texture overlaying</a></li>
<li><a href="#texture-grouping">Texture grouping</a></li>
2016-11-12 19:27:07 +03:00
<li><a href="#escaping">Escaping</a></li>
2014-12-28 22:55:14 +03:00
<li><a href="#advanced-texture-modifiers">Advanced texture modifiers</a><ul>
<li><a href="#cracknp">[crack:&lt;n&gt;:&lt;p&gt;</a></li>
2016-03-19 17:25:33 +03:00
<li><a href="#combinewxhx1y1file1x2y2file2">[combine:&lt;w&gt;x&lt;h&gt;:&lt;x1&gt;,&lt;y1&gt;=&lt;file1&gt;:&lt;x2&gt;,&lt;y2&gt;=&lt;file2&gt;:...</a></li>
2016-05-26 20:47:50 +03:00
<li><a href="#resizewxh">[resize:&lt;w&gt;x&lt;h&gt;</a></li>
2016-08-29 15:43:46 +03:00
<li><a href="#opacityr">[opacity:&lt;r&gt;</a></li>
2016-11-12 19:27:07 +03:00
<li><a href="#invertmode">[invert:&lt;mode&gt;</a></li>
2014-12-28 22:55:14 +03:00
<li><a href="#brighten">[brighten</a></li>
<li><a href="#noalpha">[noalpha</a></li>
<li><a href="#makealphargb">[makealpha:&lt;r&gt;,&lt;g&gt;,&lt;b&gt;</a></li>
<li><a href="#transformt">[transform&lt;t&gt;</a></li>
<li><a href="#inventorycubetopleftright">[inventorycube{&lt;top&gt;{&lt;left&gt;{&lt;right&gt;</a></li>
<li><a href="#lowpartpercentfile">[lowpart:&lt;percent&gt;:&lt;file&gt;</a></li>
<li><a href="#verticalframetn">[verticalframe:&lt;t&gt;:&lt;n&gt;</a></li>
<li><a href="#maskfile">[mask:&lt;file&gt;</a></li>
2017-01-31 17:21:12 +03:00
<li><a href="#sheetwxhxy">[sheet:&lt;w&gt;x&lt;h&gt;:&lt;x&gt;,&lt;y&gt;</a></li>
2015-01-24 22:07:00 +03:00
<li><a href="#colorizecolorratio">[colorize:&lt;color&gt;:&lt;ratio&gt;</a></li>
2017-01-31 17:21:12 +03:00
<li><a href="#multiplycolor">[multiply:&lt;color&gt;</a></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
</ul>
</li>
<li><a href="#sounds">Sounds</a><ul>
<li><a href="#simplesoundspec">SimpleSoundSpec</a></li>
</ul>
</li>
<li><a href="#registered-definitions-of-stuff">Registered definitions of stuff</a></li>
<li><a href="#nodes">Nodes</a></li>
<li><a href="#node-drawtypes">Node drawtypes</a></li>
<li><a href="#node-boxes">Node boxes</a></li>
<li><a href="#meshes">Meshes</a></li>
<li><a href="#noise-parameters">Noise Parameters</a><ul>
<li><a href="#offset">offset</a></li>
<li><a href="#scale">scale</a></li>
<li><a href="#spread">spread</a></li>
<li><a href="#seed">seed</a></li>
<li><a href="#octaves">octaves</a></li>
<li><a href="#persistence">persistence</a></li>
<li><a href="#lacunarity">lacunarity</a></li>
<li><a href="#flags">flags</a><ul>
<li><a href="#defaults">defaults</a></li>
<li><a href="#eased">eased</a></li>
<li><a href="#absvalue">absvalue</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#ore-types">Ore types</a><ul>
<li><a href="#scatter">scatter</a></li>
<li><a href="#sheet">sheet</a></li>
2015-09-25 02:24:04 +03:00
<li><a href="#puff">puff</a></li>
<li><a href="#blob">blob</a></li>
2015-09-25 02:24:04 +03:00
<li><a href="#vein">vein</a></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
<li><a href="#ore-attributes">Ore attributes</a><ul>
<li><a href="#absheight">absheight</a></li>
2015-09-25 02:24:04 +03:00
<li><a href="#puff_cliffs">puff_cliffs</a></li>
<li><a href="#puff_additive_composition">puff_additive_composition</a></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
<li><a href="#decoration-types">Decoration types</a><ul>
<li><a href="#simple">simple</a></li>
<li><a href="#schematic">schematic</a></li>
</ul>
</li>
<li><a href="#schematic-specifier">Schematic specifier</a></li>
<li><a href="#schematic-attributes">Schematic attributes</a></li>
<li><a href="#hud-element-types">HUD element types</a><ul>
<li><a href="#image">image</a></li>
<li><a href="#text">text</a></li>
<li><a href="#statbar">statbar</a></li>
<li><a href="#inventory">inventory</a></li>
<li><a href="#waypoint">waypoint</a></li>
</ul>
</li>
<li><a href="#representations-of-simple-things">Representations of simple things</a><ul>
<li><a href="#positionvector">Position/vector</a></li>
<li><a href="#pointed_thing">pointed_thing</a></li>
</ul>
</li>
<li><a href="#flag-specifier-format">Flag Specifier Format</a></li>
<li><a href="#items">Items</a><ul>
<li><a href="#item-types">Item types</a></li>
<li><a href="#item-formats">Item formats</a><ul>
<li><a href="#serialized">Serialized</a></li>
<li><a href="#table-format">Table format</a></li>
<li><a href="#itemstack">ItemStack</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#groups">Groups</a><ul>
<li><a href="#usage">Usage</a></li>
<li><a href="#groups-of-items">Groups of items</a></li>
<li><a href="#groups-of-nodes">Groups of nodes</a></li>
<li><a href="#groups-of-entities">Groups of entities</a></li>
<li><a href="#groups-of-tools">Groups of tools</a></li>
<li><a href="#groups-in-crafting-recipes">Groups in crafting recipes</a></li>
<li><a href="#special-groups">Special groups</a></li>
<li><a href="#known-damage-and-digging-time-defining-groups">Known damage and digging time defining groups</a></li>
<li><a href="#examples-of-custom-groups">Examples of custom groups</a></li>
<li><a href="#digging-time-calculation-specifics">Digging time calculation specifics</a><ul>
<li><a href="#tools-definition">Tools definition</a></li>
<li><a href="#full-punch-interval">Full punch interval</a></li>
<li><a href="#maximum-drop-level">Maximum drop level</a></li>
<li><a href="#uses">Uses</a></li>
<li><a href="#maximum-level">Maximum level</a></li>
<li><a href="#digging-times">Digging times</a></li>
<li><a href="#damage-groups">Damage groups</a></li>
<li><a href="#example-definition-of-the-capabilities-of-a-tool">Example definition of the capabilities of a tool</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#entity-damage-mechanism">Entity damage mechanism</a></li>
<li><a href="#node-metadata">Node Metadata</a></li>
2017-02-19 16:15:50 +03:00
<li><a href="#item-metadata">Item Metadata</a></li>
2014-12-28 22:55:14 +03:00
<li><a href="#formspec">Formspec</a><ul>
<li><a href="#examples">Examples</a><ul>
<li><a href="#chest">Chest</a></li>
<li><a href="#furnace">Furnace</a></li>
<li><a href="#minecraft-like-player-inventory">Minecraft-like player inventory</a></li>
</ul>
</li>
<li><a href="#elements">Elements</a><ul>
<li><a href="#sizewhfixed_size">size[&lt;W&gt;,&lt;H&gt;,&lt;fixed_size&gt;]</a></li>
2016-11-12 19:27:07 +03:00
<li><a href="#containerxy">container[&lt;X&gt;,&lt;Y&gt;]</a></li>
<li><a href="#container_end">container_end[]</a></li>
2014-12-28 22:55:14 +03:00
<li><a href="#listinventory-locationlist-namexywh">list[&lt;inventory location&gt;;&lt;list name&gt;;&lt;X&gt;,&lt;Y&gt;;&lt;W&gt;,&lt;H&gt;;]</a></li>
<li><a href="#listinventory-locationlist-namexywhstarting-item-index">list[&lt;inventory location&gt;;&lt;list name&gt;;&lt;X&gt;,&lt;Y&gt;;&lt;W&gt;,&lt;H&gt;;&lt;starting item index&gt;]</a></li>
2015-07-08 11:43:59 +03:00
<li><a href="#listringinventory-locationlist-name">listring[&lt;inventory location&gt;;&lt;list name&gt;]</a></li>
<li><a href="#listring">listring[]</a></li>
2014-12-28 22:55:14 +03:00
<li><a href="#listcolorsslot_bg_normalslot_bg_hover">listcolors[&lt;slot_bg_normal&gt;;&lt;slot_bg_hover&gt;]</a></li>
<li><a href="#listcolorsslot_bg_normalslot_bg_hoverslot_border">listcolors[&lt;slot_bg_normal&gt;;&lt;slot_bg_hover&gt;;&lt;slot_border&gt;]</a></li>
<li><a href="#listcolorsslot_bg_normalslot_bg_hoverslot_bordertooltip_bgcolortooltip_fontcolor">listcolors[&lt;slot_bg_normal&gt;;&lt;slot_bg_hover&gt;;&lt;slot_border&gt;;&lt;tooltip_bgcolor&gt;;&lt;tooltip_fontcolor&gt;]</a></li>
<li><a href="#tooltipgui_element_nametooltip_textbgcolorfontcolor">tooltip[&lt;gui_element_name&gt;;&lt;tooltip_text&gt;;&lt;bgcolor&gt;,&lt;fontcolor&gt;]</a></li>
<li><a href="#imagexywhtexture-name">image[&lt;X&gt;,&lt;Y&gt;;&lt;W&gt;,&lt;H&gt;;&lt;texture name&gt;]</a></li>
<li><a href="#item_imagexywhitem-name">item_image[&lt;X&gt;,&lt;Y&gt;;&lt;W&gt;,&lt;H&gt;;&lt;item name&gt;]</a></li>
<li><a href="#bgcolorcolorfullscreen">bgcolor[&lt;color&gt;;&lt;fullscreen&gt;]</a></li>
<li><a href="#backgroundxywhtexture-name">background[&lt;X&gt;,&lt;Y&gt;;&lt;W&gt;,&lt;H&gt;;&lt;texture name&gt;]</a></li>
<li><a href="#backgroundxywhtexture-nameauto_clip">background[&lt;X&gt;,&lt;Y&gt;;&lt;W&gt;,&lt;H&gt;;&lt;texture name&gt;;&lt;auto_clip&gt;]</a></li>
2016-11-12 19:27:07 +03:00
<li><a href="#pwdfieldxywhnamelabel">pwdfield[&lt;X&gt;,&lt;Y&gt;;&lt;W&gt;,&lt;H&gt;;&lt;name&gt;;&lt;label&gt;]</a></li>
<li><a href="#fieldxywhnamelabeldefault">field[&lt;X&gt;,&lt;Y&gt;;&lt;W&gt;,&lt;H&gt;;&lt;name&gt;;&lt;label&gt;;&lt;default&gt;]</a></li>
<li><a href="#fieldnamelabeldefault">field[&lt;name&gt;;&lt;label&gt;;&lt;default&gt;]</a></li>
<li><a href="#field_close_on_enternameclose_on_enter">field_close_on_enter[&lt;name&gt;;&lt;close_on_enter&gt;]</a></li>
2014-12-28 22:55:14 +03:00
<li><a href="#textareaxywhnamelabeldefault">textarea[&lt;X&gt;,&lt;Y&gt;;&lt;W&gt;,&lt;H&gt;;&lt;name&gt;;&lt;label&gt;;&lt;default&gt;]</a></li>
<li><a href="#labelxylabel">label[&lt;X&gt;,&lt;Y&gt;;&lt;label&gt;]</a></li>
<li><a href="#vertlabelxylabel">vertlabel[&lt;X&gt;,&lt;Y&gt;;&lt;label&gt;]</a></li>
<li><a href="#buttonxywhnamelabel">button[&lt;X&gt;,&lt;Y&gt;;&lt;W&gt;,&lt;H&gt;;&lt;name&gt;;&lt;label&gt;]</a></li>
<li><a href="#image_buttonxywhtexture-namenamelabel">image_button[&lt;X&gt;,&lt;Y&gt;;&lt;W&gt;,&lt;H&gt;;&lt;texture name&gt;;&lt;name&gt;;&lt;label&gt;]</a></li>
<li><a href="#image_buttonxywhtexture-namenamelabelnoclipdrawborderpressed-texture-name">image_button[&lt;X&gt;,&lt;Y&gt;;&lt;W&gt;,&lt;H&gt;;&lt;texture name&gt;;&lt;name&gt;;&lt;label&gt;;&lt;noclip&gt;;&lt;drawborder&gt;;&lt;pressed texture name&gt;]</a></li>
<li><a href="#item_image_buttonxywhitem-namenamelabel">item_image_button[&lt;X&gt;,&lt;Y&gt;;&lt;W&gt;,&lt;H&gt;;&lt;item name&gt;;&lt;name&gt;;&lt;label&gt;]</a></li>
<li><a href="#button_exitxywhnamelabel">button_exit[&lt;X&gt;,&lt;Y&gt;;&lt;W&gt;,&lt;H&gt;;&lt;name&gt;;&lt;label&gt;]</a></li>
<li><a href="#image_button_exitxywhtexture-namenamelabel">image_button_exit[&lt;X&gt;,&lt;Y&gt;;&lt;W&gt;,&lt;H&gt;;&lt;texture name&gt;;&lt;name&gt;;&lt;label&gt;]</a></li>
<li><a href="#textlistxywhnamelistelem-1listelem-2listelem-n">textlist[&lt;X&gt;,&lt;Y&gt;;&lt;W&gt;,&lt;H&gt;;&lt;name&gt;;&lt;listelem 1&gt;,&lt;listelem 2&gt;,...,&lt;listelem n&gt;]</a></li>
<li><a href="#textlistxywhnamelistelem-1listelem-2listelem-nselected-idxtransparent">textlist[&lt;X&gt;,&lt;Y&gt;;&lt;W&gt;,&lt;H&gt;;&lt;name&gt;;&lt;listelem 1&gt;,&lt;listelem 2&gt;,...,&lt;listelem n&gt;;&lt;selected idx&gt;;&lt;transparent&gt;]</a></li>
<li><a href="#tabheaderxynamecaption-1caption-2caption-ncurrent_tabtransparentdraw_border">tabheader[&lt;X&gt;,&lt;Y&gt;;&lt;name&gt;;&lt;caption 1&gt;,&lt;caption 2&gt;,...,&lt;caption n&gt;;&lt;current_tab&gt;;&lt;transparent&gt;;&lt;draw_border&gt;]</a></li>
<li><a href="#boxxywhcolor">box[&lt;X&gt;,&lt;Y&gt;;&lt;W&gt;,&lt;H&gt;;&lt;color&gt;]</a></li>
<li><a href="#dropdownxywnameitem-1item-2-item-nselected-idx">dropdown[&lt;X&gt;,&lt;Y&gt;;&lt;W&gt;;&lt;name&gt;;&lt;item 1&gt;,&lt;item 2&gt;, ...,&lt;item n&gt;;&lt;selected idx&gt;]</a></li>
2016-07-22 21:37:58 +03:00
<li><a href="#checkboxxynamelabelselected">checkbox[&lt;X&gt;,&lt;Y&gt;;&lt;name&gt;;&lt;label&gt;;&lt;selected&gt;]</a></li>
2014-12-28 22:55:14 +03:00
<li><a href="#scrollbarxywhorientationnamevalue">scrollbar[&lt;X&gt;,&lt;Y&gt;;&lt;W&gt;,&lt;H&gt;;&lt;orientation&gt;;&lt;name&gt;;&lt;value&gt;]</a></li>
<li><a href="#tablexywhnamecell-1cell-2cell-nselected-idx">table[&lt;X&gt;,&lt;Y&gt;;&lt;W&gt;,&lt;H&gt;;&lt;name&gt;;&lt;cell 1&gt;,&lt;cell 2&gt;,...,&lt;cell n&gt;;&lt;selected idx&gt;]</a></li>
<li><a href="#tableoptionsopt-1opt-2">tableoptions[&lt;opt 1&gt;;&lt;opt 2&gt;;...]</a></li>
<li><a href="#tablecolumnstype-1opt-1aopt-1btype-2opt-2aopt-2b">tablecolumns[&lt;type 1&gt;,&lt;opt 1a&gt;,&lt;opt 1b&gt;,...;&lt;type 2&gt;,&lt;opt 2a&gt;,&lt;opt 2b&gt;;...]</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#inventory-locations">Inventory locations</a></li>
2016-12-29 00:57:48 +03:00
<li><a href="#player-inventory-lists">Player Inventory lists</a></li>
2014-12-28 22:55:14 +03:00
<li><a href="#colorstring">ColorString</a></li>
2015-05-27 12:53:46 +03:00
<li><a href="#colorspec">ColorSpec</a></li>
2016-07-22 21:37:58 +03:00
<li><a href="#escape-sequences">Escape sequences</a></li>
2015-10-26 03:16:41 +03:00
<li><a href="#spatial-vectors">Spatial Vectors</a></li>
2014-12-28 22:55:14 +03:00
<li><a href="#helper-functions">Helper functions</a></li>
<li><a href="#minetest-namespace-reference">minetest namespace reference</a><ul>
<li><a href="#utilities">Utilities</a></li>
<li><a href="#logging">Logging</a></li>
<li><a href="#registration-functions">Registration functions</a></li>
<li><a href="#global-callback-registration-functions">Global callback registration functions</a></li>
<li><a href="#other-registration-functions">Other registration functions</a></li>
<li><a href="#setting-related">Setting-related</a></li>
<li><a href="#authentication">Authentication</a></li>
<li><a href="#chat">Chat</a></li>
<li><a href="#environment-access">Environment access</a></li>
<li><a href="#inventory_1">Inventory</a></li>
<li><a href="#formspec_1">Formspec</a></li>
<li><a href="#item-handling">Item handling</a></li>
<li><a href="#rollback">Rollback</a></li>
<li><a href="#defaults-for-the-on_-item-definition-functions">Defaults for the on_* item definition functions</a></li>
<li><a href="#defaults-for-the-on_punch-and-on_dig-node-definition-callbacks">Defaults for the on_punch and on_dig node definition callbacks</a></li>
<li><a href="#sounds_1">Sounds</a></li>
<li><a href="#timing">Timing</a></li>
<li><a href="#server">Server</a></li>
<li><a href="#bans">Bans</a></li>
<li><a href="#particles">Particles</a></li>
<li><a href="#schematics">Schematics</a></li>
2016-03-19 17:25:33 +03:00
<li><a href="#http-requests">HTTP Requests:</a></li>
2017-02-19 16:15:50 +03:00
<li><a href="#storage-api">Storage API:</a></li>
2014-12-28 22:55:14 +03:00
<li><a href="#misc">Misc.</a></li>
<li><a href="#global-objects">Global objects</a></li>
<li><a href="#global-tables">Global tables</a></li>
</ul>
</li>
<li><a href="#class-reference">Class reference</a><ul>
2017-02-19 16:15:50 +03:00
<li><a href="#metadataref">MetaDataRef</a><ul>
2014-12-28 22:55:14 +03:00
<li><a href="#methods">Methods</a></li>
</ul>
</li>
2017-02-19 16:15:50 +03:00
<li><a href="#nodemetaref">NodeMetaRef</a><ul>
2014-12-28 22:55:14 +03:00
<li><a href="#methods_1">Methods</a></li>
</ul>
</li>
2017-02-19 16:15:50 +03:00
<li><a href="#itemstackmetaref">ItemStackMetaRef</a><ul>
<li><a href="#methods_2">Methods</a></li>
</ul>
</li>
<li><a href="#storageref">StorageRef</a><ul>
<li><a href="#methods_3">Methods</a></li>
</ul>
</li>
<li><a href="#nodetimerref">NodeTimerRef</a><ul>
<li><a href="#methods_4">Methods</a></li>
</ul>
</li>
2014-12-28 22:55:14 +03:00
<li><a href="#objectref">ObjectRef</a><ul>
2017-02-19 16:15:50 +03:00
<li><a href="#methods_5">Methods</a><ul>
2014-12-28 22:55:14 +03:00
<li><a href="#luaentitysao-only-no-op-for-other-objects">LuaEntitySAO-only (no-op for other objects)</a></li>
<li><a href="#player-only-no-op-for-other-objects">Player-only (no-op for other objects)</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#invref">InvRef</a><ul>
2017-02-19 16:15:50 +03:00
<li><a href="#methods_6">Methods</a></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-08-12 16:54:11 +03:00
<li><a href="#areastore">AreaStore</a><ul>
2017-02-19 16:15:50 +03:00
<li><a href="#methods_7">Methods</a></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-08-12 16:54:11 +03:00
<li><a href="#itemstack_1">ItemStack</a><ul>
2017-02-19 16:15:50 +03:00
<li><a href="#methods_8">Methods</a></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-08-12 16:54:11 +03:00
<li><a href="#pseudorandom">PseudoRandom</a><ul>
2017-02-19 16:15:50 +03:00
<li><a href="#methods_9">Methods</a></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-08-12 16:54:11 +03:00
<li><a href="#pcgrandom">PcgRandom</a><ul>
2017-02-19 16:15:50 +03:00
<li><a href="#methods_10">Methods</a></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-21 18:26:52 +03:00
<li><a href="#securerandom">SecureRandom</a><ul>
2017-02-19 16:15:50 +03:00
<li><a href="#methods_11">Methods</a></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-21 18:26:52 +03:00
<li><a href="#perlinnoise">PerlinNoise</a><ul>
2017-02-19 16:15:50 +03:00
<li><a href="#methods_12">Methods</a></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-21 18:26:52 +03:00
<li><a href="#perlinnoisemap">PerlinNoiseMap</a><ul>
2017-02-19 16:15:50 +03:00
<li><a href="#methods_13">Methods</a></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-21 18:26:52 +03:00
<li><a href="#voxelmanip">VoxelManip</a><ul>
<li><a href="#about-voxelmanip">About VoxelManip</a></li>
<li><a href="#using-voxelmanip">Using VoxelManip</a><ul>
<li><a href="#flat-array-format">Flat array format</a></li>
<li><a href="#content-ids">Content IDs</a></li>
<li><a href="#mapgen-voxelmanip-objects">Mapgen VoxelManip objects</a></li>
<li><a href="#other-api-functions-operating-on-a-voxelmanip">Other API functions operating on a VoxelManip</a></li>
<li><a href="#notes">Notes</a></li>
</ul>
</li>
2017-02-19 16:15:50 +03:00
<li><a href="#methods_14">Methods</a></li>
2015-04-29 20:17:32 +03:00
</ul>
</li>
2015-11-21 18:26:52 +03:00
<li><a href="#voxelarea">VoxelArea</a><ul>
2017-02-19 16:15:50 +03:00
<li><a href="#methods_15">Methods</a></li>
2015-08-12 16:54:11 +03:00
</ul>
</li>
2015-11-21 18:26:52 +03:00
<li><a href="#settings">Settings</a><ul>
2017-02-19 16:15:50 +03:00
<li><a href="#methods_16">Methods</a></li>
2015-11-21 18:26:52 +03:00
</ul>
</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
<li><a href="#mapgen-objects">Mapgen objects</a><ul>
<li><a href="#voxelmanip_1">voxelmanip</a></li>
<li><a href="#heightmap">heightmap</a></li>
<li><a href="#biomemap">biomemap</a></li>
<li><a href="#heatmap">heatmap</a></li>
<li><a href="#humiditymap">humiditymap</a></li>
<li><a href="#gennotify">gennotify</a></li>
</ul>
</li>
<li><a href="#registered-entities">Registered entities</a></li>
<li><a href="#l-system-trees">L-system trees</a><ul>
<li><a href="#tree-definition">Tree definition</a></li>
<li><a href="#key-for-special-l-system-symbols-used-in-axioms">Key for Special L-System Symbols used in Axioms</a></li>
<li><a href="#example_1">Example</a></li>
</ul>
</li>
<li><a href="#definition-tables">Definition tables</a><ul>
<li><a href="#object-properties">Object Properties</a></li>
<li><a href="#entity-definition-register_entity">Entity definition (register_entity)</a></li>
<li><a href="#abm-activeblockmodifier-definition-register_abm">ABM (ActiveBlockModifier) definition (register_abm)</a></li>
2016-03-19 17:25:33 +03:00
<li><a href="#lbm-loadingblockmodifier-definition-register_lbm">LBM (LoadingBlockModifier) definition (register_lbm)</a></li>
2014-12-28 22:55:14 +03:00
<li><a href="#item-definition-register_node-register_craftitem-register_tool">Item definition (register_node, register_craftitem, register_tool)</a></li>
<li><a href="#tile-definition">Tile definition</a></li>
<li><a href="#tile-animation-definition">Tile animation definition</a></li>
<li><a href="#node-definition-register_node">Node definition (register_node)</a></li>
<li><a href="#recipe-for-register_craft-shaped">Recipe for register_craft (shaped)</a></li>
<li><a href="#recipe-for-register_craft-shapeless">Recipe for register_craft (shapeless)</a></li>
<li><a href="#recipe-for-register_craft-tool-repair">Recipe for register_craft (tool repair)</a></li>
<li><a href="#recipe-for-register_craft-cooking">Recipe for register_craft (cooking)</a></li>
<li><a href="#recipe-for-register_craft-furnace-fuel">Recipe for register_craft (furnace fuel)</a></li>
<li><a href="#ore-definition-register_ore">Ore definition (register_ore)</a></li>
2015-12-07 21:04:11 +03:00
<li><a href="#biome-definition-register_biome">Biome definition (register_biome)</a></li>
2014-12-28 22:55:14 +03:00
<li><a href="#decoration-definition-register_decoration">Decoration definition (register_decoration)</a></li>
<li><a href="#chat-command-definition-register_chatcommand">Chat command definition (register_chatcommand)</a></li>
<li><a href="#detached-inventory-callbacks">Detached inventory callbacks</a></li>
<li><a href="#hud-definition-hud_add-hud_get">HUD Definition (hud_add, hud_get)</a></li>
<li><a href="#particle-definition-add_particle">Particle definition (add_particle)</a></li>
<li><a href="#particlespawner-definition-add_particlespawner">ParticleSpawner definition (add_particlespawner)</a></li>
2016-07-22 21:37:58 +03:00
<li><a href="#httprequest-definition-httpapitablefetch_async-httpapitablefetch_async">HTTPRequest definition (HTTPApiTable.fetch_async, HTTPApiTable.fetch_async)</a></li>
<li><a href="#httprequestresult-definition-httpapitablefetch-callback-httpapitablefetch_async_get">HTTPRequestResult definition (HTTPApiTable.fetch callback, HTTPApiTable.fetch_async_get)</a></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
</ul>
</div>
2014-12-28 22:55:14 +03:00
<h2 id="introduction">Introduction</h2>
2014-12-28 22:26:49 +03:00
<p>Content and functionality can be added to Minetest 0.4 by using Lua
scripting in run-time loaded mods.</p>
<p>A mod is a self-contained bunch of scripts, textures and other related
things that is loaded by and interfaces with Minetest.</p>
<p>Mods are contained and ran solely on the server side. Definitions and media
files are automatically transferred to the client.</p>
<p>If you see a deficiency in the API, feel free to attempt to add the
functionality in the engine and API. You can send such improvements as
2015-11-22 19:41:52 +03:00
source code patches to <a href="mailto:celeron55@gmail.com">celeron55@gmail.com</a>.</p>
<ul>
<li>More information at <a href="http://www.minetest.net/">http://www.minetest.net/</a></li>
<li>Developer Wiki: <a href="http://dev.minetest.net/">http://dev.minetest.net/</a></li>
2017-02-19 16:15:50 +03:00
</ul>This page was last updated 19/February/2017.<br/>See <a href="https://github.com/minetest/minetest/blob/master/doc/lua_api.txt">doc/lua_api.txt</a> for the latest version (in plaintext).<br/>Generated using <a href="https://github.com/rubenwardy/minetest_modding_book/blob/gh-pages/update_lua_api.py">a Python script</a>.<h2 id="programming-in-lua">Programming in Lua</h2>
2015-03-17 21:18:48 +03:00
<p>If you have any difficulty in understanding this, please read
<a href="http://www.lua.org/pil/">Programming in Lua</a>.</p>
2014-12-28 22:55:14 +03:00
<h2 id="startup">Startup</h2>
2014-12-28 22:26:49 +03:00
<p>Mods are loaded during server startup from the mod load paths by running
the <code>init.lua</code> scripts in a shared environment.</p>
2014-12-28 22:55:14 +03:00
<h2 id="paths">Paths</h2>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#RUN_IN_PLACE1" name="RUN_IN_PLACE1">#</a><code>RUN_IN_PLACE=1</code> (Windows release, local build)<ul>
<li><a class="anchor" href="#path_user" name="path_user">#</a><code>$path_user</code>:<ul>
<li><a class="anchor" href="#builddirectory" name="builddirectory">#</a>Linux: <code>&lt;build directory&gt;</code></li>
<li><a class="anchor" href="#builddirectory_1" name="builddirectory_1">#</a>Windows: <code>&lt;build directory&gt;</code></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#path_share" name="path_share">#</a><code>$path_share</code><ul>
<li><a class="anchor" href="#builddirectory_2" name="builddirectory_2">#</a>Linux: <code>&lt;build directory&gt;</code></li>
<li><a class="anchor" href="#builddirectory_3" name="builddirectory_3">#</a>Windows: <code>&lt;build directory&gt;</code></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#RUN_IN_PLACE0" name="RUN_IN_PLACE0">#</a><code>RUN_IN_PLACE=0</code>: (Linux release)<ul>
<li><a class="anchor" href="#path_share_1" name="path_share_1">#</a><code>$path_share</code><ul>
<li><a class="anchor" href="#usrshareminetest" name="usrshareminetest">#</a>Linux: <code>/usr/share/minetest</code></li>
<li><a class="anchor" href="#installdirectoryminetest04x" name="installdirectoryminetest04x">#</a>Windows: <code>&lt;install directory&gt;/minetest-0.4.x</code></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#path_user_1" name="path_user_1">#</a><code>$path_user</code>:<ul>
<li><a class="anchor" href="#HOMEminetest" name="HOMEminetest">#</a>Linux: <code>$HOME/.minetest</code></li>
<li><a class="anchor" href="#CusersuserAppDataminetest" name="CusersuserAppDataminetest">#</a>Windows: <code>C:/users/&lt;user&gt;/AppData/minetest</code> (maybe)</li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
</li>
</ul>
</li>
</ul>
<h2 id="games">Games</h2>
2014-12-28 22:26:49 +03:00
<p>Games are looked up from:</p>
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#path_sharegamesgameid" name="path_sharegamesgameid">#</a><code>$path_share/games/gameid/</code></li>
<li><a class="anchor" href="#path_usergamesgameid" name="path_usergamesgameid">#</a><code>$path_user/games/gameid/</code></li>
2014-12-28 22:26:49 +03:00
</ul>
<p>where <code>gameid</code> is unique to each game.</p>
<p>The game directory contains the file <code>game.conf</code>, which contains these fields:</p>
<pre><code>name = &lt;Human-readable full name of the game&gt;
</code></pre>
<p>e.g.</p>
<pre><code>name = Minetest
</code></pre>
<p>The game directory can contain the file minetest.conf, which will be used
2015-10-26 03:16:41 +03:00
to set default settings when running the particular game.
It can also contain a settingtypes.txt in the same format as the one in builtin.
2016-07-22 21:37:58 +03:00
This settingtypes.txt will be parsed by the menu and the settings will be displayed
in the "Games" category in the settings tab.</p>
2015-08-12 16:54:11 +03:00
<h3 id="menu-images">Menu images</h3>
2016-07-22 21:37:58 +03:00
<p>Games can provide custom main menu images. They are put inside a <code>menu</code> directory
inside the game directory.</p>
<p>The images are named <code>$identifier.png</code>, where <code>$identifier</code> is
one of <code>overlay,background,footer,header</code>.
If you want to specify multiple images for one identifier, add additional images named
like <code>$identifier.$n.png</code>, with an ascending number $n starting with 1, and a random
image will be chosen from the provided ones.</p>
2014-12-28 22:55:14 +03:00
<h2 id="mod-load-path">Mod load path</h2>
2014-12-28 22:26:49 +03:00
<p>Generic:</p>
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#path_sharegamesgameidmods" name="path_sharegamesgameidmods">#</a><code>$path_share/games/gameid/mods/</code></li>
<li><a class="anchor" href="#path_sharemods" name="path_sharemods">#</a><code>$path_share/mods/</code></li>
<li><a class="anchor" href="#path_usergamesgameidmods" name="path_usergamesgameidmods">#</a><code>$path_user/games/gameid/mods/</code></li>
<li><a class="anchor" href="#path_usermods" name="path_usermods">#</a><code>$path_user/mods/</code> (User-installed mods)</li>
<li><a class="anchor" href="#worldpathworldmods" name="worldpathworldmods">#</a><code>$worldpath/worldmods/</code></li>
2014-12-28 22:26:49 +03:00
</ul>
<p>In a run-in-place version (e.g. the distributed windows version):</p>
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetest04xgamesgameidmods" name="minetest04xgamesgameidmods">#</a><code>minetest-0.4.x/games/gameid/mods/</code></li>
<li><a class="anchor" href="#minetest04xmods" name="minetest04xmods">#</a><code>minetest-0.4.x/mods/</code> (User-installed mods)</li>
<li><a class="anchor" href="#minetest04xworldsworldnameworldmods" name="minetest04xworldsworldnameworldmods">#</a><code>minetest-0.4.x/worlds/worldname/worldmods/</code></li>
2014-12-28 22:26:49 +03:00
</ul>
<p>On an installed version on Linux:</p>
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#usrshareminetestgamesgameidmods" name="usrshareminetestgamesgameidmods">#</a><code>/usr/share/minetest/games/gameid/mods/</code></li>
<li><a class="anchor" href="#HOMEminetestmods" name="HOMEminetestmods">#</a><code>$HOME/.minetest/mods/</code> (User-installed mods)</li>
<li><a class="anchor" href="#HOMEminetestworldsworldnameworldmods" name="HOMEminetestworldsworldnameworldmods">#</a><code>$HOME/.minetest/worlds/worldname/worldmods</code></li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
<h2 id="mod-load-path-for-world-specific-games">Mod load path for world-specific games</h2>
2014-12-28 22:26:49 +03:00
<p>It is possible to include a game in a world; in this case, no mods or
games are loaded or checked from anywhere else.</p>
<p>This is useful for e.g. adventure worlds.</p>
<p>This happens if the following directory exists:</p>
<pre><code>$world/game/
</code></pre>
<p>Mods should be then be placed in:</p>
<pre><code>$world/game/mods/
</code></pre>
2014-12-28 22:55:14 +03:00
<h2 id="modpack-support">Modpack support</h2>
2014-12-28 22:26:49 +03:00
<p>Mods can be put in a subdirectory, if the parent directory, which otherwise
should be a mod, contains a file named <code>modpack.txt</code>. This file shall be
empty, except for lines starting with <code>#</code>, which are comments.</p>
2014-12-28 22:55:14 +03:00
<h2 id="mod-directory-structure">Mod directory structure</h2>
2014-12-28 22:26:49 +03:00
<pre><code>mods
|-- modname
| |-- depends.txt
| |-- screenshot.png
| |-- description.txt
2015-10-26 03:16:41 +03:00
| |-- settingtypes.txt
2014-12-28 22:26:49 +03:00
| |-- init.lua
| |-- models
| |-- textures
| | |-- modname_stuff.png
| | `-- modname_something_else.png
| |-- sounds
| |-- media
| `-- &lt;custom data&gt;
`-- another
</code></pre>
2014-12-28 22:55:14 +03:00
<h3 id="modname">modname</h3>
2014-12-28 22:26:49 +03:00
<p>The location of this directory can be fetched by using
<code>minetest.get_modpath(modname)</code>.</p>
2014-12-28 22:55:14 +03:00
<h3 id="dependstxt"><code>depends.txt</code></h3>
2014-12-28 22:26:49 +03:00
<p>List of mods that have to be loaded before loading this mod.</p>
<p>A single line contains a single modname.</p>
<p>Optional dependencies can be defined by appending a question mark
to a single modname. Their meaning is that if the specified mod
is missing, that does not prevent this mod from being loaded.</p>
2014-12-28 22:55:14 +03:00
<h3 id="screenshotpng"><code>screenshot.png</code></h3>
2016-08-29 15:43:46 +03:00
<p>A screenshot shown in the mod manager within the main menu. It should
have an aspect ratio of 3:2 and a minimum size of 300×200 pixels.</p>
2014-12-28 22:55:14 +03:00
<h3 id="descriptiontxt"><code>description.txt</code></h3>
2014-12-28 22:26:49 +03:00
<p>A File containing description to be shown within mainmenu.</p>
2015-10-26 03:16:41 +03:00
<h3 id="settingtypestxt"><code>settingtypes.txt</code></h3>
<p>A file in the same format as the one in builtin. It will be parsed by the
settings menu and the settings will be displayed in the "Mods" category.</p>
2014-12-28 22:55:14 +03:00
<h3 id="initlua"><code>init.lua</code></h3>
2014-12-28 22:26:49 +03:00
<p>The main Lua script. Running this script should register everything it
wants to register. Subsequent execution depends on minetest calling the
registered callbacks.</p>
<p><code>minetest.setting_get(name)</code> and <code>minetest.setting_getbool(name)</code> can be used
to read custom or existing settings at load time, if necessary.</p>
2014-12-28 22:55:14 +03:00
<h3 id="models"><code>models</code></h3>
2014-12-28 22:26:49 +03:00
<p>Models for entities or meshnodes.</p>
2014-12-28 22:55:14 +03:00
<h3 id="textures-sounds-media"><code>textures</code>, <code>sounds</code>, <code>media</code></h3>
2014-12-28 22:26:49 +03:00
<p>Media files (textures, sounds, whatever) that will be transferred to the
client and will be available for use by the mod.</p>
2014-12-28 22:55:14 +03:00
<h2 id="naming-convention-for-registered-textual-names">Naming convention for registered textual names</h2>
2014-12-28 22:26:49 +03:00
<p>Registered names should generally be in this format:</p>
<pre><code>"modname:&lt;whatever&gt;" (&lt;whatever&gt; can have characters a-zA-Z0-9_)
</code></pre>
<p>This is to prevent conflicting names from corrupting maps and is
enforced by the mod loader.</p>
2014-12-28 22:55:14 +03:00
<h3 id="example">Example</h3>
2014-12-28 22:26:49 +03:00
<p>In the mod <code>experimental</code>, there is the ideal item/node/entity name <code>tnt</code>.
So the name should be <code>experimental:tnt</code>.</p>
<p>Enforcement can be overridden by prefixing the name with <code>:</code>. This can
be used for overriding the registrations of some other mod.</p>
<p>Example: Any mod can redefine <code>experimental:tnt</code> by using the name</p>
<pre><code>:experimental:tnt
</code></pre>
<p>when registering it.
(also that mod is required to have <code>experimental</code> as a dependency)</p>
<p>The <code>:</code> prefix can also be used for maintaining backwards compatibility.</p>
2014-12-28 22:55:14 +03:00
<h3 id="aliases">Aliases</h3>
2016-11-12 19:27:07 +03:00
<p>Aliases can be added by using <code>minetest.register_alias(name, convert_to)</code> or
`minetest.register_alias_force(name, convert_to).</p>
2014-12-28 22:26:49 +03:00
<p>This will make Minetest to convert things called name to things called
<code>convert_to</code>.</p>
2016-11-12 19:27:07 +03:00
<p>The only difference between <code>minetest.register_alias</code> and
<code>minetest.register_alias_force</code> is that if an item called <code>name</code> exists,
<code>minetest.register_alias</code> will do nothing while
<code>minetest.register_alias_force</code> will unregister it.</p>
2014-12-28 22:26:49 +03:00
<p>This can be used for maintaining backwards compatibility.</p>
<p>This can be also used for setting quick access names for things, e.g. if
you have an item called <code>epiclylongmodname:stuff</code>, you could do</p>
<pre><code>minetest.register_alias("stuff", "epiclylongmodname:stuff")
</code></pre>
<p>and be able to use <code>/giveme stuff</code>.</p>
2014-12-28 22:55:14 +03:00
<h2 id="textures">Textures</h2>
2014-12-28 22:26:49 +03:00
<p>Mods should generally prefix their textures with <code>modname_</code>, e.g. given
the mod name <code>foomod</code>, a texture could be called:</p>
<pre><code>foomod_foothing.png
</code></pre>
<p>Textures are referred to by their complete name, or alternatively by
stripping out the file extension:</p>
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#foomod_foothingpng" name="foomod_foothingpng">#</a>e.g. <code>foomod_foothing.png</code></li>
<li><a class="anchor" href="#foomod_foothing" name="foomod_foothing">#</a>e.g. <code>foomod_foothing</code></li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
<h2 id="texture-modifiers">Texture modifiers</h2>
2014-12-28 22:26:49 +03:00
<p>There are various texture modifiers that can be used
to generate textures on-the-fly.</p>
2014-12-28 22:55:14 +03:00
<h3 id="texture-overlaying">Texture overlaying</h3>
2014-12-28 22:26:49 +03:00
<p>Textures can be overlaid by putting a <code>^</code> between them.</p>
<p>Example:</p>
<pre><code>default_dirt.png^default_grass_side.png
</code></pre>
2016-05-26 20:47:50 +03:00
<p><code>default_grass_side.png</code> is overlayed over <code>default_dirt.png</code>.
2016-07-22 21:37:58 +03:00
The texture with the lower resolution will be automatically upscaled to
the higher resolution texture.</p>
2014-12-28 22:55:14 +03:00
<h3 id="texture-grouping">Texture grouping</h3>
2014-12-28 22:26:49 +03:00
<p>Textures can be grouped together by enclosing them in <code>(</code> and <code>)</code>.</p>
<p>Example: <code>cobble.png^(thing1.png^thing2.png)</code></p>
<p>A texture for <code>thing1.png^thing2.png</code> is created and the resulting
2016-11-12 19:27:07 +03:00
texture is overlaid on top of <code>cobble.png</code>.</p>
<h3 id="escaping">Escaping</h3>
<p>Modifiers that accept texture names (e.g. <code>[combine</code>) accept escaping to allow
passing complex texture names as arguments. Escaping is done with backslash and
is required for <code>^</code> and <code>:</code>.</p>
<p>Example: <code>cobble.png^[lowpart:50:color.png\^[mask\:trans.png</code></p>
<p>The lower 50 percent of <code>color.png^[mask:trans.png</code> are overlaid
on top of <code>cobble.png</code>.</p>
2014-12-28 22:55:14 +03:00
<h3 id="advanced-texture-modifiers">Advanced texture modifiers</h3>
<h4 id="cracknp"><code>[crack:&lt;n&gt;:&lt;p&gt;</code></h4>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#n" name="n">#</a><code>&lt;n&gt;</code> = animation frame count</li>
<li><a class="anchor" href="#p" name="p">#</a><code>&lt;p&gt;</code> = current animation frame</li>
2014-12-28 22:26:49 +03:00
</ul>
<p>Draw a step of the crack animation on the texture.</p>
<p>Example:</p>
<pre><code>default_cobble.png^[crack:10:1
</code></pre>
2016-03-19 17:25:33 +03:00
<h4 id="combinewxhx1y1file1x2y2file2"><code>[combine:&lt;w&gt;x&lt;h&gt;:&lt;x1&gt;,&lt;y1&gt;=&lt;file1&gt;:&lt;x2&gt;,&lt;y2&gt;=&lt;file2&gt;:...</code></h4>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#w" name="w">#</a><code>&lt;w&gt;</code> = width</li>
<li><a class="anchor" href="#h" name="h">#</a><code>&lt;h&gt;</code> = height</li>
2016-03-19 17:25:33 +03:00
<li><a class="anchor" href="#x" name="x">#</a><code>&lt;x&gt;</code> = x position</li>
<li><a class="anchor" href="#y" name="y">#</a><code>&lt;y&gt;</code> = y position</li>
<li><a class="anchor" href="#file" name="file">#</a><code>&lt;file&gt;</code> = texture to combine</li>
2014-12-28 22:26:49 +03:00
</ul>
2016-03-19 17:25:33 +03:00
<p>Creates a texture of size <code>&lt;w&gt;</code> times <code>&lt;h&gt;</code> and blits the listed files to their
specified coordinates.</p>
2014-12-28 22:26:49 +03:00
<p>Example:</p>
<pre><code>[combine:16x32:0,0=default_cobble.png:0,16=default_wood.png
</code></pre>
2016-05-26 20:47:50 +03:00
<h4 id="resizewxh"><code>[resize:&lt;w&gt;x&lt;h&gt;</code></h4>
<p>Resizes the texture to the given dimensions.</p>
<p>Example:</p>
<pre><code>default_sandstone.png^[resize:16x16
</code></pre>
2016-08-29 15:43:46 +03:00
<h4 id="opacityr"><code>[opacity:&lt;r&gt;</code></h4>
<pre><code>Makes the base image transparent according to the given ratio.
r must be between 0 and 255.
0 means totally transparent.
255 means totally opaque.
</code></pre>
<p>Example:</p>
<pre><code>default_sandstone.png^[opacity:127
</code></pre>
2016-11-12 19:27:07 +03:00
<h4 id="invertmode"><code>[invert:&lt;mode&gt;</code></h4>
<p>Inverts the given channels of the base image.
Mode may contain the characters "r", "g", "b", "a".
Only the channels that are mentioned in the mode string will be inverted.</p>
<p>Example:</p>
<pre><code>default_apple.png^[invert:rgb
</code></pre>
2014-12-28 22:55:14 +03:00
<h4 id="brighten"><code>[brighten</code></h4>
2014-12-28 22:26:49 +03:00
<p>Brightens the texture.</p>
<p>Example:</p>
<pre><code>tnt_tnt_side.png^[brighten
</code></pre>
2014-12-28 22:55:14 +03:00
<h4 id="noalpha"><code>[noalpha</code></h4>
2014-12-28 22:26:49 +03:00
<p>Makes the texture completely opaque.</p>
<p>Example:</p>
<pre><code>default_leaves.png^[noalpha
</code></pre>
2014-12-28 22:55:14 +03:00
<h4 id="makealphargb"><code>[makealpha:&lt;r&gt;,&lt;g&gt;,&lt;b&gt;</code></h4>
2014-12-28 22:26:49 +03:00
<p>Convert one color to transparency.</p>
<p>Example:</p>
<pre><code>default_cobble.png^[makealpha:128,128,128
</code></pre>
2014-12-28 22:55:14 +03:00
<h4 id="transformt"><code>[transform&lt;t&gt;</code></h4>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#t" name="t">#</a><code>&lt;t&gt;</code> = transformation(s) to apply</li>
2014-12-28 22:26:49 +03:00
</ul>
<p>Rotates and/or flips the image.</p>
<p><code>&lt;t&gt;</code> can be a number (between 0 and 7) or a transform name.
Rotations are counter-clockwise.</p>
<pre><code>0 I identity
1 R90 rotate by 90 degrees
2 R180 rotate by 180 degrees
3 R270 rotate by 270 degrees
4 FX flip X
5 FXR90 flip X then rotate by 90 degrees
6 FY flip Y
7 FYR90 flip Y then rotate by 90 degrees
</code></pre>
<p>Example:</p>
<pre><code>default_stone.png^[transformFXR90
</code></pre>
2014-12-28 22:55:14 +03:00
<h4 id="inventorycubetopleftright"><code>[inventorycube{&lt;top&gt;{&lt;left&gt;{&lt;right&gt;</code></h4>
2016-11-12 19:27:07 +03:00
<p>Escaping does not apply here and <code>^</code> is replaced by <code>&amp;</code> in texture names instead.</p>
2014-12-28 22:26:49 +03:00
<p>Create an inventory cube texture using the side textures.</p>
<p>Example:</p>
<pre><code>[inventorycube{grass.png{dirt.png&amp;grass_side.png{dirt.png&amp;grass_side.png
</code></pre>
<p>Creates an inventorycube with <code>grass.png</code>, <code>dirt.png^grass_side.png</code> and
<code>dirt.png^grass_side.png</code> textures</p>
2014-12-28 22:55:14 +03:00
<h4 id="lowpartpercentfile"><code>[lowpart:&lt;percent&gt;:&lt;file&gt;</code></h4>
2014-12-28 22:26:49 +03:00
<p>Blit the lower <code>&lt;percent&gt;</code>% part of <code>&lt;file&gt;</code> on the texture.</p>
<p>Example:</p>
<pre><code>base.png^[lowpart:25:overlay.png
</code></pre>
2014-12-28 22:55:14 +03:00
<h4 id="verticalframetn"><code>[verticalframe:&lt;t&gt;:&lt;n&gt;</code></h4>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#t_1" name="t_1">#</a><code>&lt;t&gt;</code> = animation frame count</li>
<li><a class="anchor" href="#n_1" name="n_1">#</a><code>&lt;n&gt;</code> = current animation frame</li>
2014-12-28 22:26:49 +03:00
</ul>
<p>Crops the texture to a frame of a vertical animation.</p>
<p>Example:</p>
<pre><code>default_torch_animated.png^[verticalframe:16:8
</code></pre>
2014-12-28 22:55:14 +03:00
<h4 id="maskfile"><code>[mask:&lt;file&gt;</code></h4>
2014-12-28 22:26:49 +03:00
<p>Apply a mask to the base image.</p>
<p>The mask is applied using binary AND.</p>
2017-01-31 17:21:12 +03:00
<h4 id="sheetwxhxy"><code>[sheet:&lt;w&gt;x&lt;h&gt;:&lt;x&gt;,&lt;y&gt;</code></h4>
<p>Retrieves a tile at position x,y from the base image
which it assumes to be a tilesheet with dimensions w,h.</p>
2015-01-24 22:07:00 +03:00
<h4 id="colorizecolorratio"><code>[colorize:&lt;color&gt;:&lt;ratio&gt;</code></h4>
2014-12-28 22:26:49 +03:00
<p>Colorize the textures with the given color.
2015-01-24 22:07:00 +03:00
<code>&lt;color&gt;</code> is specified as a <code>ColorString</code>.
2016-04-09 16:27:30 +03:00
<code>&lt;ratio&gt;</code> is an int ranging from 0 to 255 or the word "<code>alpha</code>". If
it is an int, then it specifies how far to interpolate between the
colors where 0 is only the texture color and 255 is only <code>&lt;color&gt;</code>. If
omitted, the alpha of <code>&lt;color&gt;</code> will be used as the ratio. If it is
the word "<code>alpha</code>", then each texture pixel will contain the RGB of
<code>&lt;color&gt;</code> and the alpha of <code>&lt;color&gt;</code> multiplied by the alpha of the
texture pixel.</p>
2017-01-31 17:21:12 +03:00
<h4 id="multiplycolor"><code>[multiply:&lt;color&gt;</code></h4>
<p>Multiplies texture colors with the given color.
<code>&lt;color&gt;</code> is specified as a <code>ColorString</code>.
Result is more like what you'd expect if you put a color on top of another
color. Meaning white surfaces get a lot of your new color while black parts don't
change very much.</p>
2014-12-28 22:55:14 +03:00
<h2 id="sounds">Sounds</h2>
2014-12-28 22:26:49 +03:00
<p>Only Ogg Vorbis files are supported.</p>
<p>For positional playing of sounds, only single-channel (mono) files are
supported. Otherwise OpenAL will play them non-positionally.</p>
<p>Mods should generally prefix their sounds with <code>modname_</code>, e.g. given
the mod name "<code>foomod</code>", a sound could be called:</p>
<pre><code>foomod_foosound.ogg
</code></pre>
<p>Sounds are referred to by their name with a dot, a single digit and the
file extension stripped out. When a sound is played, the actual sound file
is chosen randomly from the matching sounds.</p>
<p>When playing the sound <code>foomod_foosound</code>, the sound is chosen randomly
from the available ones of the following files:</p>
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#foomod_foosoundogg" name="foomod_foosoundogg">#</a><code>foomod_foosound.ogg</code></li>
<li><a class="anchor" href="#foomod_foosound0ogg" name="foomod_foosound0ogg">#</a><code>foomod_foosound.0.ogg</code></li>
<li><a class="anchor" href="#foomod_foosound1ogg" name="foomod_foosound1ogg">#</a><code>foomod_foosound.1.ogg</code></li>
2014-12-28 22:26:49 +03:00
<li>(...)</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#foomod_foosound9ogg" name="foomod_foosound9ogg">#</a><code>foomod_foosound.9.ogg</code></li>
2014-12-28 22:26:49 +03:00
</ul>
<p>Examples of sound parameter tables:</p>
2016-12-29 00:57:48 +03:00
<pre><code>-- Play locationless on all clients
2014-12-28 22:26:49 +03:00
{
gain = 1.0, -- default
}
2016-12-29 00:57:48 +03:00
-- Play locationless to one player
2014-12-28 22:26:49 +03:00
{
to_player = name,
gain = 1.0, -- default
}
2016-12-29 00:57:48 +03:00
-- Play locationless to one player, looped
{
to_player = name,
gain = 1.0, -- default
loop = true,
}
2014-12-28 22:26:49 +03:00
-- Play in a location
{
2016-12-29 00:57:48 +03:00
pos = {x = 1, y = 2, z = 3},
2014-12-28 22:26:49 +03:00
gain = 1.0, -- default
2015-10-26 03:16:41 +03:00
max_hear_distance = 32, -- default, uses an euclidean metric
2014-12-28 22:26:49 +03:00
}
-- Play connected to an object, looped
{
object = &lt;an ObjectRef&gt;,
gain = 1.0, -- default
2015-10-26 03:16:41 +03:00
max_hear_distance = 32, -- default, uses an euclidean metric
2016-12-29 00:57:48 +03:00
loop = true,
2014-12-28 22:26:49 +03:00
}
</code></pre>
2016-12-29 00:57:48 +03:00
<p>Looped sounds must either be connected to an object or played locationless to
one player using <code>to_player = name,</code></p>
2014-12-28 22:55:14 +03:00
<h3 id="simplesoundspec"><code>SimpleSoundSpec</code></h3>
2014-12-28 22:26:49 +03:00
<ul>
<li>e.g. <code>""</code></li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#default_place_node" name="default_place_node">#</a>e.g. <code>"default_place_node"</code></li>
2014-12-28 22:26:49 +03:00
<li>e.g. <code>{}</code></li>
2016-12-29 00:57:48 +03:00
<li><a class="anchor" href="#namedefault_place_node" name="namedefault_place_node">#</a>e.g. <code>{name = "default_place_node"}</code></li>
<li><a class="anchor" href="#namedefault_place_nodegain10" name="namedefault_place_nodegain10">#</a>e.g. <code>{name = "default_place_node", gain = 1.0}</code></li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
<h2 id="registered-definitions-of-stuff">Registered definitions of stuff</h2>
2014-12-28 22:26:49 +03:00
<p>Anything added using certain <code>minetest.register_*</code> functions get added to
the global <code>minetest.registered_*</code> tables.</p>
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestregister_entitynameprototypetable" name="minetestregister_entitynameprototypetable">#</a>
2014-12-28 22:55:14 +03:00
<p><code>minetest.register_entity(name, prototype table)</code></p>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestregistered_entitiesname" name="minetestregistered_entitiesname">#</a>added to <code>minetest.registered_entities[name]</code></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestregister_nodenamenodedefinition" name="minetestregister_nodenamenodedefinition">#</a>
2014-12-28 22:55:14 +03:00
<p><code>minetest.register_node(name, node definition)</code></p>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestregistered_itemsname" name="minetestregistered_itemsname">#</a>added to <code>minetest.registered_items[name]</code></li>
<li><a class="anchor" href="#minetestregistered_nodesname" name="minetestregistered_nodesname">#</a>added to <code>minetest.registered_nodes[name]</code></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestregister_toolnameitemdefinition" name="minetestregister_toolnameitemdefinition">#</a>
2014-12-28 22:55:14 +03:00
<p><code>minetest.register_tool(name, item definition)</code></p>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestregistered_itemsname_1" name="minetestregistered_itemsname_1">#</a>added to <code>minetest.registered_items[name]</code></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestregister_craftitemnameitemdefinition" name="minetestregister_craftitemnameitemdefinition">#</a>
2014-12-28 22:55:14 +03:00
<p><code>minetest.register_craftitem(name, item definition)</code></p>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestregistered_itemsname_2" name="minetestregistered_itemsname_2">#</a>added to <code>minetest.registered_items[name]</code></li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
</li>
2016-11-12 19:27:07 +03:00
<li><a class="anchor" href="#minetestunregister_itemname" name="minetestunregister_itemname">#</a>
<p><code>minetest.unregister_item(name)</code></p>
<ul>
<li>Unregisters the item name from engine, and deletes the entry with key</li>
<li><a class="anchor" href="#name" name="name">#</a><code>name</code> from <code>minetest.registered_items</code> and from the associated item</li>
<li>table according to its nature: minetest.registered_nodes[] etc</li>
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestregister_biomebiomedefinition" name="minetestregister_biomebiomedefinition">#</a>
2015-04-29 20:17:32 +03:00
<p><code>minetest.register_biome(biome definition)</code></p>
<ul>
<li>returns an integer uniquely identifying the registered biome</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestregistered_biome" name="minetestregistered_biome">#</a>added to <code>minetest.registered_biome</code> with the key of <code>biome.name</code></li>
<li><a class="anchor" href="#biomename" name="biomename">#</a>if <code>biome.name</code> is nil, the key is the returned ID</li>
2015-04-29 20:17:32 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestregister_oreoredefinition" name="minetestregister_oreoredefinition">#</a>
2015-01-09 21:54:25 +03:00
<p><code>minetest.register_ore(ore definition)</code></p>
<ul>
2015-01-24 22:07:00 +03:00
<li>returns an integer uniquely identifying the registered ore</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestregistered_ores" name="minetestregistered_ores">#</a>added to <code>minetest.registered_ores</code> with the key of <code>ore.name</code></li>
<li><a class="anchor" href="#orename" name="orename">#</a>if <code>ore.name</code> is nil, the key is the returned ID</li>
2015-01-09 21:54:25 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestregister_decorationdecorationdefinition" name="minetestregister_decorationdecorationdefinition">#</a>
2015-01-09 21:54:25 +03:00
<p><code>minetest.register_decoration(decoration definition)</code></p>
<ul>
2015-01-24 22:07:00 +03:00
<li>returns an integer uniquely identifying the registered decoration</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestregistered_decorations" name="minetestregistered_decorations">#</a>added to <code>minetest.registered_decorations</code> with the key of <code>decoration.name</code></li>
<li><a class="anchor" href="#decorationname" name="decorationname">#</a>if <code>decoration.name</code> is nil, the key is the returned ID</li>
2015-01-09 21:54:25 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestregister_schematicschematicdefinition" name="minetestregister_schematicschematicdefinition">#</a>
2015-04-29 20:17:32 +03:00
<p><code>minetest.register_schematic(schematic definition)</code></p>
<ul>
<li>returns an integer uniquely identifying the registered schematic</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestregistered_schematic" name="minetestregistered_schematic">#</a>added to <code>minetest.registered_schematic</code> with the key of <code>schematic.name</code></li>
<li><a class="anchor" href="#schematicname" name="schematicname">#</a>if <code>schematic.name</code> is nil, the key is the returned ID</li>
2015-04-29 20:17:32 +03:00
<li>if the schematic is loaded from a file, schematic.name is set to the filename</li>
2016-07-22 21:37:58 +03:00
<li>if the function is called when loading the mod, and schematic.name is a relative
path, then the current mod path will be prepended to the schematic filename</li>
2015-04-29 20:17:32 +03:00
</ul>
2015-01-24 22:07:00 +03:00
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestclear_registered_biomes" name="minetestclear_registered_biomes">#</a>
2015-04-29 20:17:32 +03:00
<p><code>minetest.clear_registered_biomes()</code></p>
<ul>
<li>clears all biomes currently registered</li>
</ul>
2015-01-24 22:07:00 +03:00
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestclear_registered_ores" name="minetestclear_registered_ores">#</a>
2015-04-29 20:17:32 +03:00
<p><code>minetest.clear_registered_ores()</code></p>
<ul>
<li>clears all ores currently registered</li>
</ul>
2015-01-24 22:07:00 +03:00
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestclear_registered_decorations" name="minetestclear_registered_decorations">#</a>
2015-04-29 20:17:32 +03:00
<p><code>minetest.clear_registered_decorations()</code></p>
<ul>
2015-01-24 22:07:00 +03:00
<li>clears all decorations currently registered</li>
2014-12-28 22:55:14 +03:00
</ul>
2015-04-29 20:17:32 +03:00
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestclear_registered_schematics" name="minetestclear_registered_schematics">#</a>
2015-04-29 20:17:32 +03:00
<p><code>minetest.clear_registered_schematics()</code></p>
<ul>
<li>clears all schematics currently registered</li>
</ul>
</li>
</ul>
2014-12-28 22:26:49 +03:00
<p>Note that in some cases you will stumble upon things that are not contained
in these tables (e.g. when a mod has been removed). Always check for
existence before trying to access the fields.</p>
<p>Example: If you want to check the drawtype of a node, you could do:</p>
<pre><code>local function get_nodedef_field(nodename, fieldname)
if not minetest.registered_nodes[nodename] then
return nil
end
return minetest.registered_nodes[nodename][fieldname]
end
local drawtype = get_nodedef_field(nodename, "drawtype")
</code></pre>
<p>Example: <code>minetest.get_item_group(name, group)</code> has been implemented as:</p>
<pre><code>function minetest.get_item_group(name, group)
if not minetest.registered_items[name] or not
minetest.registered_items[name].groups[group] then
return 0
end
return minetest.registered_items[name].groups[group]
end
</code></pre>
2014-12-28 22:55:14 +03:00
<h2 id="nodes">Nodes</h2>
2014-12-28 22:26:49 +03:00
<p>Nodes are the bulk data of the world: cubes and other things that take the
space of a cube. Huge amounts of them are handled efficiently, but they
are quite static.</p>
<p>The definition of a node is stored and can be accessed by name in</p>
<pre><code>minetest.registered_nodes[node.name]
</code></pre>
<p>See "Registered definitions of stuff".</p>
<p>Nodes are passed by value between Lua and the engine.
They are represented by a table:</p>
<pre><code>{name="name", param1=num, param2=num}
</code></pre>
<p><code>param1</code> and <code>param2</code> are 8-bit integers. The engine uses them for certain
automated functions. If you don't use these functions, you can use them to
store arbitrary values.</p>
<p>The functions of <code>param1</code> and <code>param2</code> are determined by certain fields in the
node definition:</p>
<p><code>param1</code> is reserved for the engine when <code>paramtype != "none"</code>:</p>
<pre><code>paramtype = "light"
2015-01-24 22:07:00 +03:00
^ The value stores light with and without sun in its upper and lower 4 bits
respectively. Allows light to propagate from or through the node with
light value falling by 1 per node. This is essential for a light source
node to spread its light.
2014-12-28 22:26:49 +03:00
</code></pre>
<p><code>param2</code> is reserved for the engine when any of these are used:</p>
<pre><code>liquidtype == "flowing"
^ The level and some flags of the liquid is stored in param2
drawtype == "flowingliquid"
^ The drawn liquid level is read from param2
drawtype == "torchlike"
drawtype == "signlike"
paramtype2 == "wallmounted"
^ The rotation of the node is stored in param2. You can make this value
by using minetest.dir_to_wallmounted().
paramtype2 == "facedir"
^ The rotation of the node is stored in param2. Furnaces and chests are
rotated this way. Can be made by using minetest.dir_to_facedir().
Values range 0 - 23
2016-05-26 20:47:50 +03:00
facedir / 4 = axis direction:
2014-12-28 22:26:49 +03:00
0 = y+ 1 = z+ 2 = z- 3 = x+ 4 = x- 5 = y-
2016-05-26 20:47:50 +03:00
facedir modulo 4 = rotation around that axis
2014-12-28 22:26:49 +03:00
paramtype2 == "leveled"
2015-10-26 03:16:41 +03:00
paramtype2 == "degrotate"
^ The rotation of this node is stored in param2. Plants are rotated this way.
Values range 0 - 179. The value stored in param2 is multiplied by two to
get the actual rotation of the node.
2016-08-29 15:43:46 +03:00
paramtype2 == "meshoptions"
^ Only valid for "plantlike". The value of param2 becomes a bitfield which can
be used to change how the client draws plantlike nodes. Bits 0, 1 and 2 form
a mesh selector. Currently the following meshes are choosable:
0 = a "x" shaped plant (ordinary plant)
1 = a "+" shaped plant (just rotated 45 degrees)
2 = a "*" shaped plant with 3 faces instead of 2
3 = a "#" shaped plant with 4 faces instead of 2
4 = a "#" shaped plant with 4 faces that lean outwards
5-7 are unused and reserved for future meshes.
Bits 3 through 7 are optional flags that can be combined and give these
effects:
bit 3 (0x08) - Makes the plant slightly vary placement horizontally
bit 4 (0x10) - Makes the plant mesh 1.4x larger
bit 5 (0x20) - Moves each face randomly a small bit down (1/8 max)
bits 6-7 are reserved for future use.
2017-01-31 17:21:12 +03:00
paramtype2 == "color"
^ `param2` tells which color is picked from the palette.
The palette should have 256 pixels.
paramtype2 == "colorfacedir"
^ Same as `facedir`, but with colors.
The first three bits of `param2` tells which color
is picked from the palette.
The palette should have 8 pixels.
paramtype2 == "colorwallmounted"
^ Same as `wallmounted`, but with colors.
The first five bits of `param2` tells which color
is picked from the palette.
The palette should have 32 pixels.
2014-12-28 22:26:49 +03:00
collision_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
},
},
^ defines list of collision boxes for the node. If empty, collision boxes
will be the same as nodeboxes, in case of any other nodes will be full cube
as in the example above.
</code></pre>
<p>Nodes can also contain extra data. See "Node Metadata".</p>
2014-12-28 22:55:14 +03:00
<h2 id="node-drawtypes">Node drawtypes</h2>
2014-12-28 22:26:49 +03:00
<p>There are a bunch of different looking node types.</p>
<p>Look for examples in <code>games/minimal</code> or <code>games/minetest_game</code>.</p>
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#normal" name="normal">#</a><code>normal</code></li>
<li><a class="anchor" href="#airlike" name="airlike">#</a><code>airlike</code></li>
<li><a class="anchor" href="#liquid" name="liquid">#</a><code>liquid</code></li>
<li><a class="anchor" href="#flowingliquid" name="flowingliquid">#</a><code>flowingliquid</code></li>
<li><a class="anchor" href="#glasslike" name="glasslike">#</a><code>glasslike</code></li>
<li><a class="anchor" href="#glasslike_framed" name="glasslike_framed">#</a><code>glasslike_framed</code></li>
<li><a class="anchor" href="#glasslike_framed_optional" name="glasslike_framed_optional">#</a><code>glasslike_framed_optional</code></li>
<li><a class="anchor" href="#allfaces" name="allfaces">#</a><code>allfaces</code></li>
<li><a class="anchor" href="#allfaces_optional" name="allfaces_optional">#</a><code>allfaces_optional</code></li>
<li><a class="anchor" href="#torchlike" name="torchlike">#</a><code>torchlike</code></li>
<li><a class="anchor" href="#signlike" name="signlike">#</a><code>signlike</code></li>
<li><a class="anchor" href="#plantlike" name="plantlike">#</a><code>plantlike</code></li>
<li><a class="anchor" href="#firelike" name="firelike">#</a><code>firelike</code></li>
<li><a class="anchor" href="#fencelike" name="fencelike">#</a><code>fencelike</code></li>
<li><a class="anchor" href="#raillike" name="raillike">#</a><code>raillike</code></li>
<li><a class="anchor" href="#nodebox" name="nodebox">#</a><code>nodebox</code> -- See below. (<strong>Experimental!</strong>)</li>
<li><a class="anchor" href="#mesh" name="mesh">#</a><code>mesh</code> -- use models for nodes</li>
2014-12-28 22:26:49 +03:00
</ul>
<p><code>*_optional</code> drawtypes need less rendering time if deactivated (always client side).</p>
2014-12-28 22:55:14 +03:00
<h2 id="node-boxes">Node boxes</h2>
2014-12-28 22:26:49 +03:00
<p>Node selection boxes are defined using "node boxes"</p>
<p>The <code>nodebox</code> node drawtype allows defining visual of nodes consisting of
arbitrary number of boxes. It allows defining stuff like stairs. Only the
<code>fixed</code> and <code>leveled</code> box type is supported for these.</p>
<p>Please note that this is still experimental, and may be incompatibly
changed in the future.</p>
<p>A nodebox is defined as any of:</p>
<pre><code>{
-- A normal cube; the default in most things
type = "regular"
}
{
-- A fixed box (facedir param2 is used, if applicable)
type = "fixed",
fixed = box OR {box1, box2, ...}
}
{
-- A box like the selection box for torches
-- (wallmounted param2 is used, if applicable)
type = "wallmounted",
wall_top = box,
wall_bottom = box,
wall_side = box
}
2016-03-19 17:25:33 +03:00
{
-- A node that has optional boxes depending on neighbouring nodes'
-- presence and type. See also `connects_to`.
type = "connected",
fixed = box OR {box1, box2, ...}
connect_top = box OR {box1, box2, ...}
connect_bottom = box OR {box1, box2, ...}
connect_front = box OR {box1, box2, ...}
connect_left = box OR {box1, box2, ...}
connect_back = box OR {box1, box2, ...}
connect_right = box OR {box1, box2, ...}
}
2014-12-28 22:26:49 +03:00
</code></pre>
<p>A <code>box</code> is defined as:</p>
<pre><code>{x1, y1, z1, x2, y2, z2}
</code></pre>
<p>A box of a regular node would look like:</p>
<pre><code>{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
</code></pre>
<p><code>type = "leveled"</code> is same as <code>type = "fixed"</code>, but <code>y2</code> will be automatically
set to level from <code>param2</code>.</p>
2014-12-28 22:55:14 +03:00
<h2 id="meshes">Meshes</h2>
2014-12-28 22:26:49 +03:00
<p>If drawtype <code>mesh</code> is used, tiles should hold model materials textures.
2015-02-16 20:35:00 +03:00
Only static meshes are implemented.
2014-12-28 22:26:49 +03:00
For supported model formats see Irrlicht engine documentation.</p>
2014-12-28 22:55:14 +03:00
<h2 id="noise-parameters">Noise Parameters</h2>
2015-03-17 21:18:48 +03:00
<p>Noise Parameters, or commonly called "<code>NoiseParams</code>", define the properties of
perlin noise.</p>
2014-12-28 22:55:14 +03:00
<h3 id="offset"><code>offset</code></h3>
2014-12-28 22:26:49 +03:00
<p>Offset that the noise is translated by (i.e. added) after calculation.</p>
2014-12-28 22:55:14 +03:00
<h3 id="scale"><code>scale</code></h3>
2014-12-28 22:26:49 +03:00
<p>Factor that the noise is scaled by (i.e. multiplied) after calculation.</p>
2014-12-28 22:55:14 +03:00
<h3 id="spread"><code>spread</code></h3>
2014-12-28 22:26:49 +03:00
<p>Vector containing values by which each coordinate is divided by before calculation.
Higher spread values result in larger noise features.</p>
<p>A value of <code>{x=250, y=250, z=250}</code> is common.</p>
2014-12-28 22:55:14 +03:00
<h3 id="seed"><code>seed</code></h3>
2014-12-28 22:26:49 +03:00
<p>Random seed for the noise. Add the world seed to a seed offset for world-unique noise.
In the case of <code>minetest.get_perlin()</code>, this value has the world seed automatically added.</p>
2014-12-28 22:55:14 +03:00
<h3 id="octaves"><code>octaves</code></h3>
2014-12-28 22:26:49 +03:00
<p>Number of times the noise gradient is accumulated into the noise.</p>
<p>Increase this number to increase the amount of detail in the resulting noise.</p>
<p>A value of <code>6</code> is common.</p>
2014-12-28 22:55:14 +03:00
<h3 id="persistence"><code>persistence</code></h3>
2014-12-28 22:26:49 +03:00
<p>Factor by which the effect of the noise gradient function changes with each successive octave.</p>
<p>Values less than <code>1</code> make the details of successive octaves' noise diminish, while values
greater than <code>1</code> make successive octaves stronger.</p>
<p>A value of <code>0.6</code> is common.</p>
2014-12-28 22:55:14 +03:00
<h3 id="lacunarity"><code>lacunarity</code></h3>
2014-12-28 22:26:49 +03:00
<p>Factor by which the noise feature sizes change with each successive octave.</p>
<p>A value of <code>2.0</code> is common.</p>
2014-12-28 22:55:14 +03:00
<h3 id="flags"><code>flags</code></h3>
2014-12-28 22:26:49 +03:00
<p>Leave this field unset for no special handling.</p>
<p>Currently supported are <code>defaults</code>, <code>eased</code> and <code>absvalue</code>.</p>
2014-12-28 22:55:14 +03:00
<h4 id="defaults"><code>defaults</code></h4>
2014-12-28 22:26:49 +03:00
<p>Specify this if you would like to keep auto-selection of eased/not-eased while specifying
some other flags.</p>
2014-12-28 22:55:14 +03:00
<h4 id="eased"><code>eased</code></h4>
2014-12-28 22:26:49 +03:00
<p>Maps noise gradient values onto a quintic S-curve before performing interpolation.
This results in smooth, rolling noise. Disable this (<code>noeased</code>) for sharp-looking noise.
If no flags are specified (or defaults is), 2D noise is eased and 3D noise is not eased.</p>
2014-12-28 22:55:14 +03:00
<h4 id="absvalue"><code>absvalue</code></h4>
2014-12-28 22:26:49 +03:00
<p>Accumulates the absolute value of each noise gradient result.</p>
<p>Noise parameters format example for 2D or 3D perlin noise or perlin noise maps:
np_terrain = {
offset = 0,
scale = 1,
spread = {x=500, y=500, z=500},
seed = 571347,
octaves = 5,
persist = 0.63,
lacunarity = 2.0,
flags = "defaults, absvalue"
}
^ A single noise parameter table can be used to get 2D or 3D noise,
when getting 2D noise spread.z is ignored.</p>
2014-12-28 22:55:14 +03:00
<h2 id="ore-types">Ore types</h2>
2014-12-28 22:26:49 +03:00
<p>These tell in what manner the ore is generated.</p>
<p>All default ores are of the uniformly-distributed scatter type.</p>
2014-12-28 22:55:14 +03:00
<h3 id="scatter"><code>scatter</code></h3>
2014-12-28 22:26:49 +03:00
<p>Randomly chooses a location and generates a cluster of ore.</p>
<p>If <code>noise_params</code> is specified, the ore will be placed if the 3D perlin noise at
2015-03-17 21:18:48 +03:00
that point is greater than the <code>noise_threshold</code>, giving the ability to create
a non-equal distribution of ore.</p>
2014-12-28 22:55:14 +03:00
<h3 id="sheet"><code>sheet</code></h3>
2015-03-17 21:18:48 +03:00
<p>Creates a sheet of ore in a blob shape according to the 2D perlin noise
2015-09-25 02:24:04 +03:00
described by <code>noise_params</code> and <code>noise_threshold</code>. This is essentially an
improved version of the so-called "stratus" ore seen in some unofficial mods.</p>
<p>This sheet consists of vertical columns of uniform randomly distributed height,
varying between the inclusive range <code>column_height_min</code> and <code>column_height_max</code>.
If <code>column_height_min</code> is not specified, this parameter defaults to 1.
If <code>column_height_max</code> is not specified, this parameter defaults to <code>clust_size</code>
for reverse compatibility. New code should prefer <code>column_height_max</code>.</p>
<p>The <code>column_midpoint_factor</code> parameter controls the position of the column at which
ore eminates from. If 1, columns grow upward. If 0, columns grow downward. If 0.5,
columns grow equally starting from each direction. <code>column_midpoint_factor</code> is a
decimal number ranging in value from 0 to 1. If this parameter is not specified,
the default is 0.5.</p>
<p>The ore parameters <code>clust_scarcity</code> and <code>clust_num_ores</code> are ignored for this ore type.</p>
<h3 id="puff"><code>puff</code></h3>
<p>Creates a sheet of ore in a cloud-like puff shape.</p>
<p>As with the <code>sheet</code> ore type, the size and shape of puffs are described by
<code>noise_params</code> and <code>noise_threshold</code> and are placed at random vertical positions
within the currently generated chunk.</p>
<p>The vertical top and bottom displacement of each puff are determined by the noise
parameters <code>np_puff_top</code> and <code>np_puff_bottom</code>, respectively.</p>
<h3 id="blob"><code>blob</code></h3>
2015-02-16 20:35:00 +03:00
<p>Creates a deformed sphere of ore according to 3d perlin noise described by
<code>noise_params</code>. The maximum size of the blob is <code>clust_size</code>, and
<code>clust_scarcity</code> has the same meaning as with the <code>scatter</code> type.</p>
2015-09-25 02:24:04 +03:00
<h3 id="vein"><code>vein</code></h3>
<p>Creates veins of ore varying in density by according to the intersection of two
instances of 3d perlin noise with diffferent seeds, both described by
<code>noise_params</code>. <code>random_factor</code> varies the influence random chance has on
placement of an ore inside the vein, which is <code>1</code> by default. Note that
2015-12-07 21:04:11 +03:00
modifying this parameter may require adjusting <code>noise_threshold</code>.
The parameters <code>clust_scarcity</code>, <code>clust_num_ores</code>, and <code>clust_size</code> are ignored
by this ore type. This ore type is difficult to control since it is sensitive
to small changes. The following is a decent set of parameters to work from:</p>
<pre><code>noise_params = {
offset = 0,
scale = 3,
spread = {x=200, y=200, z=200},
seed = 5390,
octaves = 4,
persist = 0.5,
flags = "eased",
},
2015-12-07 21:04:11 +03:00
noise_threshold = 1.6
</code></pre>
<p>WARNING: Use this ore type <em>very</em> sparingly since it is ~200x more
computationally expensive than any other ore.</p>
2014-12-28 22:55:14 +03:00
<h2 id="ore-attributes">Ore attributes</h2>
2014-12-28 22:26:49 +03:00
<p>See section "Flag Specifier Format".</p>
<p>Currently supported flags: <code>absheight</code></p>
2014-12-28 22:55:14 +03:00
<h3 id="absheight"><code>absheight</code></h3>
<p>Also produce this same ore between the height range of <code>-y_max</code> and <code>-y_min</code>.</p>
2014-12-28 22:26:49 +03:00
<p>Useful for having ore in sky realms without having to duplicate ore entries.</p>
2015-09-25 02:24:04 +03:00
<h3 id="puff_cliffs"><code>puff_cliffs</code></h3>
<p>If set, puff ore generation will not taper down large differences in displacement
when approaching the edge of a puff. This flag has no effect for ore types other
than <code>puff</code>.</p>
<h3 id="puff_additive_composition"><code>puff_additive_composition</code></h3>
<p>By default, when noise described by <code>np_puff_top</code> or <code>np_puff_bottom</code> results in a
negative displacement, the sub-column at that point is not generated. With this
attribute set, puff ore generation will instead generate the absolute difference in
noise displacement values. This flag has no effect for ore types other than <code>puff</code>.</p>
2014-12-28 22:55:14 +03:00
<h2 id="decoration-types">Decoration types</h2>
2014-12-28 22:26:49 +03:00
<p>The varying types of decorations that can be placed.</p>
2014-12-28 22:55:14 +03:00
<h3 id="simple"><code>simple</code></h3>
2015-03-17 21:18:48 +03:00
<p>Creates a 1 times <code>H</code> times 1 column of a specified node (or a random node from
a list, if a decoration list is specified). Can specify a certain node it must
spawn next to, such as water or lava, for example. Can also generate a
decoration of random height between a specified lower and upper bound.
This type of decoration is intended for placement of grass, flowers, cacti,
2015-10-26 03:16:41 +03:00
papyri, waterlilies and so on.</p>
2014-12-28 22:55:14 +03:00
<h3 id="schematic"><code>schematic</code></h3>
2015-03-17 21:18:48 +03:00
<p>Copies a box of <code>MapNodes</code> from a specified schematic file (or raw description).
Can specify a probability of a node randomly appearing when placed.
This decoration type is intended to be used for multi-node sized discrete
structures, such as trees, cave spikes, rocks, and so on.</p>
2014-12-28 22:55:14 +03:00
<h2 id="schematic-specifier">Schematic specifier</h2>
2015-03-17 21:18:48 +03:00
<p>A schematic specifier identifies a schematic by either a filename to a
Minetest Schematic file (<code>.mts</code>) or through raw data supplied through Lua,
2015-05-27 12:53:46 +03:00
in the form of a table. This table specifies the following fields:</p>
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#size" name="size">#</a>The <code>size</code> field is a 3D vector containing the dimensions of the provided schematic. (required)</li>
<li><a class="anchor" href="#yslice_prob" name="yslice_prob">#</a>The <code>yslice_prob</code> field is a table of {ypos, prob} which sets the <code>ypos</code>th vertical slice
2015-05-27 12:53:46 +03:00
of the schematic to have a <code>prob / 256 * 100</code> chance of occuring. (default: 255)</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#data" name="data">#</a>The <code>data</code> field is a flat table of MapNode tables making up the schematic,
2015-05-27 12:53:46 +03:00
in the order of <code>[z [y [x]]]</code>. (required)
Each MapNode table contains:</li>
2016-11-12 19:27:07 +03:00
<li><a class="anchor" href="#name_1" name="name_1">#</a><code>name</code>: the name of the map node to place (required)</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#prob" name="prob">#</a><code>prob</code> (alias <code>param1</code>): the probability of this node being placed (default: 255)</li>
<li><a class="anchor" href="#param2" name="param2">#</a><code>param2</code>: the raw param2 value of the node being placed onto the map (default: 0)</li>
<li><a class="anchor" href="#force_place" name="force_place">#</a><code>force_place</code>: boolean representing if the node should forcibly overwrite any
2015-05-27 12:53:46 +03:00
previous contents (default: false)</li>
</ul>
<p>About probability values:
<em> A probability value of <code>0</code> or <code>1</code> means that node will never appear (0% chance).
</em> A probability value of <code>254</code> or <code>255</code> means the node will always appear (100% chance).
* If the probability value <code>p</code> is greater than <code>1</code>, then there is a
<code>(p / 256 * 100)</code> percent chance that node will appear when the schematic is
placed on the map.</p>
2014-12-28 22:55:14 +03:00
<h2 id="schematic-attributes">Schematic attributes</h2>
2014-12-28 22:26:49 +03:00
<p>See section "Flag Specifier Format".</p>
2015-10-26 03:16:41 +03:00
<p>Currently supported flags: <code>place_center_x</code>, <code>place_center_y</code>, <code>place_center_z</code>,
<code>force_placement</code>.</p>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#place_center_x" name="place_center_x">#</a><code>place_center_x</code>: Placement of this decoration is centered along the X axis.</li>
<li><a class="anchor" href="#place_center_y" name="place_center_y">#</a><code>place_center_y</code>: Placement of this decoration is centered along the Y axis.</li>
<li><a class="anchor" href="#place_center_z" name="place_center_z">#</a><code>place_center_z</code>: Placement of this decoration is centered along the Z axis.</li>
<li><a class="anchor" href="#force_placement" name="force_placement">#</a><code>force_placement</code>: Schematic nodes other than "ignore" will replace existing nodes.</li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
<h2 id="hud-element-types">HUD element types</h2>
2014-12-28 22:26:49 +03:00
<p>The position field is used for all element types.</p>
2015-03-17 21:18:48 +03:00
<p>To account for differing resolutions, the position coordinates are the percentage
of the screen, ranging in value from <code>0</code> to <code>1</code>.</p>
<p>The name field is not yet used, but should contain a description of what the
HUD element represents. The direction field is the direction in which something
is drawn.</p>
<p><code>0</code> draws from left to right, <code>1</code> draws from right to left, <code>2</code> draws from
top to bottom, and <code>3</code> draws from bottom to top.</p>
2014-12-28 22:26:49 +03:00
<p>The <code>alignment</code> field specifies how the item will be aligned. It ranges from <code>-1</code> to <code>1</code>,
with <code>0</code> being the center, <code>-1</code> is moved to the left/up, and <code>1</code> is to the right/down.
Fractional values can be used.</p>
<p>The <code>offset</code> field specifies a pixel offset from the position. Contrary to position,
the offset is not scaled to screen size. This allows for some precisely-positioned
items in the HUD.</p>
<p><strong>Note</strong>: <code>offset</code> <em>will</em> adapt to screen DPI as well as user defined scaling factor!</p>
<p>Below are the specific uses for fields in each type; fields not listed for that type are ignored.</p>
2015-03-17 21:18:48 +03:00
<p><strong>Note</strong>: Future revisions to the HUD API may be incompatible; the HUD API is still
in the experimental stages.</p>
2014-12-28 22:55:14 +03:00
<h3 id="image"><code>image</code></h3>
2014-12-28 22:26:49 +03:00
<p>Displays an image on the HUD.</p>
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#scale_1" name="scale_1">#</a><code>scale</code>: The scale of the image, with 1 being the original texture size.
2014-12-28 22:55:14 +03:00
Only the X coordinate scale is used (positive values).
Negative values represent that percentage of the screen it
should take; e.g. <code>x=-100</code> means 100% (width).</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#text_1" name="text_1">#</a><code>text</code>: The name of the texture that is displayed.</li>
<li><a class="anchor" href="#alignment" name="alignment">#</a><code>alignment</code>: The alignment of the image.</li>
<li><a class="anchor" href="#offset_1" name="offset_1">#</a><code>offset</code>: offset in pixels from position.</li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
<h3 id="text"><code>text</code></h3>
2014-12-28 22:26:49 +03:00
<p>Displays text on the HUD.</p>
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#scale_2" name="scale_2">#</a><code>scale</code>: Defines the bounding rectangle of the text.
2014-12-28 22:55:14 +03:00
A value such as <code>{x=100, y=100}</code> should work.</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#text_2" name="text_2">#</a><code>text</code>: The text to be displayed in the HUD element.</li>
<li><a class="anchor" href="#number" name="number">#</a><code>number</code>: An integer containing the RGB value of the color used to draw the text.
2014-12-28 22:55:14 +03:00
Specify <code>0xFFFFFF</code> for white text, <code>0xFF0000</code> for red, and so on.</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#alignment_1" name="alignment_1">#</a><code>alignment</code>: The alignment of the text.</li>
<li><a class="anchor" href="#offset_2" name="offset_2">#</a><code>offset</code>: offset in pixels from position.</li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
<h3 id="statbar"><code>statbar</code></h3>
2014-12-28 22:26:49 +03:00
<p>Displays a horizontal bar made up of half-images.</p>
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#text_3" name="text_3">#</a><code>text</code>: The name of the texture that is used.</li>
<li><a class="anchor" href="#number_1" name="number_1">#</a><code>number</code>: The number of half-textures that are displayed.
2014-12-28 22:55:14 +03:00
If odd, will end with a vertically center-split texture.</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#direction" name="direction">#</a><code>direction</code></li>
<li><a class="anchor" href="#offset_3" name="offset_3">#</a><code>offset</code>: offset in pixels from position.</li>
<li><a class="anchor" href="#size_1" name="size_1">#</a><code>size</code>: If used, will force full-image size to this value (override texture pack image size)</li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
<h3 id="inventory"><code>inventory</code></h3>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#text_4" name="text_4">#</a><code>text</code>: The name of the inventory list to be displayed.</li>
<li><a class="anchor" href="#number_2" name="number_2">#</a><code>number</code>: Number of items in the inventory to be displayed.</li>
<li><a class="anchor" href="#item" name="item">#</a><code>item</code>: Position of item that is selected.</li>
<li><a class="anchor" href="#direction_1" name="direction_1">#</a><code>direction</code></li>
2016-05-26 20:47:50 +03:00
<li><a class="anchor" href="#offset_4" name="offset_4">#</a><code>offset</code>: offset in pixels from position.</li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
<h3 id="waypoint"><code>waypoint</code></h3>
2014-12-28 22:26:49 +03:00
<p>Displays distance to selected world position.</p>
<ul>
2016-11-12 19:27:07 +03:00
<li><a class="anchor" href="#name_2" name="name_2">#</a><code>name</code>: The name of the waypoint.</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#text_5" name="text_5">#</a><code>text</code>: Distance suffix. Can be blank.</li>
<li><a class="anchor" href="#number_3" name="number_3">#</a><code>number:</code> An integer containing the RGB value of the color used to draw the text.</li>
<li><a class="anchor" href="#world_pos" name="world_pos">#</a><code>world_pos</code>: World position of the waypoint.</li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
<h2 id="representations-of-simple-things">Representations of simple things</h2>
<h3 id="positionvector">Position/vector</h3>
2014-12-28 22:26:49 +03:00
<pre><code>{x=num, y=num, z=num}
</code></pre>
<p>For helper functions see "Vector helpers".</p>
2014-12-28 22:55:14 +03:00
<h3 id="pointed_thing"><code>pointed_thing</code></h3>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#typenothing" name="typenothing">#</a><code>{type="nothing"}</code></li>
<li><a class="anchor" href="#typenodeunderposabovepos" name="typenodeunderposabovepos">#</a><code>{type="node", under=pos, above=pos}</code></li>
<li><a class="anchor" href="#typeobjectrefObjectRef" name="typeobjectrefObjectRef">#</a><code>{type="object", ref=ObjectRef}</code></li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
<h2 id="flag-specifier-format">Flag Specifier Format</h2>
2015-03-17 21:18:48 +03:00
<p>Flags using the standardized flag specifier format can be specified in either of
two ways, by string or table.</p>
<p>The string format is a comma-delimited set of flag names; whitespace and
unrecognized flag fields are ignored. Specifying a flag in the string sets the
flag, and specifying a flag prefixed by the string <code>"no"</code> explicitly
2014-12-28 22:26:49 +03:00
clears the flag from whatever the default may be.</p>
2015-03-17 21:18:48 +03:00
<p>In addition to the standard string flag format, the schematic flags field can
also be a table of flag names to boolean values representing whether or not the
flag is set. Additionally, if a field with the flag name prefixed with <code>"no"</code>
is present, mapped to a boolean of any value, the specified flag is unset.</p>
2014-12-28 22:26:49 +03:00
<p>E.g. A flag field of value</p>
<pre><code>{place_center_x = true, place_center_y=false, place_center_z=true}
</code></pre>
<p>is equivalent to</p>
<pre><code>{place_center_x = true, noplace_center_y=true, place_center_z=true}
</code></pre>
<p>which is equivalent to</p>
<pre><code>"place_center_x, noplace_center_y, place_center_z"
</code></pre>
<p>or even</p>
<pre><code>"place_center_x, place_center_z"
</code></pre>
<p>since, by default, no schematic attributes are set.</p>
2014-12-28 22:55:14 +03:00
<h2 id="items">Items</h2>
<h3 id="item-types">Item types</h3>
2014-12-28 22:26:49 +03:00
<p>There are three kinds of items: nodes, tools and craftitems.</p>
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#register_node" name="register_node">#</a>Node (<code>register_node</code>): A node from the world.</li>
<li><a class="anchor" href="#register_tool" name="register_tool">#</a>Tool (<code>register_tool</code>): A tool/weapon that can dig and damage
2014-12-28 22:55:14 +03:00
things according to <code>tool_capabilities</code>.</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#register_craftitem" name="register_craftitem">#</a>Craftitem (<code>register_craftitem</code>): A miscellaneous item.</li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
<h3 id="item-formats">Item formats</h3>
2014-12-28 22:26:49 +03:00
<p>Items and item stacks can exist in three formats: Serializes, table format
and <code>ItemStack</code>.</p>
2014-12-28 22:55:14 +03:00
<h4 id="serialized">Serialized</h4>
2014-12-28 22:26:49 +03:00
<p>This is called "stackstring" or "itemstring":</p>
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#defaultdirt5" name="defaultdirt5">#</a>e.g. <code>'default:dirt 5'</code></li>
<li><a class="anchor" href="#defaultpick_wood21323" name="defaultpick_wood21323">#</a>e.g. <code>'default:pick_wood 21323'</code></li>
<li><a class="anchor" href="#defaultapple" name="defaultapple">#</a>e.g. <code>'default:apple'</code></li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
<h4 id="table-format">Table format</h4>
2014-12-28 22:26:49 +03:00
<p>Examples:</p>
<p>5 dirt nodes:</p>
<pre><code>{name="default:dirt", count=5, wear=0, metadata=""}
</code></pre>
<p>A wooden pick about 1/3 worn out:</p>
<pre><code>{name="default:pick_wood", count=1, wear=21323, metadata=""}
</code></pre>
<p>An apple:</p>
<pre><code>{name="default:apple", count=1, wear=0, metadata=""}
</code></pre>
2014-12-28 22:55:14 +03:00
<h4 id="itemstack"><code>ItemStack</code></h4>
2014-12-28 22:26:49 +03:00
<p>A native C++ format with many helper methods. Useful for converting
between formats. See the Class reference section for details.</p>
<p>When an item must be passed to a function, it can usually be in any of
these formats.</p>
2014-12-28 22:55:14 +03:00
<h2 id="groups">Groups</h2>
2014-12-28 22:26:49 +03:00
<p>In a number of places, there is a group table. Groups define the
properties of a thing (item, node, armor of entity, capabilities of
tool) in such a way that the engine and other mods can can interact with
the thing without actually knowing what the thing is.</p>
2014-12-28 22:55:14 +03:00
<h3 id="usage">Usage</h3>
2014-12-28 22:26:49 +03:00
<p>Groups are stored in a table, having the group names with keys and the
group ratings as values. For example:</p>
<pre><code>groups = {crumbly=3, soil=1}
-- ^ Default dirt
groups = {crumbly=2, soil=1, level=2, outerspace=1}
-- ^ A more special dirt-kind of thing
</code></pre>
<p>Groups always have a rating associated with them. If there is no
useful meaning for a rating for an enabled group, it shall be <code>1</code>.</p>
<p>When not defined, the rating of a group defaults to <code>0</code>. Thus when you
read groups, you must interpret <code>nil</code> and <code>0</code> as the same value, <code>0</code>.</p>
<p>You can read the rating of a group for an item or a node by using</p>
<pre><code>minetest.get_item_group(itemname, groupname)
</code></pre>
2014-12-28 22:55:14 +03:00
<h3 id="groups-of-items">Groups of items</h3>
2014-12-28 22:26:49 +03:00
<p>Groups of items can define what kind of an item it is (e.g. wool).</p>
2014-12-28 22:55:14 +03:00
<h3 id="groups-of-nodes">Groups of nodes</h3>
2014-12-28 22:26:49 +03:00
<p>In addition to the general item things, groups are used to define whether
a node is destroyable and how long it takes to destroy by a tool.</p>
2014-12-28 22:55:14 +03:00
<h3 id="groups-of-entities">Groups of entities</h3>
2014-12-28 22:26:49 +03:00
<p>For entities, groups are, as of now, used only for calculating damage.
The rating is the percentage of damage caused by tools with this damage group.
See "Entity damage mechanism".</p>
<pre><code>object.get_armor_groups() --&gt; a group-rating table (e.g. {fleshy=100})
object.set_armor_groups({fleshy=30, cracky=80})
</code></pre>
2014-12-28 22:55:14 +03:00
<h3 id="groups-of-tools">Groups of tools</h3>
2014-12-28 22:26:49 +03:00
<p>Groups in tools define which groups of nodes and entities they are
effective towards.</p>
2014-12-28 22:55:14 +03:00
<h3 id="groups-in-crafting-recipes">Groups in crafting recipes</h3>
2014-12-28 22:26:49 +03:00
<p>An example: Make meat soup from any meat, any water and any bowl:</p>
<pre><code>{
output = 'food:meat_soup_raw',
recipe = {
{'group:meat'},
{'group:water'},
{'group:bowl'},
},
-- preserve = {'group:bowl'}, -- Not implemented yet (TODO)
}
</code></pre>
<p>Another example: Make red wool from white wool and red dye:</p>
<pre><code>{
type = 'shapeless',
output = 'wool:red',
recipe = {'wool:white', 'group:dye,basecolor_red'},
}
</code></pre>
2014-12-28 22:55:14 +03:00
<h3 id="special-groups">Special groups</h3>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#immortal" name="immortal">#</a><code>immortal</code>: Disables the group damage system for an entity</li>
<li><a class="anchor" href="#level" name="level">#</a><code>level</code>: Can be used to give an additional sense of progression in the game.<ul>
2014-12-28 22:26:49 +03:00
<li>A larger level will cause e.g. a weapon of a lower level make much less
2014-12-28 22:55:14 +03:00
damage, and get worn out much faster, or not be able to get drops
from destroyed nodes.</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#0" name="0">#</a><code>0</code> is something that is directly accessible at the start of gameplay</li>
2014-12-28 22:26:49 +03:00
<li>There is no upper limit</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#dig_immediate" name="dig_immediate">#</a><code>dig_immediate</code>: (player can always pick up node without tool wear)<ul>
<li><a class="anchor" href="#2" name="2">#</a><code>2</code>: node is removed without tool wear after 0.5 seconds or so
2014-12-28 22:55:14 +03:00
(rail, sign)</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#3" name="3">#</a><code>3</code>: node is removed without tool wear immediately (torch)</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#disable_jump" name="disable_jump">#</a><code>disable_jump</code>: Player (and possibly other things) cannot jump from node</li>
<li><a class="anchor" href="#fall_damage_add_percent" name="fall_damage_add_percent">#</a><code>fall_damage_add_percent</code>: damage speed = <code>speed * (1 + value/100)</code></li>
<li><a class="anchor" href="#bouncy" name="bouncy">#</a><code>bouncy</code>: value is bounce speed in percent</li>
<li><a class="anchor" href="#falling_node" name="falling_node">#</a><code>falling_node</code>: if there is no walkable block under the node it will fall</li>
<li><a class="anchor" href="#attached_node" name="attached_node">#</a><code>attached_node</code>: if the node under it is not a walkable block the node will be
2014-12-28 22:55:14 +03:00
dropped as an item. If the node is wallmounted the wallmounted direction is
checked.</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#soil" name="soil">#</a><code>soil</code>: saplings will grow on nodes in this group</li>
<li><a class="anchor" href="#connect_to_raillike" name="connect_to_raillike">#</a><code>connect_to_raillike</code>: makes nodes of raillike drawtype with same group value
2015-03-17 21:18:48 +03:00
connect to each other</li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
<h3 id="known-damage-and-digging-time-defining-groups">Known damage and digging time defining groups</h3>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#crumbly" name="crumbly">#</a><code>crumbly</code>: dirt, sand</li>
<li><a class="anchor" href="#cracky" name="cracky">#</a><code>cracky</code>: tough but crackable stuff like stone.</li>
<li><a class="anchor" href="#snappy" name="snappy">#</a><code>snappy</code>: something that can be cut using fine tools; e.g. leaves, small
2014-12-28 22:55:14 +03:00
plants, wire, sheets of metal</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#choppy" name="choppy">#</a><code>choppy</code>: something that can be cut using force; e.g. trees, wooden planks</li>
<li><a class="anchor" href="#fleshy" name="fleshy">#</a><code>fleshy</code>: Living things like animals and the player. This could imply
2014-12-28 22:55:14 +03:00
some blood effects when hitting.</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#explody" name="explody">#</a><code>explody</code>: Especially prone to explosions</li>
<li><a class="anchor" href="#oddly_breakable_by_hand" name="oddly_breakable_by_hand">#</a><code>oddly_breakable_by_hand</code>:
2014-12-28 22:55:14 +03:00
Can be added to nodes that shouldn't logically be breakable by the
hand but are. Somewhat similar to <code>dig_immediate</code>, but times are more
like <code>{[1]=3.50,[2]=2.00,[3]=0.70}</code> and this does not override the
speed of a tool if the tool can dig at a faster speed than this
suggests for the hand.</li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
<h3 id="examples-of-custom-groups">Examples of custom groups</h3>
2014-12-28 22:26:49 +03:00
<p>Item groups are often used for defining, well, <em>groups of items</em>.
2014-12-28 22:55:14 +03:00
<em> <code>meat</code>: any meat-kind of a thing (rating might define the size or healing
2014-12-28 22:26:49 +03:00
ability or be irrelevant -- it is not defined as of yet)
2014-12-28 22:55:14 +03:00
</em> <code>eatable</code>: anything that can be eaten. Rating might define HP gain in half
2014-12-28 22:26:49 +03:00
hearts.
2014-12-28 22:55:14 +03:00
<em> <code>flammable</code>: can be set on fire. Rating might define the intensity of the
2014-12-28 22:26:49 +03:00
fire, affecting e.g. the speed of the spreading of an open fire.
2014-12-28 22:55:14 +03:00
</em> <code>wool</code>: any wool (any origin, any color)
<em> <code>metal</code>: any metal
</em> <code>weapon</code>: any weapon
2014-12-28 22:26:49 +03:00
* <code>heavy</code>: anything considerably heavy</p>
2014-12-28 22:55:14 +03:00
<h3 id="digging-time-calculation-specifics">Digging time calculation specifics</h3>
2014-12-28 22:26:49 +03:00
<p>Groups such as <code>crumbly</code>, <code>cracky</code> and <code>snappy</code> are used for this
purpose. Rating is <code>1</code>, <code>2</code> or <code>3</code>. A higher rating for such a group implies
faster digging time.</p>
<p>The <code>level</code> group is used to limit the toughness of nodes a tool can dig
and to scale the digging times / damage to a greater extent.</p>
<p><strong>Please do understand this</strong>, otherwise you cannot use the system to it's
full potential.</p>
<p>Tools define their properties by a list of parameters for groups. They
cannot dig other groups; thus it is important to use a standard bunch of
groups to enable interaction with tools.</p>
2014-12-28 22:55:14 +03:00
<h4 id="tools-definition">Tools definition</h4>
2014-12-28 22:26:49 +03:00
<p>Tools define:</p>
<ul>
<li>Full punch interval</li>
<li>Maximum drop level</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#0_1" name="0_1">#</a>For an arbitrary list of groups:<ul>
<li><a class="anchor" href="#0_2" name="0_2">#</a>Uses (until the tool breaks)<ul>
<li><a class="anchor" href="#0_3" name="0_3">#</a>Maximum level (usually <code>0</code>, <code>1</code>, <code>2</code> or <code>3</code>)</li>
2014-12-28 22:26:49 +03:00
<li>Digging times</li>
<li>Damage groups</li>
</ul>
2014-12-28 22:55:14 +03:00
</li>
</ul>
</li>
</ul>
<h4 id="full-punch-interval">Full punch interval</h4>
2014-12-28 22:26:49 +03:00
<p>When used as a weapon, the tool will do full damage if this time is spent
between punches. If e.g. half the time is spent, the tool will do half
damage.</p>
2014-12-28 22:55:14 +03:00
<h4 id="maximum-drop-level">Maximum drop level</h4>
2014-12-28 22:26:49 +03:00
<p>Suggests the maximum level of node, when dug with the tool, that will drop
it's useful item. (e.g. iron ore to drop a lump of iron).</p>
<p>This is not automated; it is the responsibility of the node definition
to implement this.</p>
2014-12-28 22:55:14 +03:00
<h4 id="uses">Uses</h4>
2014-12-28 22:26:49 +03:00
<p>Determines how many uses the tool has when it is used for digging a node,
of this group, of the maximum level. For lower leveled nodes, the use count
is multiplied by <code>3^leveldiff</code>.</p>
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#uses10leveldiff0" name="uses10leveldiff0">#</a><code>uses=10, leveldiff=0</code>: actual uses: 10</li>
<li><a class="anchor" href="#uses10leveldiff1" name="uses10leveldiff1">#</a><code>uses=10, leveldiff=1</code>: actual uses: 30</li>
<li><a class="anchor" href="#uses10leveldiff2" name="uses10leveldiff2">#</a><code>uses=10, leveldiff=2</code>: actual uses: 90</li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
<h4 id="maximum-level">Maximum level</h4>
2014-12-28 22:26:49 +03:00
<p>Tells what is the maximum level of a node of this group that the tool will
be able to dig.</p>
2014-12-28 22:55:14 +03:00
<h4 id="digging-times">Digging times</h4>
2014-12-28 22:26:49 +03:00
<p>List of digging times for different ratings of the group, for nodes of the
maximum level.</p>
<p>For example, as a Lua table, <code>times={2=2.00, 3=0.70}</code>. This would
result in the tool to be able to dig nodes that have a rating of <code>2</code> or <code>3</code>
for this group, and unable to dig the rating <code>1</code>, which is the toughest.
Unless there is a matching group that enables digging otherwise.</p>
2014-12-28 22:55:14 +03:00
<h4 id="damage-groups">Damage groups</h4>
2014-12-28 22:26:49 +03:00
<p>List of damage for groups of entities. See "Entity damage mechanism".</p>
2014-12-28 22:55:14 +03:00
<h4 id="example-definition-of-the-capabilities-of-a-tool">Example definition of the capabilities of a tool</h4>
2014-12-28 22:26:49 +03:00
<pre><code>tool_capabilities = {
full_punch_interval=1.5,
max_drop_level=1,
groupcaps={
crumbly={maxlevel=2, uses=20, times={[1]=1.60, [2]=1.20, [3]=0.80}}
}
damage_groups = {fleshy=2},
}
</code></pre>
<p>This makes the tool be able to dig nodes that fulfil both of these:</p>
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#crumbly_1" name="crumbly_1">#</a>Have the <code>crumbly</code> group</li>
<li><a class="anchor" href="#level_1" name="level_1">#</a>Have a <code>level</code> group less or equal to <code>2</code></li>
2014-12-28 22:26:49 +03:00
</ul>
<p>Table of resulting digging times:</p>
<pre><code>crumbly 0 1 2 3 4 &lt;- level
-&gt; 0 - - - - -
1 0.80 1.60 1.60 - -
2 0.60 1.20 1.20 - -
3 0.40 0.80 0.80 - -
level diff: 2 1 0 -1 -2
</code></pre>
<p>Table of resulting tool uses:</p>
<pre><code>-&gt; 0 - - - - -
1 180 60 20 - -
2 180 60 20 - -
3 180 60 20 - -
</code></pre>
<p><strong>Notes</strong>:</p>
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#crumbly0" name="crumbly0">#</a>At <code>crumbly==0</code>, the node is not diggable.</li>
<li><a class="anchor" href="#crumbly3" name="crumbly3">#</a>At <code>crumbly==3</code>, the level difference digging time divider kicks in and makes
2014-12-28 22:55:14 +03:00
easy nodes to be quickly breakable.</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#level2" name="level2">#</a>At <code>level &gt; 2</code>, the node is not diggable, because it's <code>level &gt; maxlevel</code></li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
<h2 id="entity-damage-mechanism">Entity damage mechanism</h2>
2014-12-28 22:26:49 +03:00
<p>Damage calculation:</p>
<pre><code>damage = 0
foreach group in cap.damage_groups:
2015-03-17 21:18:48 +03:00
damage += cap.damage_groups[group] * limit(actual_interval /
cap.full_punch_interval, 0.0, 1.0)
2014-12-28 22:26:49 +03:00
* (object.armor_groups[group] / 100.0)
-- Where object.armor_groups[group] is 0 for inexistent values
return damage
</code></pre>
<p>Client predicts damage based on damage groups. Because of this, it is able to
give an immediate response when an entity is damaged or dies; the response is
pre-defined somehow (e.g. by defining a sprite animation) (not implemented;
2015-02-16 20:35:00 +03:00
TODO).
2014-12-28 22:26:49 +03:00
Currently a smoke puff will appear when an entity dies.</p>
<p>The group <code>immortal</code> completely disables normal damage.</p>
<p>Entities can define a special armor group, which is <code>punch_operable</code>. This
group disables the regular damage mechanism for players punching it by hand or
a non-tool item, so that it can do something else than take damage.</p>
<p>On the Lua side, every punch calls:</p>
2017-01-31 17:21:12 +03:00
<pre><code>entity:on_punch(puncher, time_from_last_punch, tool_capabilities, direction, damage)
2014-12-28 22:26:49 +03:00
</code></pre>
2015-03-17 21:18:48 +03:00
<p>This should never be called directly, because damage is usually not handled by
the entity itself.</p>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#puncher" name="puncher">#</a><code>puncher</code> is the object performing the punch. Can be <code>nil</code>. Should never be
2014-12-28 22:55:14 +03:00
accessed unless absolutely required, to encourage interoperability.</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#time_from_last_punch" name="time_from_last_punch">#</a><code>time_from_last_punch</code> is time from last punch (by <code>puncher</code>) or <code>nil</code>.</li>
<li><a class="anchor" href="#tool_capabilities" name="tool_capabilities">#</a><code>tool_capabilities</code> can be <code>nil</code>.</li>
<li><a class="anchor" href="#direction_2" name="direction_2">#</a><code>direction</code> is a unit vector, pointing from the source of the punch to
2014-12-28 22:55:14 +03:00
the punched object.</li>
2017-01-31 17:21:12 +03:00
<li><a class="anchor" href="#damage" name="damage">#</a><code>damage</code> damage that will be done to entity
2017-02-19 16:15:50 +03:00
Return value of this function will determin if damage is done by this function
2017-01-31 17:21:12 +03:00
(retval true) or shall be done by engine (retval false)</li>
2014-12-28 22:26:49 +03:00
</ul>
<p>To punch an entity/object in Lua, call:</p>
<pre><code>object:punch(puncher, time_from_last_punch, tool_capabilities, direction)
</code></pre>
<ul>
<li>Return value is tool wear.</li>
<li>Parameters are equal to the above callback.</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#direction_3" name="direction_3">#</a>If <code>direction</code> equals <code>nil</code> and <code>puncher</code> does not equal <code>nil</code>,
2014-12-28 22:55:14 +03:00
<code>direction</code> will be automatically filled in based on the location of <code>puncher</code>.</li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
<h2 id="node-metadata">Node Metadata</h2>
2014-12-28 22:26:49 +03:00
<p>The instance of a node in the world normally only contains the three values
mentioned in "Nodes". However, it is possible to insert extra data into a
2017-02-19 16:15:50 +03:00
node. It is called "node metadata"; See <code>NodeMetaRef</code>.</p>
<p>Node metadata contains two things:</p>
2015-12-07 21:04:11 +03:00
<ul>
<li>A key-value store</li>
<li>An inventory</li>
</ul>
<p>Some of the values in the key-value store are handled specially:</p>
<ul>
<li><a class="anchor" href="#formspec_2" name="formspec_2">#</a><code>formspec</code>: Defines a right-click inventory menu. See "Formspec".</li>
<li><a class="anchor" href="#infotext" name="infotext">#</a><code>infotext</code>: Text shown on the screen when the node is pointed at</li>
</ul>
2014-12-28 22:26:49 +03:00
<p>Example stuff:</p>
<pre><code>local meta = minetest.get_meta(pos)
meta:set_string("formspec",
"size[8,9]"..
"list[context;main;0,0;8,4;]"..
"list[current_player;main;0,5;8,4;]")
meta:set_string("infotext", "Chest");
local inv = meta:get_inventory()
inv:set_size("main", 8*4)
print(dump(meta:to_table()))
meta:from_table({
inventory = {
2015-03-17 21:18:48 +03:00
main = {[1] = "default:dirt", [2] = "", [3] = "", [4] = "",
[5] = "", [6] = "", [7] = "", [8] = "", [9] = "",
[10] = "", [11] = "", [12] = "", [13] = "",
[14] = "default:cobble", [15] = "", [16] = "", [17] = "",
[18] = "", [19] = "", [20] = "default:cobble", [21] = "",
[22] = "", [23] = "", [24] = "", [25] = "", [26] = "",
[27] = "", [28] = "", [29] = "", [30] = "", [31] = "",
[32] = ""}
2014-12-28 22:26:49 +03:00
},
fields = {
formspec = "size[8,9]list[context;main;0,0;8,4;]list[current_player;main;0,5;8,4;]",
infotext = "Chest"
}
})
</code></pre>
2017-02-19 16:15:50 +03:00
<h2 id="item-metadata">Item Metadata</h2>
<p>Item stacks can store metadata too. See <code>ItemStackMetaRef</code>.</p>
<p>Item metadata only contains a key-value store.</p>
<p>Some of the values in the key-value store are handled specially:</p>
<ul>
<li><a class="anchor" href="#description" name="description">#</a><code>description</code>: Set the itemstack's description. Defaults to idef.description</li>
</ul>
<p>Example stuff:</p>
<pre><code>local meta = stack:get_meta()
meta:set_string("key", "value")
print(dump(meta:to_table()))
</code></pre>
2014-12-28 22:55:14 +03:00
<h2 id="formspec">Formspec</h2>
2014-12-28 22:26:49 +03:00
<p>Formspec defines a menu. Currently not much else than inventories are
supported. It is a string, with a somewhat strange format.</p>
<p>Spaces and newlines can be inserted between the blocks, as is used in the
examples.</p>
2014-12-28 22:55:14 +03:00
<h3 id="examples">Examples</h3>
<h4 id="chest">Chest</h4>
2014-12-28 22:26:49 +03:00
<pre><code>size[8,9]
list[context;main;0,0;8,4;]
list[current_player;main;0,5;8,4;]
</code></pre>
2014-12-28 22:55:14 +03:00
<h4 id="furnace">Furnace</h4>
2014-12-28 22:26:49 +03:00
<pre><code>size[8,9]
list[context;fuel;2,3;1,1;]
list[context;src;2,1;1,1;]
list[context;dst;5,1;2,2;]
list[current_player;main;0,5;8,4;]
</code></pre>
2014-12-28 22:55:14 +03:00
<h4 id="minecraft-like-player-inventory">Minecraft-like player inventory</h4>
2014-12-28 22:26:49 +03:00
<pre><code>size[8,7.5]
image[1,0.6;1,2;player.png]
list[current_player;main;0,3.5;8,4;]
list[current_player;craft;3,0;3,3;]
list[current_player;craftpreview;7,1;1,1;]
</code></pre>
2014-12-28 22:55:14 +03:00
<h3 id="elements">Elements</h3>
<h4 id="sizewhfixed_size"><code>size[&lt;W&gt;,&lt;H&gt;,&lt;fixed_size&gt;]</code></h4>
2014-12-28 22:26:49 +03:00
<ul>
<li>Define the size of the menu in inventory slots</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#fixed_size" name="fixed_size">#</a><code>fixed_size</code>: <code>true</code>/<code>false</code> (optional)</li>
<li><a class="anchor" href="#invsizeWH" name="invsizeWH">#</a>deprecated: <code>invsize[&lt;W&gt;,&lt;H&gt;;]</code></li>
2014-12-28 22:26:49 +03:00
</ul>
2016-11-12 19:27:07 +03:00
<h4 id="containerxy"><code>container[&lt;X&gt;,&lt;Y&gt;]</code></h4>
<ul>
<li>Start of a container block, moves all physical elements in the container by (X, Y)</li>
<li>Must have matching container_end</li>
<li>Containers can be nested, in which case the offsets are added
(child containers are relative to parent containers)</li>
</ul>
<h4 id="container_end"><code>container_end[]</code></h4>
<ul>
<li>End of a container, following elements are no longer relative to this container</li>
</ul>
2014-12-28 22:55:14 +03:00
<h4 id="listinventory-locationlist-namexywh"><code>list[&lt;inventory location&gt;;&lt;list name&gt;;&lt;X&gt;,&lt;Y&gt;;&lt;W&gt;,&lt;H&gt;;]</code></h4>
2014-12-28 22:26:49 +03:00
<ul>
<li>Show an inventory list</li>
</ul>
2014-12-28 22:55:14 +03:00
<h4 id="listinventory-locationlist-namexywhstarting-item-index"><code>list[&lt;inventory location&gt;;&lt;list name&gt;;&lt;X&gt;,&lt;Y&gt;;&lt;W&gt;,&lt;H&gt;;&lt;starting item index&gt;]</code></h4>
2014-12-28 22:26:49 +03:00
<ul>
<li>Show an inventory list</li>
</ul>
2015-07-08 11:43:59 +03:00
<h4 id="listringinventory-locationlist-name"><code>listring[&lt;inventory location&gt;;&lt;list name&gt;]</code></h4>
<ul>
<li>Allows to create a ring of inventory lists</li>
2016-07-22 21:37:58 +03:00
<li>Shift-clicking on items in one element of the ring
will send them to the next inventory list inside the ring</li>
<li>The first occurrence of an element inside the ring will
determine the inventory where items will be sent to</li>
2015-07-08 11:43:59 +03:00
</ul>
<h4 id="listring"><code>listring[]</code></h4>
<ul>
2016-07-22 21:37:58 +03:00
<li><a class="anchor" href="#listringinventorylocationlistname" name="listringinventorylocationlistname">#</a>Shorthand for doing <code>listring[&lt;inventory location&gt;;&lt;list name&gt;]</code>
for the last two inventory lists added by list[...]</li>
2015-07-08 11:43:59 +03:00
</ul>
2014-12-28 22:55:14 +03:00
<h4 id="listcolorsslot_bg_normalslot_bg_hover"><code>listcolors[&lt;slot_bg_normal&gt;;&lt;slot_bg_hover&gt;]</code></h4>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#ColorString" name="ColorString">#</a>Sets background color of slots as <code>ColorString</code></li>
2014-12-28 22:26:49 +03:00
<li>Sets background color of slots on mouse hovering</li>
</ul>
2014-12-28 22:55:14 +03:00
<h4 id="listcolorsslot_bg_normalslot_bg_hoverslot_border"><code>listcolors[&lt;slot_bg_normal&gt;;&lt;slot_bg_hover&gt;;&lt;slot_border&gt;]</code></h4>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#ColorString_1" name="ColorString_1">#</a>Sets background color of slots as <code>ColorString</code></li>
2014-12-28 22:26:49 +03:00
<li>Sets background color of slots on mouse hovering</li>
<li>Sets color of slots border</li>
</ul>
2014-12-28 22:55:14 +03:00
<h4 id="listcolorsslot_bg_normalslot_bg_hoverslot_bordertooltip_bgcolortooltip_fontcolor"><code>listcolors[&lt;slot_bg_normal&gt;;&lt;slot_bg_hover&gt;;&lt;slot_border&gt;;&lt;tooltip_bgcolor&gt;;&lt;tooltip_fontcolor&gt;]</code></h4>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#ColorString_2" name="ColorString_2">#</a>Sets background color of slots as <code>ColorString</code></li>
2014-12-28 22:26:49 +03:00
<li>Sets background color of slots on mouse hovering</li>
<li>Sets color of slots border</li>
<li>Sets default background color of tooltips</li>
<li>Sets default font color of tooltips</li>
</ul>
2014-12-28 22:55:14 +03:00
<h4 id="tooltipgui_element_nametooltip_textbgcolorfontcolor"><code>tooltip[&lt;gui_element_name&gt;;&lt;tooltip_text&gt;;&lt;bgcolor&gt;,&lt;fontcolor&gt;]</code></h4>
2014-12-28 22:26:49 +03:00
<ul>
<li>Adds tooltip for an element</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#bgcolor" name="bgcolor">#</a><code>&lt;bgcolor&gt;</code> tooltip background color as <code>ColorString</code> (optional)</li>
<li><a class="anchor" href="#fontcolor" name="fontcolor">#</a><code>&lt;fontcolor&gt;</code> tooltip font color as <code>ColorString</code> (optional)</li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
<h4 id="imagexywhtexture-name"><code>image[&lt;X&gt;,&lt;Y&gt;;&lt;W&gt;,&lt;H&gt;;&lt;texture name&gt;]</code></h4>
2014-12-28 22:26:49 +03:00
<ul>
<li>Show an image</li>
<li>Position and size units are inventory slots</li>
</ul>
2014-12-28 22:55:14 +03:00
<h4 id="item_imagexywhitem-name"><code>item_image[&lt;X&gt;,&lt;Y&gt;;&lt;W&gt;,&lt;H&gt;;&lt;item name&gt;]</code></h4>
2014-12-28 22:26:49 +03:00
<ul>
<li>Show an inventory image of registered item/node</li>
<li>Position and size units are inventory slots</li>
</ul>
2014-12-28 22:55:14 +03:00
<h4 id="bgcolorcolorfullscreen"><code>bgcolor[&lt;color&gt;;&lt;fullscreen&gt;]</code></h4>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#ColorString_3" name="ColorString_3">#</a>Sets background color of formspec as <code>ColorString</code></li>
<li><a class="anchor" href="#true" name="true">#</a>If <code>true</code>, the background color is drawn fullscreen (does not effect the size of the formspec)</li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
<h4 id="backgroundxywhtexture-name"><code>background[&lt;X&gt;,&lt;Y&gt;;&lt;W&gt;,&lt;H&gt;;&lt;texture name&gt;]</code></h4>
2014-12-28 22:26:49 +03:00
<ul>
<li>Use a background. Inventory rectangles are not drawn then.</li>
<li>Position and size units are inventory slots</li>
<li>Example for formspec 8x4 in 16x resolution: image shall be sized
2014-12-28 22:55:14 +03:00
8 times 16px times 4 times 16px.</li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
<h4 id="backgroundxywhtexture-nameauto_clip"><code>background[&lt;X&gt;,&lt;Y&gt;;&lt;W&gt;,&lt;H&gt;;&lt;texture name&gt;;&lt;auto_clip&gt;]</code></h4>
2014-12-28 22:26:49 +03:00
<ul>
<li>Use a background. Inventory rectangles are not drawn then.</li>
<li>Position and size units are inventory slots</li>
<li>Example for formspec 8x4 in 16x resolution:
2014-12-28 22:55:14 +03:00
image shall be sized 8 times 16px times 4 times 16px</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#true_1" name="true_1">#</a>If <code>true</code> the background is clipped to formspec size
2015-01-24 22:07:00 +03:00
(<code>x</code> and <code>y</code> are used as offset values, <code>w</code> and <code>h</code> are ignored)</li>
2014-12-28 22:26:49 +03:00
</ul>
2016-11-12 19:27:07 +03:00
<h4 id="pwdfieldxywhnamelabel"><code>pwdfield[&lt;X&gt;,&lt;Y&gt;;&lt;W&gt;,&lt;H&gt;;&lt;name&gt;;&lt;label&gt;]</code></h4>
2014-12-28 22:26:49 +03:00
<ul>
<li>Textual password style field; will be sent to server when a button is clicked</li>
2016-08-29 15:43:46 +03:00
<li>When enter is pressed in field, fields.key_enter_field will be sent with the name
of this field.</li>
2016-03-19 17:25:33 +03:00
<li><a class="anchor" href="#x_1" name="x_1">#</a><code>x</code> and <code>y</code> position the field relative to the top left of the menu</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#w_1" name="w_1">#</a><code>w</code> and <code>h</code> are the size of the field</li>
2016-07-22 21:37:58 +03:00
<li><a class="anchor" href="#h_1" name="h_1">#</a>Fields are a set height, but will be vertically centred on <code>h</code></li>
2014-12-28 22:26:49 +03:00
<li>Position and size units are inventory slots</li>
2016-11-12 19:27:07 +03:00
<li><a class="anchor" href="#name_3" name="name_3">#</a><code>name</code> is the name of the field as returned in fields to <code>on_receive_fields</code></li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#label" name="label">#</a><code>label</code>, if not blank, will be text printed on the top left above the field</li>
2016-11-12 19:27:07 +03:00
<li>See field_close_on_enter to stop enter closing the formspec</li>
2014-12-28 22:26:49 +03:00
</ul>
2016-11-12 19:27:07 +03:00
<h4 id="fieldxywhnamelabeldefault"><code>field[&lt;X&gt;,&lt;Y&gt;;&lt;W&gt;,&lt;H&gt;;&lt;name&gt;;&lt;label&gt;;&lt;default&gt;]</code></h4>
2014-12-28 22:26:49 +03:00
<ul>
<li>Textual field; will be sent to server when a button is clicked</li>
2016-08-29 15:43:46 +03:00
<li>When enter is pressed in field, fields.key_enter_field will be sent with the name
of this field.</li>
2016-03-19 17:25:33 +03:00
<li><a class="anchor" href="#x_2" name="x_2">#</a><code>x</code> and <code>y</code> position the field relative to the top left of the menu</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#w_2" name="w_2">#</a><code>w</code> and <code>h</code> are the size of the field</li>
2016-07-22 21:37:58 +03:00
<li><a class="anchor" href="#h_2" name="h_2">#</a>Fields are a set height, but will be vertically centred on <code>h</code></li>
2014-12-28 22:26:49 +03:00
<li>Position and size units are inventory slots</li>
2016-11-12 19:27:07 +03:00
<li><a class="anchor" href="#name_4" name="name_4">#</a><code>name</code> is the name of the field as returned in fields to <code>on_receive_fields</code></li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#label_1" name="label_1">#</a><code>label</code>, if not blank, will be text printed on the top left above the field</li>
<li><a class="anchor" href="#default" name="default">#</a><code>default</code> is the default value of the field<ul>
<li><a class="anchor" href="#default_1" name="default_1">#</a><code>default</code> may contain variable references such as <code>${text}'</code> which
2014-12-28 22:55:14 +03:00
will fill the value from the metadata value <code>text</code></li>
2014-12-28 22:26:49 +03:00
<li><strong>Note</strong>: no extra text or more than a single variable is supported ATM.</li>
</ul>
2014-12-28 22:55:14 +03:00
</li>
2016-11-12 19:27:07 +03:00
<li>See field_close_on_enter to stop enter closing the formspec</li>
2014-12-28 22:55:14 +03:00
</ul>
2016-11-12 19:27:07 +03:00
<h4 id="fieldnamelabeldefault"><code>field[&lt;name&gt;;&lt;label&gt;;&lt;default&gt;]</code></h4>
2014-12-28 22:26:49 +03:00
<ul>
2016-07-22 21:37:58 +03:00
<li>As above, but without position/size units</li>
2016-08-29 15:43:46 +03:00
<li>When enter is pressed in field, fields.key_enter_field will be sent with the name
of this field.</li>
2016-07-22 21:37:58 +03:00
<li>Special field for creating simple forms, such as sign text input</li>
<li><a class="anchor" href="#size_2" name="size_2">#</a>Must be used without a <code>size[]</code> element</li>
<li>A "Proceed" button will be added automatically</li>
2016-11-12 19:27:07 +03:00
<li>See field_close_on_enter to stop enter closing the formspec</li>
</ul>
<h4 id="field_close_on_enternameclose_on_enter"><code>field_close_on_enter[&lt;name&gt;;&lt;close_on_enter&gt;]</code></h4>
<ul>
<li><name> is the name of the field</name></li>
<li>if <close_on_enter> is false, pressing enter in the field will submit the form but not close it</close_on_enter></li>
<li>defaults to true when not specified (ie: no tag for a field)</li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
<h4 id="textareaxywhnamelabeldefault"><code>textarea[&lt;X&gt;,&lt;Y&gt;;&lt;W&gt;,&lt;H&gt;;&lt;name&gt;;&lt;label&gt;;&lt;default&gt;]</code></h4>
2014-12-28 22:26:49 +03:00
<ul>
2016-07-22 21:37:58 +03:00
<li>Same as fields above, but with multi-line input</li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
<h4 id="labelxylabel"><code>label[&lt;X&gt;,&lt;Y&gt;;&lt;label&gt;]</code></h4>
2014-12-28 22:26:49 +03:00
<ul>
2016-03-19 17:25:33 +03:00
<li><a class="anchor" href="#x_3" name="x_3">#</a><code>x</code> and <code>y</code> work as per field</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#label_2" name="label_2">#</a><code>label</code> is the text on the label</li>
2014-12-28 22:26:49 +03:00
<li>Position and size units are inventory slots</li>
</ul>
2014-12-28 22:55:14 +03:00
<h4 id="vertlabelxylabel"><code>vertlabel[&lt;X&gt;,&lt;Y&gt;;&lt;label&gt;]</code></h4>
2014-12-28 22:26:49 +03:00
<ul>
<li>Textual label drawn vertically</li>
2016-03-19 17:25:33 +03:00
<li><a class="anchor" href="#x_4" name="x_4">#</a><code>x</code> and <code>y</code> work as per field</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#label_3" name="label_3">#</a><code>label</code> is the text on the label</li>
2014-12-28 22:26:49 +03:00
<li>Position and size units are inventory slots</li>
</ul>
2014-12-28 22:55:14 +03:00
<h4 id="buttonxywhnamelabel"><code>button[&lt;X&gt;,&lt;Y&gt;;&lt;W&gt;,&lt;H&gt;;&lt;name&gt;;&lt;label&gt;]</code></h4>
2014-12-28 22:26:49 +03:00
<ul>
<li>Clickable button. When clicked, fields will be sent.</li>
2016-03-19 17:25:33 +03:00
<li><a class="anchor" href="#x_5" name="x_5">#</a><code>x</code>, <code>y</code> and <code>name</code> work as per field</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#w_3" name="w_3">#</a><code>w</code> and <code>h</code> are the size of the button</li>
<li><a class="anchor" href="#label_4" name="label_4">#</a><code>label</code> is the text on the button</li>
2014-12-28 22:26:49 +03:00
<li>Position and size units are inventory slots</li>
</ul>
2014-12-28 22:55:14 +03:00
<h4 id="image_buttonxywhtexture-namenamelabel"><code>image_button[&lt;X&gt;,&lt;Y&gt;;&lt;W&gt;,&lt;H&gt;;&lt;texture name&gt;;&lt;name&gt;;&lt;label&gt;]</code></h4>
2014-12-28 22:26:49 +03:00
<ul>
2016-03-19 17:25:33 +03:00
<li><a class="anchor" href="#x_6" name="x_6">#</a><code>x</code>, <code>y</code>, <code>w</code>, <code>h</code>, and <code>name</code> work as per button</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#texturename" name="texturename">#</a><code>texture name</code> is the filename of an image</li>
2014-12-28 22:26:49 +03:00
<li>Position and size units are inventory slots</li>
</ul>
2014-12-28 22:55:14 +03:00
<h4 id="image_buttonxywhtexture-namenamelabelnoclipdrawborderpressed-texture-name"><code>image_button[&lt;X&gt;,&lt;Y&gt;;&lt;W&gt;,&lt;H&gt;;&lt;texture name&gt;;&lt;name&gt;;&lt;label&gt;;&lt;noclip&gt;;&lt;drawborder&gt;;&lt;pressed texture name&gt;]</code></h4>
2014-12-28 22:26:49 +03:00
<ul>
2016-03-19 17:25:33 +03:00
<li><a class="anchor" href="#x_7" name="x_7">#</a><code>x</code>, <code>y</code>, <code>w</code>, <code>h</code>, and <code>name</code> work as per button</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#texturename_1" name="texturename_1">#</a><code>texture name</code> is the filename of an image</li>
2014-12-28 22:26:49 +03:00
<li>Position and size units are inventory slots</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#nocliptrue" name="nocliptrue">#</a><code>noclip=true</code> means the image button doesn't need to be within specified formsize</li>
<li><a class="anchor" href="#drawborder" name="drawborder">#</a><code>drawborder</code>: draw button border or not</li>
<li><a class="anchor" href="#pressedtexturename" name="pressedtexturename">#</a><code>pressed texture name</code> is the filename of an image on pressed state</li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
<h4 id="item_image_buttonxywhitem-namenamelabel"><code>item_image_button[&lt;X&gt;,&lt;Y&gt;;&lt;W&gt;,&lt;H&gt;;&lt;item name&gt;;&lt;name&gt;;&lt;label&gt;]</code></h4>
2014-12-28 22:26:49 +03:00
<ul>
2016-03-19 17:25:33 +03:00
<li><a class="anchor" href="#x_8" name="x_8">#</a><code>x</code>, <code>y</code>, <code>w</code>, <code>h</code>, <code>name</code> and <code>label</code> work as per button</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#itemname" name="itemname">#</a><code>item name</code> is the registered name of an item/node,
2014-12-28 22:55:14 +03:00
tooltip will be made out of its description
to override it use tooltip element</li>
2014-12-28 22:26:49 +03:00
<li>Position and size units are inventory slots</li>
</ul>
2014-12-28 22:55:14 +03:00
<h4 id="button_exitxywhnamelabel"><code>button_exit[&lt;X&gt;,&lt;Y&gt;;&lt;W&gt;,&lt;H&gt;;&lt;name&gt;;&lt;label&gt;]</code></h4>
2014-12-28 22:26:49 +03:00
<ul>
<li>When clicked, fields will be sent and the form will quit.</li>
</ul>
2014-12-28 22:55:14 +03:00
<h4 id="image_button_exitxywhtexture-namenamelabel"><code>image_button_exit[&lt;X&gt;,&lt;Y&gt;;&lt;W&gt;,&lt;H&gt;;&lt;texture name&gt;;&lt;name&gt;;&lt;label&gt;]</code></h4>
2014-12-28 22:26:49 +03:00
<ul>
<li>When clicked, fields will be sent and the form will quit.</li>
</ul>
2014-12-28 22:55:14 +03:00
<h4 id="textlistxywhnamelistelem-1listelem-2listelem-n"><code>textlist[&lt;X&gt;,&lt;Y&gt;;&lt;W&gt;,&lt;H&gt;;&lt;name&gt;;&lt;listelem 1&gt;,&lt;listelem 2&gt;,...,&lt;listelem n&gt;]</code></h4>
2014-12-28 22:26:49 +03:00
<ul>
<li>Scrollable item list showing arbitrary text elements</li>
2016-03-19 17:25:33 +03:00
<li><a class="anchor" href="#x_9" name="x_9">#</a><code>x</code> and <code>y</code> position the itemlist relative to the top left of the menu</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#w_4" name="w_4">#</a><code>w</code> and <code>h</code> are the size of the itemlist</li>
2016-11-12 19:27:07 +03:00
<li><a class="anchor" href="#name_5" name="name_5">#</a><code>name</code> fieldname sent to server on doubleclick value is current selected element</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#listelements" name="listelements">#</a><code>listelements</code> can be prepended by #color in hexadecimal format RRGGBB (only),<ul>
2014-12-28 22:26:49 +03:00
<li>if you want a listelement to start with "#" write "##".</li>
</ul>
2014-12-28 22:55:14 +03:00
</li>
</ul>
<h4 id="textlistxywhnamelistelem-1listelem-2listelem-nselected-idxtransparent"><code>textlist[&lt;X&gt;,&lt;Y&gt;;&lt;W&gt;,&lt;H&gt;;&lt;name&gt;;&lt;listelem 1&gt;,&lt;listelem 2&gt;,...,&lt;listelem n&gt;;&lt;selected idx&gt;;&lt;transparent&gt;]</code></h4>
2014-12-28 22:26:49 +03:00
<ul>
<li>Scrollable itemlist showing arbitrary text elements</li>
2016-03-19 17:25:33 +03:00
<li><a class="anchor" href="#x_10" name="x_10">#</a><code>x</code> and <code>y</code> position the item list relative to the top left of the menu</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#w_5" name="w_5">#</a><code>w</code> and <code>h</code> are the size of the item list</li>
2016-11-12 19:27:07 +03:00
<li><a class="anchor" href="#name_6" name="name_6">#</a><code>name</code> fieldname sent to server on doubleclick value is current selected element</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#listelements_1" name="listelements_1">#</a><code>listelements</code> can be prepended by #RRGGBB (only) in hexadecimal format<ul>
2014-12-28 22:26:49 +03:00
<li>if you want a listelement to start with "#" write "##"</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2016-07-22 21:37:58 +03:00
<li>Index to be selected within textlist</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#true_2" name="true_2">#</a><code>true</code>/<code>false</code>: draw transparent background</li>
2016-07-22 21:37:58 +03:00
<li><a class="anchor" href="#minetestexplode_textlist_event" name="minetestexplode_textlist_event">#</a>See also <code>minetest.explode_textlist_event</code> (main menu: <code>engine.explode_textlist_event</code>)</li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
<h4 id="tabheaderxynamecaption-1caption-2caption-ncurrent_tabtransparentdraw_border"><code>tabheader[&lt;X&gt;,&lt;Y&gt;;&lt;name&gt;;&lt;caption 1&gt;,&lt;caption 2&gt;,...,&lt;caption n&gt;;&lt;current_tab&gt;;&lt;transparent&gt;;&lt;draw_border&gt;]</code></h4>
2014-12-28 22:26:49 +03:00
<ul>
2016-07-22 21:37:58 +03:00
<li>Show a tab<strong>header</strong> at specific position (ignores formsize)</li>
2016-03-19 17:25:33 +03:00
<li><a class="anchor" href="#x_11" name="x_11">#</a><code>x</code> and <code>y</code> position the itemlist relative to the top left of the menu</li>
2016-11-12 19:27:07 +03:00
<li><a class="anchor" href="#name_7" name="name_7">#</a><code>name</code> fieldname data is transferred to Lua</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#caption1" name="caption1">#</a><code>caption 1</code>...: name shown on top of tab</li>
<li><a class="anchor" href="#current_tab" name="current_tab">#</a><code>current_tab</code>: index of selected tab 1...</li>
<li><a class="anchor" href="#transparent" name="transparent">#</a><code>transparent</code> (optional): show transparent</li>
<li><a class="anchor" href="#draw_border" name="draw_border">#</a><code>draw_border</code> (optional): draw border</li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
<h4 id="boxxywhcolor"><code>box[&lt;X&gt;,&lt;Y&gt;;&lt;W&gt;,&lt;H&gt;;&lt;color&gt;]</code></h4>
2014-12-28 22:26:49 +03:00
<ul>
2016-07-22 21:37:58 +03:00
<li>Simple colored semitransparent box</li>
2016-03-19 17:25:33 +03:00
<li><a class="anchor" href="#x_12" name="x_12">#</a><code>x</code> and <code>y</code> position the box relative to the top left of the menu</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#w_6" name="w_6">#</a><code>w</code> and <code>h</code> are the size of box</li>
<li><a class="anchor" href="#color" name="color">#</a><code>color</code> is color specified as a <code>ColorString</code></li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
<h4 id="dropdownxywnameitem-1item-2-item-nselected-idx"><code>dropdown[&lt;X&gt;,&lt;Y&gt;;&lt;W&gt;;&lt;name&gt;;&lt;item 1&gt;,&lt;item 2&gt;, ...,&lt;item n&gt;;&lt;selected idx&gt;]</code></h4>
2014-12-28 22:26:49 +03:00
<ul>
2016-07-22 21:37:58 +03:00
<li>Show a dropdown field</li>
2014-12-28 22:55:14 +03:00
<li><strong>Important note</strong>: There are two different operation modes:<ol>
2014-12-28 22:26:49 +03:00
<li>handle directly on change (only changed dropdown is submitted)</li>
<li>read the value on pressing a button (all dropdown values are available)</li>
2014-12-28 22:55:14 +03:00
</ol>
</li>
2016-03-19 17:25:33 +03:00
<li><a class="anchor" href="#x_13" name="x_13">#</a><code>x</code> and <code>y</code> position of dropdown</li>
2016-07-22 21:37:58 +03:00
<li>Width of dropdown</li>
<li>Fieldname data is transferred to Lua</li>
<li>Items to be shown in dropdown</li>
<li>Index of currently selected dropdown item</li>
2014-12-28 22:26:49 +03:00
</ul>
2016-07-22 21:37:58 +03:00
<h4 id="checkboxxynamelabelselected"><code>checkbox[&lt;X&gt;,&lt;Y&gt;;&lt;name&gt;;&lt;label&gt;;&lt;selected&gt;]</code></h4>
2014-12-28 22:26:49 +03:00
<ul>
2016-07-22 21:37:58 +03:00
<li>Show a checkbox</li>
2016-03-19 17:25:33 +03:00
<li><a class="anchor" href="#x_14" name="x_14">#</a><code>x</code> and <code>y</code>: position of checkbox</li>
2016-11-12 19:27:07 +03:00
<li><a class="anchor" href="#name_8" name="name_8">#</a><code>name</code> fieldname data is transferred to Lua</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#label_5" name="label_5">#</a><code>label</code> to be shown left of checkbox</li>
<li><a class="anchor" href="#selected" name="selected">#</a><code>selected</code> (optional): <code>true</code>/<code>false</code></li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
<h4 id="scrollbarxywhorientationnamevalue"><code>scrollbar[&lt;X&gt;,&lt;Y&gt;;&lt;W&gt;,&lt;H&gt;;&lt;orientation&gt;;&lt;name&gt;;&lt;value&gt;]</code></h4>
2014-12-28 22:26:49 +03:00
<ul>
2016-07-22 21:37:58 +03:00
<li>Show a scrollbar</li>
<li>There are two ways to use it:<ol>
2014-12-28 22:26:49 +03:00
<li>handle the changed event (only changed scrollbar is available)</li>
<li>read the value on pressing a button (all scrollbars are available)</li>
2014-12-28 22:55:14 +03:00
</ol>
</li>
2016-03-19 17:25:33 +03:00
<li><a class="anchor" href="#x_15" name="x_15">#</a><code>x</code> and <code>y</code>: position of trackbar</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#w_7" name="w_7">#</a><code>w</code> and <code>h</code>: width and height</li>
<li><a class="anchor" href="#orientation" name="orientation">#</a><code>orientation</code>: <code>vertical</code>/<code>horizontal</code></li>
2016-07-22 21:37:58 +03:00
<li>Fieldname data is transferred to Lua</li>
<li><a class="anchor" href="#0_4" name="0_4">#</a>Value this trackbar is set to (<code>0</code>-<code>1000</code>)</li>
<li><a class="anchor" href="#minetestexplode_scrollbar_event" name="minetestexplode_scrollbar_event">#</a>See also <code>minetest.explode_scrollbar_event</code> (main menu: <code>engine.explode_scrollbar_event</code>)</li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
<h4 id="tablexywhnamecell-1cell-2cell-nselected-idx"><code>table[&lt;X&gt;,&lt;Y&gt;;&lt;W&gt;,&lt;H&gt;;&lt;name&gt;;&lt;cell 1&gt;,&lt;cell 2&gt;,...,&lt;cell n&gt;;&lt;selected idx&gt;]</code></h4>
2014-12-28 22:26:49 +03:00
<ul>
2016-07-22 21:37:58 +03:00
<li><a class="anchor" href="#tableoptions" name="tableoptions">#</a>Show scrollable table using options defined by the previous <code>tableoptions[]</code></li>
<li><a class="anchor" href="#tablecolumns" name="tablecolumns">#</a>Displays cells as defined by the previous <code>tablecolumns[]</code></li>
2016-03-19 17:25:33 +03:00
<li><a class="anchor" href="#x_16" name="x_16">#</a><code>x</code> and <code>y</code>: position the itemlist relative to the top left of the menu</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#w_8" name="w_8">#</a><code>w</code> and <code>h</code> are the size of the itemlist</li>
2016-11-12 19:27:07 +03:00
<li><a class="anchor" href="#name_9" name="name_9">#</a><code>name</code>: fieldname sent to server on row select or doubleclick</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#cell1" name="cell1">#</a><code>cell 1</code>...<code>cell n</code>: cell contents given in row-major order</li>
<li><a class="anchor" href="#selectedidx" name="selectedidx">#</a><code>selected idx</code>: index of row to be selected within table (first row = <code>1</code>)</li>
2016-07-22 21:37:58 +03:00
<li><a class="anchor" href="#minetestexplode_table_event" name="minetestexplode_table_event">#</a>See also <code>minetest.explode_table_event</code> (main menu: <code>engine.explode_table_event</code>)</li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
<h4 id="tableoptionsopt-1opt-2"><code>tableoptions[&lt;opt 1&gt;;&lt;opt 2&gt;;...]</code></h4>
2014-12-28 22:26:49 +03:00
<ul>
2016-07-22 21:37:58 +03:00
<li><a class="anchor" href="#table" name="table">#</a>Sets options for <code>table[]</code></li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#colorRRGGBB" name="colorRRGGBB">#</a><code>color=#RRGGBB</code><ul>
<li><a class="anchor" href="#ColorString_4" name="ColorString_4">#</a>default text color (<code>ColorString</code>), defaults to <code>#FFFFFF</code></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#backgroundRRGGBB" name="backgroundRRGGBB">#</a><code>background=#RRGGBB</code><ul>
<li><a class="anchor" href="#ColorString_5" name="ColorString_5">#</a>table background color (<code>ColorString</code>), defaults to <code>#000000</code></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#bordertruefalse" name="bordertruefalse">#</a><code>border=&lt;true/false&gt;</code><ul>
<li><a class="anchor" href="#true_3" name="true_3">#</a>should the table be drawn with a border? (default: <code>true</code>)</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#highlightRRGGBB" name="highlightRRGGBB">#</a><code>highlight=#RRGGBB</code><ul>
<li><a class="anchor" href="#ColorString_6" name="ColorString_6">#</a>highlight background color (<code>ColorString</code>), defaults to <code>#466432</code></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#highlight_textRRGGBB" name="highlight_textRRGGBB">#</a><code>highlight_text=#RRGGBB</code><ul>
<li><a class="anchor" href="#ColorString_7" name="ColorString_7">#</a>highlight text color (<code>ColorString</code>), defaults to <code>#FFFFFF</code></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#opendepthvalue" name="opendepthvalue">#</a><code>opendepth=&lt;value&gt;</code><ul>
<li><a class="anchor" href="#depthvalue" name="depthvalue">#</a>all subtrees up to <code>depth &lt; value</code> are open (default value = <code>0</code>)</li>
2014-12-28 22:26:49 +03:00
<li>only useful when there is a column of type "tree"</li>
</ul>
2014-12-28 22:55:14 +03:00
</li>
</ul>
<h4 id="tablecolumnstype-1opt-1aopt-1btype-2opt-2aopt-2b"><code>tablecolumns[&lt;type 1&gt;,&lt;opt 1a&gt;,&lt;opt 1b&gt;,...;&lt;type 2&gt;,&lt;opt 2a&gt;,&lt;opt 2b&gt;;...]</code></h4>
2014-12-28 22:26:49 +03:00
<ul>
2016-07-22 21:37:58 +03:00
<li><a class="anchor" href="#table_1" name="table_1">#</a>Sets columns for <code>table[]</code></li>
<li><a class="anchor" href="#text_6" name="text_6">#</a>Types: <code>text</code>, <code>image</code>, <code>color</code>, <code>indent</code>, <code>tree</code><ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#text_7" name="text_7">#</a><code>text</code>: show cell contents as text</li>
<li><a class="anchor" href="#image_1" name="image_1">#</a><code>image</code>: cell contents are an image index, use column options to define images</li>
2016-03-19 17:25:33 +03:00
<li><a class="anchor" href="#color_1" name="color_1">#</a><code>color</code>: cell contents are a ColorString and define color of following cell</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#indent" name="indent">#</a><code>indent</code>: cell contents are a number and define indentation of following cell</li>
<li><a class="anchor" href="#tree" name="tree">#</a><code>tree</code>: same as indent, but user can open and close subtrees (treeview-like)</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2016-07-22 21:37:58 +03:00
<li><a class="anchor" href="#alignvalue" name="alignvalue">#</a>Column options:<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#alignvalue_1" name="alignvalue_1">#</a><code>align=&lt;value&gt;</code><ul>
<li><a class="anchor" href="#text_8" name="text_8">#</a>for <code>text</code> and <code>image</code>: content alignment within cells.
2014-12-28 22:55:14 +03:00
Available values: <code>left</code> (default), <code>center</code>, <code>right</code>, <code>inline</code></li>
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#widthvalue" name="widthvalue">#</a><code>width=&lt;value&gt;</code><ul>
<li><a class="anchor" href="#text_9" name="text_9">#</a>for <code>text</code> and <code>image</code>: minimum width in em (default: <code>0</code>)</li>
<li><a class="anchor" href="#indent_1" name="indent_1">#</a>for <code>indent</code> and <code>tree</code>: indent width in em (default: <code>1.5</code>)</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#paddingvalue" name="paddingvalue">#</a><code>padding=&lt;value&gt;</code>: padding left of the column, in em (default <code>0.5</code>).
2014-12-28 22:55:14 +03:00
Exception: defaults to 0 for indent columns</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#tooltipvalue" name="tooltipvalue">#</a><code>tooltip=&lt;value&gt;</code>: tooltip text (default: empty)</li>
<li><a class="anchor" href="#image_2" name="image_2">#</a><code>image</code> column options:<ul>
<li><a class="anchor" href="#0value" name="0value">#</a><code>0=&lt;value&gt;</code> sets image for image index 0</li>
<li><a class="anchor" href="#1value" name="1value">#</a><code>1=&lt;value&gt;</code> sets image for image index 1</li>
<li><a class="anchor" href="#2value" name="2value">#</a><code>2=&lt;value&gt;</code> sets image for image index 2</li>
<li><a class="anchor" href="#0_5" name="0_5">#</a>and so on; defined indices need not be contiguous empty or
2014-12-28 22:55:14 +03:00
non-numeric cells are treated as <code>0</code>.</li>
</ul>
</li>
2016-03-19 17:25:33 +03:00
<li><a class="anchor" href="#color_2" name="color_2">#</a><code>color</code> column options:<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#spanvalue" name="spanvalue">#</a><code>span=&lt;value&gt;</code>: number of following columns to affect (default: infinite)</li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
</li>
</ul>
</li>
</ul>
2014-12-28 22:26:49 +03:00
<p><strong>Note</strong>: do <em>not</em> use a element name starting with <code>key_</code>; those names are reserved to
pass key press events to formspec!</p>
2014-12-28 22:55:14 +03:00
<h2 id="inventory-locations">Inventory locations</h2>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#context" name="context">#</a><code>"context"</code>: Selected node metadata (deprecated: <code>"current_name"</code>)</li>
<li><a class="anchor" href="#current_player" name="current_player">#</a><code>"current_player"</code>: Player to whom the menu is shown</li>
<li><a class="anchor" href="#playername" name="playername">#</a><code>"player:&lt;name&gt;"</code>: Any player</li>
<li><a class="anchor" href="#nodemetaXYZ" name="nodemetaXYZ">#</a><code>"nodemeta:&lt;X&gt;,&lt;Y&gt;,&lt;Z&gt;"</code>: Any node metadata</li>
<li><a class="anchor" href="#detachedname" name="detachedname">#</a><code>"detached:&lt;name&gt;"</code>: A detached inventory</li>
2014-12-28 22:26:49 +03:00
</ul>
2016-12-29 00:57:48 +03:00
<h2 id="player-inventory-lists">Player Inventory lists</h2>
<ul>
<li><a class="anchor" href="#main" name="main">#</a><code>main</code>: list containing the default inventory</li>
<li><a class="anchor" href="#craft" name="craft">#</a><code>craft</code>: list containing the craft input</li>
<li><a class="anchor" href="#craftpreview" name="craftpreview">#</a><code>craftpreview</code>: list containing the craft output</li>
<li><a class="anchor" href="#hand" name="hand">#</a><code>hand</code>: list containing an override for the empty hand</li>
</ul>
2014-12-28 22:55:14 +03:00
<h2 id="colorstring"><code>ColorString</code></h2>
2014-12-28 22:26:49 +03:00
<p><code>#RGB</code> defines a color in hexadecimal format.</p>
<p><code>#RGBA</code> defines a color in hexadecimal format and alpha channel.</p>
<p><code>#RRGGBB</code> defines a color in hexadecimal format.</p>
<p><code>#RRGGBBAA</code> defines a color in hexadecimal format and alpha channel.</p>
<p>Named colors are also supported and are equivalent to
<a href="http://dev.w3.org/csswg/css-color/#named-colors">CSS Color Module Level 4</a>.
To specify the value of the alpha channel, append <code>#AA</code> to the end of the color name
(e.g. <code>colorname#08</code>). For named colors the hexadecimal string representing the alpha
value must (always) be two hexadecimal digits.</p>
2015-05-27 12:53:46 +03:00
<h2 id="colorspec"><code>ColorSpec</code></h2>
<p>A ColorSpec specifies a 32-bit color. It can be written in either:
table form, each element ranging from 0..255 (a, if absent, defaults to 255):
<code>colorspec = {a=255, r=0, g=255, b=0}</code>
numerical form, the raw integer value of an ARGB8 quad:
<code>colorspec = 0xFF00FF00</code>
or string form, a ColorString (defined above):
<code>colorspec = "green"</code></p>
2016-07-22 21:37:58 +03:00
<h2 id="escape-sequences">Escape sequences</h2>
<p>Most text can contain escape sequences, that can for example color the text.
There are a few exceptions: tab headers, dropdowns and vertical labels can't.
The following functions provide escape sequences:
<em> <code>core.get_color_escape_sequence(color)</code>:
* <code>color</code> is a ColorString
* The escape sequence sets the text color to <code>color</code>
</em> <code>core.colorize(color, message)</code>:
* Equivalent to:
<code>core.get_color_escape_sequence(color) ..
message ..
core.get_color_escape_sequence("#ffffff")</code>
* <code>color.get_background_escape_sequence(color)</code>
* <code>color</code> is a ColorString
* The escape sequence sets the background of the whole text element to
<code>color</code>. Only defined for item descriptions and tooltips.</p>
2015-10-26 03:16:41 +03:00
<h2 id="spatial-vectors">Spatial Vectors</h2>
2014-12-28 22:26:49 +03:00
<ul>
2016-04-09 16:27:30 +03:00
<li><a class="anchor" href="#vectornewabc" name="vectornewabc">#</a><code>vector.new(a[, b, c])</code>: returns a vector:<ul>
2016-03-19 17:25:33 +03:00
<li><a class="anchor" href="#a" name="a">#</a>A copy of <code>a</code> if <code>a</code> is a vector.</li>
<li><a class="anchor" href="#xaybzc" name="xaybzc">#</a><code>{x = a, y = b, z = c}</code>, if all <code>a, b, c</code> are defined</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2016-03-19 17:25:33 +03:00
<li><a class="anchor" href="#vectordirectionp1p2" name="vectordirectionp1p2">#</a><code>vector.direction(p1, p2)</code>: returns a vector</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#vectordistancep1p2" name="vectordistancep1p2">#</a><code>vector.distance(p1, p2)</code>: returns a number</li>
<li><a class="anchor" href="#vectorlengthv" name="vectorlengthv">#</a><code>vector.length(v)</code>: returns a number</li>
<li><a class="anchor" href="#vectornormalizev" name="vectornormalizev">#</a><code>vector.normalize(v)</code>: returns a vector</li>
2016-11-12 19:27:07 +03:00
<li><a class="anchor" href="#vectorfloorv" name="vectorfloorv">#</a><code>vector.floor(v)</code>: returns a vector, each dimension rounded down</li>
<li><a class="anchor" href="#vectorroundv" name="vectorroundv">#</a><code>vector.round(v)</code>: returns a vector, each dimension rounded to nearest int</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#vectorapplyvfunc" name="vectorapplyvfunc">#</a><code>vector.apply(v, func)</code>: returns a vector</li>
<li><a class="anchor" href="#vectorequalsv1v2" name="vectorequalsv1v2">#</a><code>vector.equals(v1, v2)</code>: returns a boolean</li>
2017-01-31 17:21:12 +03:00
<li><a class="anchor" href="#vectorsortv1v2" name="vectorsortv1v2">#</a><code>vector.sort(v1, v2)</code>: returns minp, maxp vectors of the cuboid defined by v1 and v2</li>
2014-12-28 22:26:49 +03:00
</ul>
<p>For the following functions <code>x</code> can be either a vector or a number:</p>
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#vectoraddvx" name="vectoraddvx">#</a><code>vector.add(v, x)</code>: returns a vector</li>
<li><a class="anchor" href="#vectorsubtractvx" name="vectorsubtractvx">#</a><code>vector.subtract(v, x)</code>: returns a vector</li>
<li><a class="anchor" href="#vectormultiplyvx" name="vectormultiplyvx">#</a><code>vector.multiply(v, x)</code>: returns a scaled vector or Schur product</li>
<li><a class="anchor" href="#vectordividevx" name="vectordividevx">#</a><code>vector.divide(v, x)</code>: returns a scaled vector or Schur quotient</li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
<h2 id="helper-functions">Helper functions</h2>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#dump2objname_dumped" name="dump2objname_dumped">#</a><code>dump2(obj, name="_", dumped={})</code><ul>
2014-12-28 22:26:49 +03:00
<li>Return object serialized as a string, handles reference loops</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#dumpobjdumped" name="dumpobjdumped">#</a><code>dump(obj, dumped={})</code><ul>
2014-12-28 22:26:49 +03:00
<li>Return object serialized as a string</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#mathhypotxy" name="mathhypotxy">#</a><code>math.hypot(x, y)</code><ul>
2014-12-28 22:26:49 +03:00
<li>Get the hypotenuse of a triangle with legs x and y.
2014-12-28 22:55:14 +03:00
Useful for distance calculation.</li>
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#mathsignxtolerance" name="mathsignxtolerance">#</a><code>math.sign(x, tolerance)</code><ul>
<li><a class="anchor" href="#0_6" name="0_6">#</a>Get the sign of a number.
2014-12-28 22:55:14 +03:00
Optional: Also returns <code>0</code> when the absolute value is within the tolerance (default: <code>0</code>)</li>
</ul>
</li>
<li>`string.split(str, separator=",", include_empty=false, max_splits=-1,</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#max_splits" name="max_splits">#</a>sep_is_pattern=false)`<ul>
<li><a class="anchor" href="#max_splits_1" name="max_splits_1">#</a>If <code>max_splits</code> is negative, do not limit splits.</li>
<li><a class="anchor" href="#sep_is_pattern" name="sep_is_pattern">#</a><code>sep_is_pattern</code> specifies if separator is a plain string or a pattern (regex).</li>
<li><a class="anchor" href="#stringsplitabab" name="stringsplitabab">#</a>e.g. <code>string:split("a,b", ",") == {"a","b"}</code></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#stringtrim" name="stringtrim">#</a><code>string:trim()</code><ul>
<li><a class="anchor" href="#stringtrimnttfoobartfoobar" name="stringtrimnttfoobartfoobar">#</a>e.g. <code>string.trim("\n \t\tfoo bar\t ") == "foo bar"</code></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2016-03-19 17:25:33 +03:00
<li><a class="anchor" href="#minetestpos_to_stringxXyYzZdecimal_places" name="minetestpos_to_stringxXyYzZdecimal_places">#</a><code>minetest.pos_to_string({x=X,y=Y,z=Z}, decimal_places))</code>: returns <code>"(X,Y,Z)"</code><ul>
<li>Convert position to a printable string
Optional: 'decimal_places' will round the x, y and z of the pos to the given decimal place.</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#mineteststring_to_posstring" name="mineteststring_to_posstring">#</a><code>minetest.string_to_pos(string)</code>: returns a position<ul>
<li><a class="anchor" href="#nil" name="nil">#</a>Same but in reverse. Returns <code>nil</code> if the string can't be parsed to a position.</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#mineteststring_to_areaX1Y1Z1X2Y2Z2" name="mineteststring_to_areaX1Y1Z1X2Y2Z2">#</a><code>minetest.string_to_area("(X1, Y1, Z1) (X2, Y2, Z2)")</code>: returns two positions<ul>
2015-09-25 02:24:04 +03:00
<li>Converts a string representing an area box into two positions</li>
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestformspec_escapestring" name="minetestformspec_escapestring">#</a><code>minetest.formspec_escape(string)</code>: returns a string<ul>
2014-12-28 22:26:49 +03:00
<li>escapes the characters "[", "]", "\", "," and ";", which can not be used in formspecs</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestis_yesarg" name="minetestis_yesarg">#</a><code>minetest.is_yes(arg)</code><ul>
<li><a class="anchor" href="#arg" name="arg">#</a>returns whether <code>arg</code> can be interpreted as yes</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestget_us_time" name="minetestget_us_time">#</a><code>minetest.get_us_time()</code><ul>
2016-03-19 17:25:33 +03:00
<li>returns time with microsecond precision. May not return wall time.</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#tablecopytable" name="tablecopytable">#</a><code>table.copy(table)</code>: returns a table<ul>
<li><a class="anchor" href="#table_2" name="table_2">#</a>returns a deep copy of <code>table</code></li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
</li>
</ul>
<h2 id="minetest-namespace-reference"><code>minetest</code> namespace reference</h2>
<h3 id="utilities">Utilities</h3>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestget_current_modname" name="minetestget_current_modname">#</a><code>minetest.get_current_modname()</code>: returns the currently loading mod's name, when we are loading a mod</li>
<li><a class="anchor" href="#minetestget_modpathmodname" name="minetestget_modpathmodname">#</a><code>minetest.get_modpath(modname)</code>: returns e.g. <code>"/home/user/.minetest/usermods/modname"</code><ul>
<li><a class="anchor" href="#lua" name="lua">#</a>Useful for loading additional <code>.lua</code> modules or static data from mod</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestget_modnames" name="minetestget_modnames">#</a><code>minetest.get_modnames()</code>: returns a list of installed mods<ul>
2014-12-28 22:26:49 +03:00
<li>Return a list of installed mods, sorted alphabetically</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestget_worldpath" name="minetestget_worldpath">#</a><code>minetest.get_worldpath()</code>: returns e.g. <code>"/home/user/.minetest/world"</code><ul>
2014-12-28 22:26:49 +03:00
<li>Useful for storing custom data</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestis_singleplayer" name="minetestis_singleplayer">#</a><code>minetest.is_singleplayer()</code></li>
<li><a class="anchor" href="#minetestfeatures" name="minetestfeatures">#</a><code>minetest.features</code><ul>
<li><a class="anchor" href="#footruebartrue" name="footruebartrue">#</a>Table containing API feature flags: <code>{foo=true, bar=true}</code></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetesthas_featurearg" name="minetesthas_featurearg">#</a><code>minetest.has_feature(arg)</code>: returns <code>boolean, missing_features</code><ul>
<li><a class="anchor" href="#arg_1" name="arg_1">#</a><code>arg</code>: string or table in format <code>{foo=true, bar=true}</code></li>
<li><a class="anchor" href="#missing_features" name="missing_features">#</a><code>missing_features</code>: <code>{foo=true, bar=true}</code></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestget_player_informationplayer_name" name="minetestget_player_informationplayer_name">#</a><code>minetest.get_player_information(player_name)</code>: returns a table containing
2015-05-27 12:53:46 +03:00
information about player. Example return value:
{
address = "127.0.0.1", -- IP address of client
ip_version = 4, -- IPv4 / IPv6
min_rtt = 0.01, -- minimum round trip time
max_rtt = 0.2, -- maximum round trip time
avg_rtt = 0.02, -- average round trip time
min_jitter = 0.01, -- minimum packet time jitter
max_jitter = 0.5, -- maximum packet time jitter
avg_jitter = 0.03, -- average packet time jitter
connection_uptime = 200, -- seconds since client connected<pre><code> -- following information is available on debug build only!!!
2014-12-28 22:26:49 +03:00
-- DO NOT USE IN MODS
--ser_vers = 26, -- serialization version used by client
--prot_vers = 23, -- protocol version used by client
--major = 0, -- major version number
--minor = 4, -- minor version number
--patch = 10, -- patch version number
--vers_string = "0.4.9-git", -- full version string
--state = "Active" -- current client state
}
</code></pre>
2015-05-27 12:53:46 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestmkdirpath" name="minetestmkdirpath">#</a><code>minetest.mkdir(path)</code>: returns success.</li>
<li><a class="anchor" href="#path" name="path">#</a>Creates a directory specified by <code>path</code>, creating parent directories
2015-05-27 12:53:46 +03:00
if they don't exist.</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestget_dir_listpathis_dir" name="minetestget_dir_listpathis_dir">#</a><code>minetest.get_dir_list(path, [is_dir])</code>: returns list of entry names</li>
2015-05-27 12:53:46 +03:00
<li>is_dir is one of:</li>
<li>nil: return all entries,</li>
<li>true: return only subdirectory names, or</li>
<li>false: return only file names.</li>
2016-11-12 19:27:07 +03:00
<li><a class="anchor" href="#minetestget_version" name="minetestget_version">#</a><code>minetest.get_version()</code>: returns a table containing components of the
engine version. Components:</li>
<li><a class="anchor" href="#project" name="project">#</a><code>project</code>: Name of the project, eg, "Minetest"</li>
<li><a class="anchor" href="#string" name="string">#</a><code>string</code>: Simple version, eg, "1.2.3-dev"</li>
<li><a class="anchor" href="#hash" name="hash">#</a><code>hash</code>: Full git version (only set if available), eg, "1.2.3-dev-01234567-dirty"
Use this for informational purposes only. The information in the returned
table does not represent the capabilities of the engine, nor is it
reliable or verifyable. Compatible forks will have a different name and
version entirely. To check for the presence of engine features, test
whether the functions exported by the wanted features exist. For example:
<code>if core.nodeupdate then ... end</code>.</li>
2015-05-27 12:53:46 +03:00
</ul>
</li>
</ul>
2014-12-28 22:55:14 +03:00
<h3 id="logging">Logging</h3>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestdebug" name="minetestdebug">#</a><code>minetest.debug(...)</code><ul>
<li><a class="anchor" href="#minetestlogtableconcatt" name="minetestlogtableconcatt">#</a>Equivalent to <code>minetest.log(table.concat({...}, "\t"))</code></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestlogleveltext" name="minetestlogleveltext">#</a><code>minetest.log([level,] text)</code><ul>
<li><a class="anchor" href="#level_2" name="level_2">#</a><code>level</code> is one of <code>"none"</code>, <code>"error"</code>, <code>"warning"</code>, <code>"action"</code>,
2015-10-26 03:16:41 +03:00
<code>"info"</code>, or <code>"verbose"</code>. Default is <code>"none"</code>.</li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
</li>
</ul>
<h3 id="registration-functions">Registration functions</h3>
2014-12-28 22:26:49 +03:00
<p>Call these functions only at load time!</p>
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestregister_entitynameprototypetable_1" name="minetestregister_entitynameprototypetable_1">#</a><code>minetest.register_entity(name, prototype table)</code></li>
<li><a class="anchor" href="#minetestregister_abmabmdefinition" name="minetestregister_abmabmdefinition">#</a><code>minetest.register_abm(abm definition)</code></li>
2016-03-19 17:25:33 +03:00
<li><a class="anchor" href="#minetestregister_lbmlbmdefinition" name="minetestregister_lbmlbmdefinition">#</a><code>minetest.register_lbm(lbm definition)</code></li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestregister_nodenamenodedefinition_1" name="minetestregister_nodenamenodedefinition_1">#</a><code>minetest.register_node(name, node definition)</code></li>
<li><a class="anchor" href="#minetestregister_toolnameitemdefinition_1" name="minetestregister_toolnameitemdefinition_1">#</a><code>minetest.register_tool(name, item definition)</code></li>
<li><a class="anchor" href="#minetestregister_craftitemnameitemdefinition_1" name="minetestregister_craftitemnameitemdefinition_1">#</a><code>minetest.register_craftitem(name, item definition)</code></li>
2016-11-12 19:27:07 +03:00
<li><a class="anchor" href="#minetestunregister_itemname_1" name="minetestunregister_itemname_1">#</a><code>minetest.unregister_item(name)</code></li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestregister_aliasnameconvert_to" name="minetestregister_aliasnameconvert_to">#</a><code>minetest.register_alias(name, convert_to)</code></li>
2016-11-12 19:27:07 +03:00
<li><a class="anchor" href="#minetestregister_alias_forcenameconvert_to" name="minetestregister_alias_forcenameconvert_to">#</a><code>minetest.register_alias_force(name, convert_to)</code></li>
2016-07-22 21:37:58 +03:00
<li><a class="anchor" href="#minetestregister_craftrecipe" name="minetestregister_craftrecipe">#</a><code>minetest.register_craft(recipe)</code><ul>
<li>Check recipe table syntax for different types below.</li>
</ul>
</li>
<li><a class="anchor" href="#minetestclear_craftrecipe" name="minetestclear_craftrecipe">#</a><code>minetest.clear_craft(recipe)</code><ul>
<li>Will erase existing craft based either on output item or on input recipe.</li>
<li><a class="anchor" href="#minetestregister_craftrecipe_1" name="minetestregister_craftrecipe_1">#</a>Specify either output or input only. If you specify both, input will be ignored. For input use the same recipe table
syntax as for <code>minetest.register_craft(recipe)</code>. For output specify only the item, without a quantity.</li>
<li>If no erase candidate could be found, Lua exception will be thrown.</li>
<li>Warning! The type field ("shaped","cooking" or any other) will be ignored if the recipe
contains output. Erasing is then done independently from the crafting method.</li>
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestregister_oreoredefinition_1" name="minetestregister_oreoredefinition_1">#</a><code>minetest.register_ore(ore definition)</code></li>
2016-11-12 19:27:07 +03:00
<li><a class="anchor" href="#minetestregister_biomebiomedefinition_1" name="minetestregister_biomebiomedefinition_1">#</a><code>minetest.register_biome(biome definition)</code></li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestregister_decorationdecorationdefinition_1" name="minetestregister_decorationdecorationdefinition_1">#</a><code>minetest.register_decoration(decoration definition)</code></li>
2016-11-12 19:27:07 +03:00
<li><a class="anchor" href="#minetestoverride_itemnameredefinition" name="minetestoverride_itemnameredefinition">#</a><code>minetest.override_item(name, redefinition)</code><ul>
2014-12-28 22:26:49 +03:00
<li>Overrides fields of an item registered with register_node/tool/craftitem.</li>
<li>Note: Item must already be defined, (opt)depend on the mod defining it.</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestoverride_itemdefaultmeselight_sourceLIGHT_MAX" name="minetestoverride_itemdefaultmeselight_sourceLIGHT_MAX">#</a>Example: <code>minetest.override_item("default:mese", {light_source=LIGHT_MAX})</code></li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
</li>
2016-11-12 19:27:07 +03:00
<li><a class="anchor" href="#minetestclear_registered_ores_1" name="minetestclear_registered_ores_1">#</a><code>minetest.clear_registered_ores()</code></li>
<li><a class="anchor" href="#minetestclear_registered_biomes_1" name="minetestclear_registered_biomes_1">#</a><code>minetest.clear_registered_biomes()</code></li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestclear_registered_decorations_1" name="minetestclear_registered_decorations_1">#</a><code>minetest.clear_registered_decorations()</code></li>
2014-12-28 22:55:14 +03:00
</ul>
<h3 id="global-callback-registration-functions">Global callback registration functions</h3>
2014-12-28 22:26:49 +03:00
<p>Call these functions only at load time!</p>
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestregister_globalstepfuncdtime" name="minetestregister_globalstepfuncdtime">#</a><code>minetest.register_globalstep(func(dtime))</code><ul>
2014-12-28 22:26:49 +03:00
<li>Called every server step, usually interval of 0.1s</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestregister_on_shutdownfunc" name="minetestregister_on_shutdownfunc">#</a><code>minetest.register_on_shutdown(func())</code><ul>
2014-12-28 22:26:49 +03:00
<li>Called before server shutdown</li>
<li><strong>Warning</strong>: If the server terminates abnormally (i.e. crashes), the registered
2014-12-28 22:55:14 +03:00
callbacks <strong>will likely not be run</strong>. Data should be saved at
semi-frequent intervals as well as on server shutdown.</li>
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestregister_on_placenodefuncposnewnodeplaceroldnodeitemstackpointed_thing" name="minetestregister_on_placenodefuncposnewnodeplaceroldnodeitemstackpointed_thing">#</a><code>minetest.register_on_placenode(func(pos, newnode, placer, oldnode, itemstack, pointed_thing))</code><ul>
2014-12-28 22:26:49 +03:00
<li>Called when a node has been placed</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#true_4" name="true_4">#</a>If return <code>true</code> no item is taken from <code>itemstack</code></li>
<li><a class="anchor" href="#on_construct" name="on_construct">#</a><strong>Not recommended</strong>; use <code>on_construct</code> or <code>after_place_node</code> in node definition
2014-12-28 22:55:14 +03:00
whenever possible</li>
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestregister_on_dignodefuncposoldnodedigger" name="minetestregister_on_dignodefuncposoldnodedigger">#</a><code>minetest.register_on_dignode(func(pos, oldnode, digger))</code><ul>
2014-12-28 22:26:49 +03:00
<li>Called when a node has been dug.</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#on_destruct" name="on_destruct">#</a><strong>Not recommended</strong>; Use <code>on_destruct</code> or <code>after_dig_node</code> in node definition
2014-12-28 22:55:14 +03:00
whenever possible</li>
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestregister_on_punchnodefuncposnodepuncherpointed_thing" name="minetestregister_on_punchnodefuncposnodepuncherpointed_thing">#</a><code>minetest.register_on_punchnode(func(pos, node, puncher, pointed_thing))</code><ul>
2014-12-28 22:26:49 +03:00
<li>Called when a node is punched</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestregister_on_generatedfuncminpmaxpblockseed" name="minetestregister_on_generatedfuncminpmaxpblockseed">#</a><code>minetest.register_on_generated(func(minp, maxp, blockseed))</code><ul>
2014-12-28 22:26:49 +03:00
<li>Called after generating a piece of world. Modifying nodes inside the area
2014-12-28 22:55:14 +03:00
is a bit faster than usually.</li>
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestregister_on_newplayerfuncObjectRef" name="minetestregister_on_newplayerfuncObjectRef">#</a><code>minetest.register_on_newplayer(func(ObjectRef))</code><ul>
2014-12-28 22:26:49 +03:00
<li>Called after a new player has been created</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestregister_on_dieplayerfuncObjectRef" name="minetestregister_on_dieplayerfuncObjectRef">#</a><code>minetest.register_on_dieplayer(func(ObjectRef))</code><ul>
2014-12-28 22:26:49 +03:00
<li>Called when a player dies</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestregister_on_punchplayerfuncplayerhittertime_from_last_punchtool_capabilitiesdirdamage" name="minetestregister_on_punchplayerfuncplayerhittertime_from_last_punchtool_capabilitiesdirdamage">#</a><code>minetest.register_on_punchplayer(func(player, hitter, time_from_last_punch, tool_capabilities, dir, damage))</code><ul>
2015-05-27 12:53:46 +03:00
<li>Called when a player is punched</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#player" name="player">#</a><code>player</code> - ObjectRef - Player that was punched</li>
<li><a class="anchor" href="#hitter" name="hitter">#</a><code>hitter</code> - ObjectRef - Player that hit</li>
<li><a class="anchor" href="#time_from_last_punch_1" name="time_from_last_punch_1">#</a><code>time_from_last_punch</code>: Meant for disallowing spamming of clicks (can be nil)</li>
<li><a class="anchor" href="#tool_capabilities_1" name="tool_capabilities_1">#</a><code>tool_capabilities</code>: capability table of used tool (can be nil)</li>
<li><a class="anchor" href="#dir" name="dir">#</a><code>dir</code>: unit vector of direction of punch. Always defined. Points from
2015-05-27 12:53:46 +03:00
the puncher to the punched.</li>
2017-01-31 17:21:12 +03:00
<li><a class="anchor" href="#damage_1" name="damage_1">#</a><code>damage</code> - number that represents the damage calculated by the engine</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#true_5" name="true_5">#</a>should return <code>true</code> to prevent the default damage mechanism</li>
2015-05-27 12:53:46 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestregister_on_player_hpchangefuncplayerhp_changemodifier" name="minetestregister_on_player_hpchangefuncplayerhp_changemodifier">#</a><code>minetest.register_on_player_hpchange(func(player, hp_change), modifier)</code><ul>
2015-07-08 11:43:59 +03:00
<li>Called when the player gets damaged or healed</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#player_1" name="player_1">#</a><code>player</code>: ObjectRef of the player</li>
<li><a class="anchor" href="#hp_change" name="hp_change">#</a><code>hp_change</code>: the amount of change. Negative when it is damage.</li>
<li><a class="anchor" href="#modifier" name="modifier">#</a><code>modifier</code>: when true, the function should return the actual hp_change.
2015-07-08 11:43:59 +03:00
Note: modifiers only get a temporary hp_change that can be modified by later modifiers.
2016-05-26 20:47:50 +03:00
modifiers can return true as a second argument to stop the execution of further functions.
Non-modifiers receive the final hp change calculated by the modifiers.</li>
2015-07-08 11:43:59 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestregister_on_respawnplayerfuncObjectRef" name="minetestregister_on_respawnplayerfuncObjectRef">#</a><code>minetest.register_on_respawnplayer(func(ObjectRef))</code><ul>
2014-12-28 22:26:49 +03:00
<li>Called when player is to be respawned</li>
<li>Called <em>before</em> repositioning of player occurs</li>
<li>return true in func to disable regular player placement</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestregister_on_prejoinplayerfuncnameip" name="minetestregister_on_prejoinplayerfuncnameip">#</a><code>minetest.register_on_prejoinplayer(func(name, ip))</code><ul>
2014-12-28 22:26:49 +03:00
<li>Called before a player joins the game</li>
<li>If it returns a string, the player is disconnected with that string as reason</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestregister_on_joinplayerfuncObjectRef" name="minetestregister_on_joinplayerfuncObjectRef">#</a><code>minetest.register_on_joinplayer(func(ObjectRef))</code><ul>
2014-12-28 22:26:49 +03:00
<li>Called when a player joins the game</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2016-07-22 21:37:58 +03:00
<li><a class="anchor" href="#minetestregister_on_leaveplayerfuncObjectReftimed_out" name="minetestregister_on_leaveplayerfuncObjectReftimed_out">#</a><code>minetest.register_on_leaveplayer(func(ObjectRef, timed_out))</code><ul>
2014-12-28 22:26:49 +03:00
<li>Called when a player leaves the game</li>
2016-07-22 21:37:58 +03:00
<li><a class="anchor" href="#timed_out" name="timed_out">#</a><code>timed_out</code>: True for timeout, false for other reasons.</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestregister_on_cheatfuncObjectRefcheat" name="minetestregister_on_cheatfuncObjectRefcheat">#</a><code>minetest.register_on_cheat(func(ObjectRef, cheat))</code><ul>
2014-12-28 22:26:49 +03:00
<li>Called when a player cheats</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#cheat" name="cheat">#</a><code>cheat</code>: <code>{type=&lt;cheat_type&gt;}</code>, where <code>&lt;cheat_type&gt;</code> is one of:<ul>
2016-12-29 00:57:48 +03:00
<li><a class="anchor" href="#moved_too_fast" name="moved_too_fast">#</a><code>moved_too_fast</code></li>
<li><a class="anchor" href="#interacted_too_far" name="interacted_too_far">#</a><code>interacted_too_far</code></li>
<li><a class="anchor" href="#interacted_while_dead" name="interacted_while_dead">#</a><code>interacted_while_dead</code></li>
<li><a class="anchor" href="#finished_unknown_dig" name="finished_unknown_dig">#</a><code>finished_unknown_dig</code></li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#dug_unbreakable" name="dug_unbreakable">#</a><code>dug_unbreakable</code></li>
<li><a class="anchor" href="#dug_too_fast" name="dug_too_fast">#</a><code>dug_too_fast</code></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestregister_on_chat_messagefuncnamemessage" name="minetestregister_on_chat_messagefuncnamemessage">#</a><code>minetest.register_on_chat_message(func(name, message))</code><ul>
2014-12-28 22:26:49 +03:00
<li>Called always when a player says something</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#true_6" name="true_6">#</a>Return <code>true</code> to mark the message as handled, which means that it will not be sent to other players</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestregister_on_player_receive_fieldsfuncplayerformnamefields" name="minetestregister_on_player_receive_fieldsfuncplayerformnamefields">#</a><code>minetest.register_on_player_receive_fields(func(player, formname, fields))</code><ul>
2014-12-28 22:26:49 +03:00
<li>Called when a button is pressed in player's inventory form</li>
<li>Newest functions are called first</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#true_7" name="true_7">#</a>If function returns <code>true</code>, remaining functions are not called</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestregister_on_craftfuncitemstackplayerold_craft_gridcraft_inv" name="minetestregister_on_craftfuncitemstackplayerold_craft_gridcraft_inv">#</a><code>minetest.register_on_craft(func(itemstack, player, old_craft_grid, craft_inv))</code><ul>
<li><a class="anchor" href="#player_2" name="player_2">#</a>Called when <code>player</code> crafts something</li>
<li><a class="anchor" href="#itemstack_2" name="itemstack_2">#</a><code>itemstack</code> is the output</li>
<li><a class="anchor" href="#old_craft_grid" name="old_craft_grid">#</a><code>old_craft_grid</code> contains the recipe (Note: the one in the inventory is cleared)</li>
<li><a class="anchor" href="#craft_inv" name="craft_inv">#</a><code>craft_inv</code> is the inventory with the crafting grid</li>
<li><a class="anchor" href="#ItemStack" name="ItemStack">#</a>Return either an <code>ItemStack</code>, to replace the output, or <code>nil</code>, to not modify it</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestregister_craft_predictfuncitemstackplayerold_craft_gridcraft_inv" name="minetestregister_craft_predictfuncitemstackplayerold_craft_gridcraft_inv">#</a><code>minetest.register_craft_predict(func(itemstack, player, old_craft_grid, craft_inv))</code><ul>
2014-12-28 22:26:49 +03:00
<li>The same as before, except that it is called before the player crafts, to make
2014-12-28 22:55:14 +03:00
craft prediction, and it should not change anything.</li>
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestregister_on_protection_violationfuncposname" name="minetestregister_on_protection_violationfuncposname">#</a><code>minetest.register_on_protection_violation(func(pos, name))</code><ul>
<li><a class="anchor" href="#builtin" name="builtin">#</a>Called by <code>builtin</code> and mods when a player violates protection at a position
2014-12-28 22:55:14 +03:00
(eg, digs a node or punches a protected entity).</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestrecord_protection_violation" name="minetestrecord_protection_violation">#</a>The registered functions can be called using <code>minetest.record_protection_violation</code></li>
2014-12-28 22:26:49 +03:00
<li>The provided function should check that the position is protected by the mod
2014-12-28 22:55:14 +03:00
calling this function before it prints a message, if it does, to allow for
multiple protection mods.</li>
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestregister_on_item_eatfunchp_changereplace_with_itemitemstackuserpointed_thing" name="minetestregister_on_item_eatfunchp_changereplace_with_itemitemstackuserpointed_thing">#</a><code>minetest.register_on_item_eat(func(hp_change, replace_with_item, itemstack, user, pointed_thing))</code><ul>
<li><a class="anchor" href="#minetestitem_eat" name="minetestitem_eat">#</a>Called when an item is eaten, by <code>minetest.item_eat</code></li>
<li><a class="anchor" href="#true_8" name="true_8">#</a>Return <code>true</code> or <code>itemstack</code> to cancel the default item eat response (i.e.: hp increase)</li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
</li>
</ul>
<h3 id="other-registration-functions">Other registration functions</h3>
2014-12-28 22:26:49 +03:00
<ul>
2017-01-31 17:21:12 +03:00
<li><a class="anchor" href="#minetestregister_chatcommandcmdchatcommanddefinition" name="minetestregister_chatcommandcmdchatcommanddefinition">#</a><code>minetest.register_chatcommand(cmd, chatcommand definition)</code><ul>
<li>Adds definition to minetest.registered_chatcommands</li>
</ul>
</li>
<li><a class="anchor" href="#minetestoverride_chatcommandnameredefinition" name="minetestoverride_chatcommandnameredefinition">#</a><code>minetest.override_chatcommand(name, redefinition)</code><ul>
<li>Overrides fields of a chatcommand registered with register_chatcommand.</li>
</ul>
</li>
<li><a class="anchor" href="#minetestunregister_chatcommandname" name="minetestunregister_chatcommandname">#</a><code>minetest.unregister_chatcommand(name)</code><ul>
<li>Unregisters a chatcommands registered with register_chatcommand.</li>
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestregister_privilegenamedefinition" name="minetestregister_privilegenamedefinition">#</a><code>minetest.register_privilege(name, definition)</code><ul>
<li><a class="anchor" href="#definition" name="definition">#</a><code>definition</code>: <code>"description text"</code></li>
2016-07-22 21:37:58 +03:00
<li><a class="anchor" href="#definition_1" name="definition_1">#</a><code>definition</code>: <code>{ description = "description text", give_to_singleplayer = boolean}</code>
2016-08-29 15:43:46 +03:00
the default of <code>give_to_singleplayer</code> is true</li>
2016-05-26 20:47:50 +03:00
<li>To allow players with basic_privs to grant, see basic_privs minetest.conf setting.</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestregister_authentication_handlerhandler" name="minetestregister_authentication_handlerhandler">#</a><code>minetest.register_authentication_handler(handler)</code><ul>
<li><a class="anchor" href="#minetestbuiltin_auth_handler" name="minetestbuiltin_auth_handler">#</a>See <code>minetest.builtin_auth_handler</code> in <code>builtin.lua</code> for reference</li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
</li>
</ul>
<h3 id="setting-related">Setting-related</h3>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestsetting_setnamevalue" name="minetestsetting_setnamevalue">#</a><code>minetest.setting_set(name, value)</code><ul>
2015-05-27 12:53:46 +03:00
<li>Setting names can't contain whitespace or any of <code>="{}#</code>.</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#n_2" name="n_2">#</a>Setting values can't contain the sequence <code>\n"""</code>.</li>
2015-05-27 12:53:46 +03:00
<li>Setting names starting with "secure." can't be set.</li>
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestsetting_getname" name="minetestsetting_getname">#</a><code>minetest.setting_get(name)</code>: returns string or <code>nil</code></li>
<li><a class="anchor" href="#minetestsetting_setboolnamevalue" name="minetestsetting_setboolnamevalue">#</a><code>minetest.setting_setbool(name, value)</code><ul>
<li><a class="anchor" href="#setting_set" name="setting_set">#</a>See documentation on <code>setting_set</code> for restrictions.</li>
2015-05-27 12:53:46 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestsetting_getboolname" name="minetestsetting_getboolname">#</a><code>minetest.setting_getbool(name)</code>: returns boolean or <code>nil</code></li>
<li><a class="anchor" href="#minetestsetting_get_posname" name="minetestsetting_get_posname">#</a><code>minetest.setting_get_pos(name)</code>: returns position or nil</li>
<li><a class="anchor" href="#minetestsetting_save" name="minetestsetting_save">#</a><code>minetest.setting_save()</code>, returns <code>nil</code>, save all settings to config file</li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
<h3 id="authentication">Authentication</h3>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestnotify_authentication_modifiedname" name="minetestnotify_authentication_modifiedname">#</a><code>minetest.notify_authentication_modified(name)</code><ul>
2014-12-28 22:26:49 +03:00
<li>Should be called by the authentication handler if privileges changes.</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#namenil" name="namenil">#</a>To report everybody, set <code>name=nil</code>.</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2016-07-22 21:37:58 +03:00
<li><a class="anchor" href="#minetestcheck_password_entrynameentrypassword" name="minetestcheck_password_entrynameentrypassword">#</a><code>minetest.check_password_entry(name, entry, password)</code><ul>
<li>Returns true if the "db entry" for a player with name matches given</li>
<li>password, false otherwise.</li>
<li>The "db entry" is the usually player-individual value that is derived</li>
<li>from the player's chosen password and stored on the server in order to allow</li>
<li>authentication whenever the player desires to log in.</li>
<li>Only use this function for making it possible to log in via the password from</li>
<li>via protocols like IRC, other uses for inside the game are frowned upon.</li>
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestget_password_hashnameraw_password" name="minetestget_password_hashnameraw_password">#</a><code>minetest.get_password_hash(name, raw_password)</code><ul>
2015-12-07 21:04:11 +03:00
<li>Convert a name-password pair to a password hash that Minetest can use.</li>
<li>The returned value alone is not a good basis for password checks based</li>
<li>on comparing the password hash in the database with the password hash</li>
<li>from the function, with an externally provided password, as the hash</li>
<li>in the db might use the new SRP verifier format.</li>
2016-07-22 21:37:58 +03:00
<li>For this purpose, use minetest.check_password_entry instead.</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#mineteststring_to_privsstr" name="mineteststring_to_privsstr">#</a><code>minetest.string_to_privs(str)</code>: returns <code>{priv1=true,...}</code></li>
<li><a class="anchor" href="#minetestprivs_to_stringprivs" name="minetestprivs_to_stringprivs">#</a><code>minetest.privs_to_string(privs)</code>: returns <code>"priv1,priv2,..."</code><ul>
2014-12-28 22:26:49 +03:00
<li>Convert between two privilege representations</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestset_player_passwordnamepassword_hash" name="minetestset_player_passwordnamepassword_hash">#</a><code>minetest.set_player_password(name, password_hash)</code></li>
<li><a class="anchor" href="#minetestset_player_privsnamepriv1true" name="minetestset_player_privsnamepriv1true">#</a><code>minetest.set_player_privs(name, {priv1=true,...})</code></li>
<li><a class="anchor" href="#minetestget_player_privsnamepriv1true" name="minetestget_player_privsnamepriv1true">#</a><code>minetest.get_player_privs(name) -&gt; {priv1=true,...}</code></li>
<li><a class="anchor" href="#minetestauth_reload" name="minetestauth_reload">#</a><code>minetest.auth_reload()</code></li>
<li><a class="anchor" href="#minetestcheck_player_privsplayer_or_name" name="minetestcheck_player_privsplayer_or_name">#</a><code>minetest.check_player_privs(player_or_name, ...)</code>: returns <code>bool, missing_privs</code><ul>
2015-10-26 03:16:41 +03:00
<li>A quickhand for checking privileges.</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#player_or_name" name="player_or_name">#</a><code>player_or_name</code>: Either a Player object or the name of a player.</li>
2015-10-26 03:16:41 +03:00
<li><code>...</code> is either a list of strings, e.g. <code>"priva", "privb"</code> or
a table, e.g. <code>{ priva = true, privb = true }</code>.</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestget_player_ipname" name="minetestget_player_ipname">#</a><code>minetest.get_player_ip(name)</code>: returns an IP address string</li>
2014-12-28 22:26:49 +03:00
</ul>
<p><code>minetest.set_player_password</code>, <code>minetest_set_player_privs</code>, <code>minetest_get_player_privs</code>
and <code>minetest.auth_reload</code> call the authetification handler.</p>
2014-12-28 22:55:14 +03:00
<h3 id="chat">Chat</h3>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestchat_send_alltext" name="minetestchat_send_alltext">#</a><code>minetest.chat_send_all(text)</code></li>
<li><a class="anchor" href="#minetestchat_send_playernametext" name="minetestchat_send_playernametext">#</a><code>minetest.chat_send_player(name, text)</code></li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
<h3 id="environment-access">Environment access</h3>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestset_nodeposnode" name="minetestset_nodeposnode">#</a><code>minetest.set_node(pos, node)</code></li>
<li><a class="anchor" href="#minetestadd_nodeposnodealiasset_nodeposnode" name="minetestadd_nodeposnodealiasset_nodeposnode">#</a><code>minetest.add_node(pos, node): alias set_node(pos, node)</code><ul>
<li><a class="anchor" href="#nodenamefooparam10param20" name="nodenamefooparam10param20">#</a>Set node at position (<code>node = {name="foo", param1=0, param2=0}</code>)</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2016-12-29 00:57:48 +03:00
<li><a class="anchor" href="#minetestswap_nodeposnode" name="minetestswap_nodeposnode">#</a><code>minetest.swap_node(pos, node)</code><ul>
2014-12-28 22:26:49 +03:00
<li>Set node at position, but don't remove metadata</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestremove_nodepos" name="minetestremove_nodepos">#</a><code>minetest.remove_node(pos)</code><ul>
<li><a class="anchor" href="#set_nodeposair" name="set_nodeposair">#</a>Equivalent to <code>set_node(pos, "air")</code></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestget_nodepos" name="minetestget_nodepos">#</a><code>minetest.get_node(pos)</code><ul>
2016-03-19 17:25:33 +03:00
<li><a class="anchor" href="#namenode_nameparam10param20" name="namenode_nameparam10param20">#</a>Returns the node at the given position as table in the format
<code>{name="node_name", param1=0, param2=0}</code>, returns <code>{name="ignore", param1=0, param2=0}</code>
for unloaded areas.</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestget_node_or_nilpos" name="minetestget_node_or_nilpos">#</a><code>minetest.get_node_or_nil(pos)</code><ul>
2016-03-19 17:25:33 +03:00
<li><a class="anchor" href="#get_node" name="get_node">#</a>Same as <code>get_node</code> but returns <code>nil</code> for unloaded areas.</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestget_node_lightpostimeofday" name="minetestget_node_lightpostimeofday">#</a><code>minetest.get_node_light(pos, timeofday)</code><ul>
2015-09-25 02:24:04 +03:00
<li>Gets the light value at the given position. Note that the light value
"inside" the node at the given position is returned, so you usually want
to get the light value of a neighbor.</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#pos" name="pos">#</a><code>pos</code>: The position where to measure the light.</li>
<li><a class="anchor" href="#timeofday" name="timeofday">#</a><code>timeofday</code>: <code>nil</code> for current time, <code>0</code> for night, <code>0.5</code> for day</li>
<li><a class="anchor" href="#0_7" name="0_7">#</a>Returns a number between <code>0</code> and <code>15</code> or <code>nil</code></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestplace_nodeposnode" name="minetestplace_nodeposnode">#</a><code>minetest.place_node(pos, node)</code><ul>
2014-12-28 22:26:49 +03:00
<li>Place node with the same effects that a player would cause</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestdig_nodepos" name="minetestdig_nodepos">#</a><code>minetest.dig_node(pos)</code><ul>
2014-12-28 22:26:49 +03:00
<li>Dig node with the same effects that a player would cause</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#true_9" name="true_9">#</a>Returns <code>true</code> if successful, <code>false</code> on failure (e.g. protected location)</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestpunch_nodepos" name="minetestpunch_nodepos">#</a>
2014-12-28 22:55:14 +03:00
<p><code>minetest.punch_node(pos)</code></p>
2014-12-28 22:26:49 +03:00
<ul>
<li>Punch node with the same effects that a player would cause</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestfind_nodes_with_metapos1pos2" name="minetestfind_nodes_with_metapos1pos2">#</a>
2015-05-08 20:55:17 +03:00
<p><code>minetest.find_nodes_with_meta(pos1, pos2)</code></p>
2014-12-28 22:26:49 +03:00
<ul>
2015-05-08 20:55:17 +03:00
<li>Get a table of positions of nodes that have metadata within a region {pos1, pos2}</li>
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestget_metapos" name="minetestget_metapos">#</a><code>minetest.get_meta(pos)</code><ul>
<li><a class="anchor" href="#NodeMetaRef" name="NodeMetaRef">#</a>Get a <code>NodeMetaRef</code> at that position</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestget_node_timerpos" name="minetestget_node_timerpos">#</a>
2014-12-28 22:55:14 +03:00
<p><code>minetest.get_node_timer(pos)</code></p>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#NodeTimerRef" name="NodeTimerRef">#</a>Get <code>NodeTimerRef</code></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2017-01-31 17:21:12 +03:00
<li><a class="anchor" href="#minetestadd_entityposnamestaticdata" name="minetestadd_entityposnamestaticdata">#</a>
<p><code>minetest.add_entity(pos, name, [staticdata])</code>: Spawn Lua-defined entity at position</p>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#ObjectRef" name="ObjectRef">#</a>Returns <code>ObjectRef</code>, or <code>nil</code> if failed</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestadd_itempositem" name="minetestadd_itempositem">#</a><code>minetest.add_item(pos, item)</code>: Spawn item<ul>
<li><a class="anchor" href="#ObjectRef_1" name="ObjectRef_1">#</a>Returns <code>ObjectRef</code>, or <code>nil</code> if failed</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestget_player_by_namename" name="minetestget_player_by_namename">#</a><code>minetest.get_player_by_name(name)</code>: Get an <code>ObjectRef</code> to a player</li>
<li><a class="anchor" href="#minetestget_objects_inside_radiusposradius" name="minetestget_objects_inside_radiusposradius">#</a><code>minetest.get_objects_inside_radius(pos, radius)</code><ul>
<li><a class="anchor" href="#radius" name="radius">#</a><code>radius</code>: using an euclidean metric</li>
2015-10-26 03:16:41 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestset_timeofdayval" name="minetestset_timeofdayval">#</a><code>minetest.set_timeofday(val)</code><ul>
<li><a class="anchor" href="#val" name="val">#</a><code>val</code> is between <code>0</code> and <code>1</code>; <code>0</code> for midnight, <code>0.5</code> for midday</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestget_timeofday" name="minetestget_timeofday">#</a><code>minetest.get_timeofday()</code></li>
<li><a class="anchor" href="#minetestget_gametime" name="minetestget_gametime">#</a><code>minetest.get_gametime()</code>: returns the time, in seconds, since the world was created</li>
2016-03-19 17:25:33 +03:00
<li><a class="anchor" href="#minetestget_day_count" name="minetestget_day_count">#</a><code>minetest.get_day_count()</code>: returns number days elapsed since world was created,<ul>
<li>accounting for time changes.</li>
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestfind_node_nearposradiusnodenames" name="minetestfind_node_nearposradiusnodenames">#</a><code>minetest.find_node_near(pos, radius, nodenames)</code>: returns pos or <code>nil</code><ul>
<li><a class="anchor" href="#radius_1" name="radius_1">#</a><code>radius</code>: using a maximum metric</li>
<li><a class="anchor" href="#nodenames" name="nodenames">#</a><code>nodenames</code>: e.g. <code>{"ignore", "group:tree"}</code> or <code>"default:dirt"</code></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestfind_nodes_in_areaminpmaxpnodenames" name="minetestfind_nodes_in_areaminpmaxpnodenames">#</a><code>minetest.find_nodes_in_area(minp, maxp, nodenames)</code>: returns a list of positions<ul>
2015-07-08 11:43:59 +03:00
<li>returns as second value a table with the count of the individual nodes found</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#nodenames_1" name="nodenames_1">#</a><code>nodenames</code>: e.g. <code>{"ignore", "group:tree"}</code> or <code>"default:dirt"</code></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestfind_nodes_in_area_under_airminpmaxpnodenames" name="minetestfind_nodes_in_area_under_airminpmaxpnodenames">#</a><code>minetest.find_nodes_in_area_under_air(minp, maxp, nodenames)</code>: returns a list of positions<ul>
2015-03-17 21:18:48 +03:00
<li>returned positions are nodes with a node air above</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#nodenames_2" name="nodenames_2">#</a><code>nodenames</code>: e.g. <code>{"ignore", "group:tree"}</code> or <code>"default:dirt"</code></li>
2015-03-17 21:18:48 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestget_perlinnoiseparams" name="minetestget_perlinnoiseparams">#</a><code>minetest.get_perlin(noiseparams)</code></li>
<li><a class="anchor" href="#minetestget_perlinseeddiffoctavespersistencescale" name="minetestget_perlinseeddiffoctavespersistencescale">#</a><code>minetest.get_perlin(seeddiff, octaves, persistence, scale)</code><ul>
<li><a class="anchor" href="#intworldseedseeddiff" name="intworldseedseeddiff">#</a>Return world-specific perlin noise (<code>int(worldseed)+seeddiff</code>)</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestget_voxel_manippos1pos2" name="minetestget_voxel_manippos1pos2">#</a><code>minetest.get_voxel_manip([pos1, pos2])</code><ul>
<li>Return voxel manipulator object.</li>
<li>Loads the manipulator from the map if positions are passed.</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestset_gen_notifyflagsdeco_ids" name="minetestset_gen_notifyflagsdeco_ids">#</a><code>minetest.set_gen_notify(flags, {deco_ids})</code><ul>
2014-12-28 22:26:49 +03:00
<li>Set the types of on-generate notifications that should be collected</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#flags_1" name="flags_1">#</a><code>flags</code> is a flag field with the available flags: <code>dungeon</code>, <code>temple</code>, <code>cave_begin</code>,
2014-12-28 22:55:14 +03:00
<code>cave_end</code>, <code>large_cave_begin</code>, <code>large_cave_end</code>, <code>decoration</code></li>
</ul>
</li>
2014-12-28 22:26:49 +03:00
<li>The second parameter is a list of IDS of decorations which notification is requested for</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#get_gen_notify" name="get_gen_notify">#</a><code>get_gen_notify()</code>: returns a flagstring and a table with the deco_ids</li>
<li><a class="anchor" href="#minetestget_mapgen_objectobjectname" name="minetestget_mapgen_objectobjectname">#</a><code>minetest.get_mapgen_object(objectname)</code><ul>
2014-12-28 22:26:49 +03:00
<li>Return requested mapgen object if available (see "Mapgen objects")</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestget_biome_idbiome_name" name="minetestget_biome_idbiome_name">#</a><code>minetest.get_biome_id(biome_name)</code><ul>
2015-10-26 03:16:41 +03:00
<li>Returns the biome id, as used in the biomemap Mapgen object, for a
given biome_name string.</li>
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestget_mapgen_params" name="minetestget_mapgen_params">#</a><code>minetest.get_mapgen_params()</code> Returns mapgen parameters, a table containing
<code>mgname</code>, <code>seed</code>, <code>chunksize</code>, <code>water_level</code>, and <code>flags</code>.</li>
2016-07-22 21:37:58 +03:00
<li>Deprecated: use minetest.get_mapgen_setting(name) instead</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestset_mapgen_paramsMapgenParams" name="minetestset_mapgen_paramsMapgenParams">#</a><code>minetest.set_mapgen_params(MapgenParams)</code><ul>
2016-07-22 21:37:58 +03:00
<li>Deprecated: use minetest.set_mapgen_setting(name, value, override) instead</li>
2014-12-28 22:26:49 +03:00
<li>Set map generation parameters</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#on_mapgen_init" name="on_mapgen_init">#</a>Function cannot be called after the registration period; only initialization
2015-03-17 21:18:48 +03:00
and <code>on_mapgen_init</code></li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#mgname" name="mgname">#</a>Takes a table as an argument with the fields <code>mgname</code>, <code>seed</code>, <code>water_level</code>,
2015-03-17 21:18:48 +03:00
and <code>flags</code>.<ul>
2014-12-28 22:26:49 +03:00
<li>Leave field unset to leave that parameter unchanged</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#flags_2" name="flags_2">#</a><code>flags</code> contains a comma-delimited string of flags to set,
2015-01-24 22:07:00 +03:00
or if the prefix <code>"no"</code> is attached, clears instead.</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#flags_3" name="flags_3">#</a><code>flags</code> is in the same format and has the same options as <code>mg_flags</code> in <code>minetest.conf</code></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
</ul>
</li>
2016-07-22 21:37:58 +03:00
<li><a class="anchor" href="#minetestget_mapgen_settingname" name="minetestget_mapgen_settingname">#</a><code>minetest.get_mapgen_setting(name)</code><ul>
<li>Gets the <em>active</em> mapgen setting (or nil if none exists) in string format with the following
order of precedence:
1) Settings loaded from map_meta.txt or overrides set during mod execution
2) Settings set by mods without a metafile override
3) Settings explicitly set in the user config file, minetest.conf
4) Settings set as the user config default</li>
</ul>
</li>
<li><a class="anchor" href="#minetestget_mapgen_setting_noiseparamsname" name="minetestget_mapgen_setting_noiseparamsname">#</a><code>minetest.get_mapgen_setting_noiseparams(name)</code><ul>
2016-11-12 19:27:07 +03:00
<li><a class="anchor" href="#name_10" name="name_10">#</a>Same as above, but returns the value as a NoiseParams table if the setting <code>name</code> exists
2016-07-22 21:37:58 +03:00
and is a valid NoiseParams</li>
</ul>
</li>
2016-11-12 19:27:07 +03:00
<li><a class="anchor" href="#minetestset_mapgen_settingnamevalueoverride_meta" name="minetestset_mapgen_settingnamevalueoverride_meta">#</a><code>minetest.set_mapgen_setting(name, value, [override_meta])</code></li>
2016-07-22 21:37:58 +03:00
<li><a class="anchor" href="#value" name="value">#</a>Sets a mapgen param to <code>value</code>, and will take effect if the corresponding mapgen setting
2016-11-12 19:27:07 +03:00
is not already present in map_meta.txt.</li>
<li><a class="anchor" href="#override_meta" name="override_meta">#</a><code>override_meta</code> is an optional boolean (default: <code>false</code>). If this is set to true,
the setting will become the active setting regardless of the map metafile contents.</li>
2016-07-22 21:37:58 +03:00
<li>Note: to set the seed, use "seed", not "fixed_map_seed"</li>
2016-11-12 19:27:07 +03:00
<li><a class="anchor" href="#minetestset_mapgen_setting_noiseparamsnamevalueoverride_meta" name="minetestset_mapgen_setting_noiseparamsnamevalueoverride_meta">#</a><code>minetest.set_mapgen_setting_noiseparams(name, value, [override_meta])</code></li>
<li>Same as above, except value is a NoiseParams table.</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestset_noiseparamsnamenoiseparamsset_default" name="minetestset_noiseparamsnamenoiseparamsset_default">#</a><code>minetest.set_noiseparams(name, noiseparams, set_default)</code><ul>
2016-11-12 19:27:07 +03:00
<li><a class="anchor" href="#name_11" name="name_11">#</a>Sets the noiseparams setting of <code>name</code> to the noiseparams table specified in <code>noiseparams</code>.</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#set_default" name="set_default">#</a><code>set_default</code> is an optional boolean (default: <code>true</code>) that specifies whether the setting
2014-12-28 22:55:14 +03:00
should be applied to the default config or current active config</li>
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestget_noiseparamsname" name="minetestget_noiseparamsname">#</a><code>minetest.get_noiseparams(name)</code>: returns a table of the noiseparams for name</li>
<li><a class="anchor" href="#minetestgenerate_oresvmpos1pos2" name="minetestgenerate_oresvmpos1pos2">#</a><code>minetest.generate_ores(vm, pos1, pos2)</code><ul>
<li><a class="anchor" href="#vm" name="vm">#</a>Generate all registered ores within the VoxelManip <code>vm</code> and in the area from <code>pos1</code> to <code>pos2</code>.</li>
<li><a class="anchor" href="#pos1" name="pos1">#</a><code>pos1</code> and <code>pos2</code> are optional and default to mapchunk minp and maxp.</li>
2015-04-29 20:17:32 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestgenerate_decorationsvmpos1pos2" name="minetestgenerate_decorationsvmpos1pos2">#</a><code>minetest.generate_decorations(vm, pos1, pos2)</code><ul>
<li><a class="anchor" href="#vm_1" name="vm_1">#</a>Generate all registered decorations within the VoxelManip <code>vm</code> and in the area from <code>pos1</code> to <code>pos2</code>.</li>
<li><a class="anchor" href="#pos1_1" name="pos1_1">#</a><code>pos1</code> and <code>pos2</code> are optional and default to mapchunk minp and maxp.</li>
2015-04-29 20:17:32 +03:00
</ul>
</li>
2016-03-19 17:25:33 +03:00
<li><a class="anchor" href="#minetestclear_objectsoptions" name="minetestclear_objectsoptions">#</a><code>minetest.clear_objects([options])</code><ul>
<li>Clear all objects in the environment</li>
<li><a class="anchor" href="#mode" name="mode">#</a>Takes an optional table as an argument with the field <code>mode</code>.<ul>
<li><a class="anchor" href="#full" name="full">#</a>mode = <code>"full"</code>: Load and go through every mapblock, clearing objects (default).</li>
<li><a class="anchor" href="#quick" name="quick">#</a>mode = <code>"quick"</code>: Clear objects immediately in loaded mapblocks;
clear objects in unloaded mapblocks only when the mapblocks are next activated.</li>
</ul>
</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestemerge_areapos1pos2callbackparam" name="minetestemerge_areapos1pos2callbackparam">#</a><code>minetest.emerge_area(pos1, pos2, [callback], [param])</code><ul>
<li><a class="anchor" href="#pos1_2" name="pos1_2">#</a>Queue all blocks in the area from <code>pos1</code> to <code>pos2</code>, inclusive, to be asynchronously</li>
2015-11-21 18:26:52 +03:00
<li>fetched from memory, loaded from disk, or if inexistent, generates them.</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#callback" name="callback">#</a>If <code>callback</code> is a valid Lua function, this will be called for each block emerged.</li>
2015-11-21 18:26:52 +03:00
<li>The function signature of callback is:</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#functionEmergeAreaCallbackblockposactioncalls_remainingparam" name="functionEmergeAreaCallbackblockposactioncalls_remainingparam">#</a><code>function EmergeAreaCallback(blockpos, action, calls_remaining, param)</code></li>
<li><a class="anchor" href="#blockpos" name="blockpos">#</a>
2015-11-21 18:26:52 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#blockpos_1" name="blockpos_1">#</a><code>blockpos</code> is the <em>block</em> coordinates of the block that had been emerged</li>
2015-11-21 18:26:52 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#action" name="action">#</a>
2015-11-21 18:26:52 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#action_1" name="action_1">#</a><code>action</code> could be one of the following constant values:</li>
2015-11-21 18:26:52 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#coreEMERGE_CANCELLED" name="coreEMERGE_CANCELLED">#</a><code>core.EMERGE_CANCELLED</code>, <code>core.EMERGE_ERRORED</code>, <code>core.EMERGE_FROM_MEMORY</code>,</li>
<li><a class="anchor" href="#coreEMERGE_FROM_DISK" name="coreEMERGE_FROM_DISK">#</a><code>core.EMERGE_FROM_DISK</code>, <code>core.EMERGE_GENERATED</code></li>
<li><a class="anchor" href="#calls_remaining" name="calls_remaining">#</a>
2015-11-21 18:26:52 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#calls_remaining_1" name="calls_remaining_1">#</a><code>calls_remaining</code> is the number of callbacks to be expected after this one</li>
2015-11-21 18:26:52 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#param" name="param">#</a>
2015-11-21 18:26:52 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#param_1" name="param_1">#</a><code>param</code> is the user-defined parameter passed to emerge_area (or nil if the</li>
2015-11-21 18:26:52 +03:00
</ul>
</li>
<li>parameter was absent)</li>
2015-09-25 02:24:04 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestdelete_areapos1pos2" name="minetestdelete_areapos1pos2">#</a><code>minetest.delete_area(pos1, pos2)</code><ul>
2015-01-24 22:07:00 +03:00
<li>delete all mapblocks in the area from pos1 to pos2, inclusive</li>
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestline_of_sightpos1pos2stepsize" name="minetestline_of_sightpos1pos2stepsize">#</a><code>minetest.line_of_sight(pos1, pos2, stepsize)</code>: returns <code>boolean, pos</code><ul>
<li><a class="anchor" href="#pos1_3" name="pos1_3">#</a>Check if there is a direct line of sight between <code>pos1</code> and <code>pos2</code></li>
<li><a class="anchor" href="#false" name="false">#</a>Returns the position of the blocking node when <code>false</code></li>
<li><a class="anchor" href="#pos1_4" name="pos1_4">#</a><code>pos1</code>: First position</li>
<li><a class="anchor" href="#pos2" name="pos2">#</a><code>pos2</code>: Second position</li>
<li><a class="anchor" href="#stepsize" name="stepsize">#</a><code>stepsize</code>: smaller gives more accurate results but requires more computing
2014-12-28 22:55:14 +03:00
time. Default is <code>1</code>.</li>
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestfind_pathpos1pos2searchdistancemax_jumpmax_dropalgorithm" name="minetestfind_pathpos1pos2searchdistancemax_jumpmax_dropalgorithm">#</a><code>minetest.find_path(pos1,pos2,searchdistance,max_jump,max_drop,algorithm)</code><ul>
2014-12-28 22:26:49 +03:00
<li>returns table containing path</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#pos1_5" name="pos1_5">#</a>returns a table of 3D points representing a path from <code>pos1</code> to <code>pos2</code> or <code>nil</code></li>
<li><a class="anchor" href="#pos1_6" name="pos1_6">#</a><code>pos1</code>: start position</li>
<li><a class="anchor" href="#pos2_1" name="pos2_1">#</a><code>pos2</code>: end position</li>
<li><a class="anchor" href="#searchdistance" name="searchdistance">#</a><code>searchdistance</code>: number of blocks to search in each direction using a maximum metric</li>
<li><a class="anchor" href="#max_jump" name="max_jump">#</a><code>max_jump</code>: maximum height difference to consider walkable</li>
<li><a class="anchor" href="#max_drop" name="max_drop">#</a><code>max_drop</code>: maximum height difference to consider droppable</li>
<li><a class="anchor" href="#algorithm" name="algorithm">#</a><code>algorithm</code>: One of <code>"A*_noprefetch"</code> (default), <code>"A*"</code>, <code>"Dijkstra"</code></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestspawn_treepostreedef" name="minetestspawn_treepostreedef">#</a><code>minetest.spawn_tree (pos, {treedef})</code><ul>
2016-05-26 20:47:50 +03:00
<li><a class="anchor" href="#pos_1" name="pos_1">#</a>spawns L-system tree at given <code>pos</code> with definition in <code>treedef</code> table</li>
<li>Warning: L-system generation currently creates lighting bugs in the form of mapblock-sized shadows.
Often these bugs appear as subtle shadows in water.</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetesttransforming_liquid_addpos" name="minetesttransforming_liquid_addpos">#</a><code>minetest.transforming_liquid_add(pos)</code><ul>
2014-12-28 22:26:49 +03:00
<li>add node to liquid update queue</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestget_node_max_levelpos" name="minetestget_node_max_levelpos">#</a><code>minetest.get_node_max_level(pos)</code><ul>
2014-12-28 22:26:49 +03:00
<li>get max available level for leveled node</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestget_node_levelpos" name="minetestget_node_levelpos">#</a><code>minetest.get_node_level(pos)</code><ul>
2014-12-28 22:26:49 +03:00
<li>get level of leveled node (water, snow)</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestset_node_levelposlevel" name="minetestset_node_levelposlevel">#</a><code>minetest.set_node_level(pos, level)</code><ul>
<li><a class="anchor" href="#level_3" name="level_3">#</a>set level of leveled node, default <code>level</code> equals <code>1</code></li>
<li><a class="anchor" href="#totallevelmaxlevel" name="totallevelmaxlevel">#</a>if <code>totallevel &gt; maxlevel</code>, returns rest (<code>total-max</code>).</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestadd_node_levelposlevel" name="minetestadd_node_levelposlevel">#</a><code>minetest.add_node_level(pos, level)</code><ul>
<li><a class="anchor" href="#level_4" name="level_4">#</a>increase level of leveled node by level, default <code>level</code> equals <code>1</code></li>
<li><a class="anchor" href="#totallevelmaxlevel_1" name="totallevelmaxlevel_1">#</a>if <code>totallevel &gt; maxlevel</code>, returns rest (<code>total-max</code>)</li>
2014-12-28 22:26:49 +03:00
<li>can be negative for decreasing</li>
</ul>
2014-12-28 22:55:14 +03:00
</li>
2016-12-29 00:57:48 +03:00
<li><a class="anchor" href="#corecheck_single_for_fallingpos" name="corecheck_single_for_fallingpos">#</a><code>core.check_single_for_falling(pos)</code><ul>
<li><a class="anchor" href="#groupfalling_node" name="groupfalling_node">#</a>causes an unsupported <code>group:falling_node</code> node to fall and causes an
unattached <code>group:attached_node</code> node to fall.</li>
<li>does not spread these updates to neighbours.</li>
</ul>
</li>
<li><a class="anchor" href="#corecheck_for_fallingpos" name="corecheck_for_fallingpos">#</a><code>core.check_for_falling(pos)</code><ul>
<li><a class="anchor" href="#groupfalling_node_1" name="groupfalling_node_1">#</a>causes an unsupported <code>group:falling_node</code> node to fall and causes an
unattached <code>group:attached_node</code> node to fall.</li>
<li>spread these updates to neighbours and can cause a cascade
of nodes to fall.</li>
</ul>
</li>
2014-12-28 22:55:14 +03:00
</ul>
<h3 id="inventory_1">Inventory</h3>
2014-12-28 22:26:49 +03:00
<p><code>minetest.get_inventory(location)</code>: returns an <code>InvRef</code></p>
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#location" name="location">#</a><code>location</code> = e.g.<ul>
<li><a class="anchor" href="#typeplayernameceleron55" name="typeplayernameceleron55">#</a><code>{type="player", name="celeron55"}</code></li>
<li><a class="anchor" href="#typenodeposxyz" name="typenodeposxyz">#</a><code>{type="node", pos={x=, y=, z=}}</code></li>
<li><a class="anchor" href="#typedetachednamecreative" name="typedetachednamecreative">#</a><code>{type="detached", name="creative"}</code></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2016-12-29 00:57:48 +03:00
<li><a class="anchor" href="#minetestcreate_detached_inventorynamecallbacksplayer_name" name="minetestcreate_detached_inventorynamecallbacksplayer_name">#</a><code>minetest.create_detached_inventory(name, callbacks, [player_name])</code>: returns an <code>InvRef</code><ul>
2014-12-28 22:26:49 +03:00
<li>callbacks: See "Detached inventory callbacks"</li>
2016-12-29 00:57:48 +03:00
<li>player_name: Make detached inventory available to one player exclusively,
by default they will be sent to every player (even if not used).
Note that this parameter is mostly just a workaround and will be removed in future releases.</li>
2014-12-28 22:26:49 +03:00
<li>Creates a detached inventory. If it already exists, it is cleared.</li>
</ul>
2014-12-28 22:55:14 +03:00
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestdo_item_eathp_changereplace_with_itemitemstackuserpointed_thing" name="minetestdo_item_eathp_changereplace_with_itemitemstackuserpointed_thing">#</a><code>minetest.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed_thing)</code>:
2015-03-17 21:18:48 +03:00
returns left over ItemStack<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestitem_eat_1" name="minetestitem_eat_1">#</a>See <code>minetest.item_eat</code> and <code>minetest.register_on_item_eat</code></li>
2015-02-16 20:35:00 +03:00
</ul>
</li>
2014-12-28 22:55:14 +03:00
</ul>
<h3 id="formspec_1">Formspec</h3>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestshow_formspecplayernameformnameformspec" name="minetestshow_formspecplayernameformnameformspec">#</a><code>minetest.show_formspec(playername, formname, formspec)</code><ul>
<li><a class="anchor" href="#playername_1" name="playername_1">#</a><code>playername</code>: name of player to show formspec</li>
<li><a class="anchor" href="#formname" name="formname">#</a><code>formname</code>: name passed to <code>on_player_receive_fields</code> callbacks.
2014-12-28 22:55:14 +03:00
It should follow the <code>"modname:&lt;whatever&gt;"</code> naming convention</li>
2015-12-07 21:04:11 +03:00
<li><a class="anchor" href="#formspec_3" name="formspec_3">#</a><code>formspec</code>: formspec to display</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2016-12-29 00:57:48 +03:00
<li><a class="anchor" href="#minetestclose_formspecplayernameformname" name="minetestclose_formspecplayernameformname">#</a><code>minetest.close_formspec(playername, formname)</code><ul>
<li><a class="anchor" href="#playername_2" name="playername_2">#</a><code>playername</code>: name of player to close formspec</li>
<li><a class="anchor" href="#formname_1" name="formname_1">#</a><code>formname</code>: has to exactly match the one given in show_formspec, or the formspec will
not close.</li>
<li>calling show_formspec(playername, formname, "") is equal to this expression</li>
<li>to close a formspec regardless of the formname, call
minetest.close_formspec(playername, ""). USE THIS ONLY WHEN ABSOLUTELY NECESSARY!</li>
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestformspec_escapestring_1" name="minetestformspec_escapestring_1">#</a><code>minetest.formspec_escape(string)</code>: returns a string<ul>
2014-12-28 22:26:49 +03:00
<li>escapes the characters "[", "]", "\", "," and ";", which can not be used in formspecs</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestexplode_table_eventstring" name="minetestexplode_table_eventstring">#</a><code>minetest.explode_table_event(string)</code>: returns a table<ul>
<li><a class="anchor" href="#typeCHGrow1column2" name="typeCHGrow1column2">#</a>returns e.g. <code>{type="CHG", row=1, column=2}</code></li>
<li><a class="anchor" href="#type" name="type">#</a><code>type</code> is one of:<ul>
<li><a class="anchor" href="#INV" name="INV">#</a><code>"INV"</code>: no row selected)</li>
<li><a class="anchor" href="#CHG" name="CHG">#</a><code>"CHG"</code>: selected)</li>
<li><a class="anchor" href="#DCL" name="DCL">#</a><code>"DCL"</code>: double-click</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestexplode_textlist_eventstring" name="minetestexplode_textlist_eventstring">#</a><code>minetest.explode_textlist_event(string)</code>: returns a table<ul>
<li><a class="anchor" href="#typeCHGindex1" name="typeCHGindex1">#</a>returns e.g. <code>{type="CHG", index=1}</code></li>
<li><a class="anchor" href="#type_1" name="type_1">#</a><code>type</code> is one of:<ul>
<li><a class="anchor" href="#INV_1" name="INV_1">#</a><code>"INV"</code>: no row selected)</li>
<li><a class="anchor" href="#CHG_1" name="CHG_1">#</a><code>"CHG"</code>: selected)</li>
<li><a class="anchor" href="#DCL_1" name="DCL_1">#</a><code>"DCL"</code>: double-click</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestexplode_scrollbar_eventstring" name="minetestexplode_scrollbar_eventstring">#</a><code>minetest.explode_scrollbar_event(string)</code>: returns a table<ul>
<li><a class="anchor" href="#typeCHGvalue500" name="typeCHGvalue500">#</a>returns e.g. <code>{type="CHG", value=500}</code></li>
<li><a class="anchor" href="#type_2" name="type_2">#</a><code>type</code> is one of:<ul>
<li><a class="anchor" href="#INV_2" name="INV_2">#</a><code>"INV"</code>: something failed</li>
<li><a class="anchor" href="#CHG_2" name="CHG_2">#</a><code>"CHG"</code>: has been changed</li>
<li><a class="anchor" href="#VAL" name="VAL">#</a><code>"VAL"</code>: not changed</li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
</li>
</ul>
</li>
</ul>
<h3 id="item-handling">Item handling</h3>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestinventorycubeimg1img2img3" name="minetestinventorycubeimg1img2img3">#</a><code>minetest.inventorycube(img1, img2, img3)</code><ul>
2014-12-28 22:26:49 +03:00
<li>Returns a string for making an image of a cube (useful as an item image)</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestget_pointed_thing_positionpointed_thingabove" name="minetestget_pointed_thing_positionpointed_thingabove">#</a><code>minetest.get_pointed_thing_position(pointed_thing, above)</code><ul>
<li><a class="anchor" href="#pointed_thing_1" name="pointed_thing_1">#</a>Get position of a <code>pointed_thing</code> (that you can get from somewhere)</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestdir_to_facedirdiris6d" name="minetestdir_to_facedirdiris6d">#</a><code>minetest.dir_to_facedir(dir, is6d)</code><ul>
<li><a class="anchor" href="#param2_1" name="param2_1">#</a>Convert a vector to a facedir value, used in <code>param2</code> for <code>paramtype2="facedir"</code>;</li>
2016-03-19 17:25:33 +03:00
<li><a class="anchor" href="#nil_1" name="nil_1">#</a>passing something non-<code>nil</code>/<code>false</code> for the optional second parameter causes it to
2015-01-24 22:07:00 +03:00
take the y component into account</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestfacedir_to_dirfacedir" name="minetestfacedir_to_dirfacedir">#</a><code>minetest.facedir_to_dir(facedir)</code><ul>
2014-12-28 22:26:49 +03:00
<li>Convert a facedir back into a vector aimed directly out the "back" of a node</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestdir_to_wallmounteddir" name="minetestdir_to_wallmounteddir">#</a><code>minetest.dir_to_wallmounted(dir)</code><ul>
<li><a class="anchor" href="#paramtype2wallmounted" name="paramtype2wallmounted">#</a>Convert a vector to a wallmounted value, used for <code>paramtype2="wallmounted"</code></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2016-03-19 17:25:33 +03:00
<li><a class="anchor" href="#minetestwallmounted_to_dirwallmounted" name="minetestwallmounted_to_dirwallmounted">#</a><code>minetest.wallmounted_to_dir(wallmounted)</code><ul>
<li>Convert a wallmounted value back into a vector aimed directly out the "back" of a node</li>
</ul>
</li>
2017-01-31 17:21:12 +03:00
<li><a class="anchor" href="#minetestdir_to_yawdir" name="minetestdir_to_yawdir">#</a><code>minetest.dir_to_yaw(dir)</code><ul>
<li>Convert a vector into a yaw (angle)</li>
</ul>
</li>
<li><a class="anchor" href="#minetestyaw_to_diryaw" name="minetestyaw_to_diryaw">#</a><code>minetest.yaw_to_dir(yaw)</code><ul>
<li>Convert yaw (angle) to a vector</li>
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestget_node_dropsnodenametoolname" name="minetestget_node_dropsnodenametoolname">#</a><code>minetest.get_node_drops(nodename, toolname)</code><ul>
2014-12-28 22:26:49 +03:00
<li>Returns list of item names.</li>
<li><strong>Note</strong>: This will be removed or modified in a future version.</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestget_craft_resultinput" name="minetestget_craft_resultinput">#</a><code>minetest.get_craft_result(input)</code>: returns <code>output, decremented_input</code><ul>
<li><a class="anchor" href="#inputmethod" name="inputmethod">#</a><code>input.method</code> = <code>"normal"</code> or <code>"cooking"</code> or <code>"fuel"</code></li>
<li><a class="anchor" href="#inputwidth" name="inputwidth">#</a><code>input.width</code> = for example <code>3</code></li>
<li><a class="anchor" href="#inputitems" name="inputitems">#</a><code>input.items</code> = for example
2014-12-28 22:55:14 +03:00
<code>{ stack1, stack2, stack3, stack4, stack 5, stack 6, stack 7, stack 8, stack 9 }</code></li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#outputitem" name="outputitem">#</a><code>output.item</code> = <code>ItemStack</code>, if unsuccessful: empty <code>ItemStack</code></li>
<li><a class="anchor" href="#outputtime" name="outputtime">#</a><code>output.time</code> = a number, if unsuccessful: <code>0</code></li>
<li><a class="anchor" href="#outputreplacements" name="outputreplacements">#</a><code>output.replacements</code> = list of <code>ItemStack</code>s that couldn't be placed in
2015-07-08 11:43:59 +03:00
<code>decremented_input.items</code></li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#decremented_input" name="decremented_input">#</a><code>decremented_input</code> = like <code>input</code></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestget_craft_recipeoutput" name="minetestget_craft_recipeoutput">#</a><code>minetest.get_craft_recipe(output)</code>: returns input<ul>
2014-12-28 22:26:49 +03:00
<li>returns last registered recipe for output item (node)</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#output" name="output">#</a><code>output</code> is a node or item type such as <code>"default:torch"</code></li>
<li><a class="anchor" href="#inputmethod_1" name="inputmethod_1">#</a><code>input.method</code> = <code>"normal"</code> or <code>"cooking"</code> or <code>"fuel"</code></li>
<li><a class="anchor" href="#inputwidth_1" name="inputwidth_1">#</a><code>input.width</code> = for example <code>3</code></li>
<li><a class="anchor" href="#inputitems_1" name="inputitems_1">#</a><code>input.items</code> = for example
2014-12-28 22:55:14 +03:00
<code>{ stack1, stack2, stack3, stack4, stack 5, stack 6, stack 7, stack 8, stack 9 }</code></li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#inputitems_2" name="inputitems_2">#</a><code>input.items</code> = <code>nil</code> if no recipe found</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestget_all_craft_recipesqueryitem" name="minetestget_all_craft_recipesqueryitem">#</a><code>minetest.get_all_craft_recipes(query item)</code>: returns a table or <code>nil</code><ul>
2016-03-19 17:25:33 +03:00
<li><a class="anchor" href="#nil_2" name="nil_2">#</a>returns indexed table with all registered recipes for query item (node)
2014-12-28 22:55:14 +03:00
or <code>nil</code> if no recipe was found</li>
2014-12-28 22:26:49 +03:00
<li>recipe entry table:
2014-12-28 22:55:14 +03:00
{
method = 'normal' or 'cooking' or 'fuel'
width = 0-3, 0 means shapeless recipe
items = indexed [1-9] table with recipe items
output = string with item name and quantity
}</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#defaultgold_ingot" name="defaultgold_ingot">#</a>Example query for <code>"default:gold_ingot"</code> will return table:
2014-12-28 22:55:14 +03:00
{
[1]={type = "cooking", width = 3, output = "default:gold_ingot",
items = {1 = "default:gold_lump"}},
[2]={type = "normal", width = 1, output = "default:gold_ingot 9",
items = {1 = "default:goldblock"}}
}</li>
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetesthandle_node_dropsposdropsdigger" name="minetesthandle_node_dropsposdropsdigger">#</a><code>minetest.handle_node_drops(pos, drops, digger)</code><ul>
<li><a class="anchor" href="#drops" name="drops">#</a><code>drops</code>: list of itemstrings</li>
2014-12-28 22:26:49 +03:00
<li>Handles drops from nodes after digging: Default action is to put them into
2014-12-28 22:55:14 +03:00
digger's inventory</li>
2014-12-28 22:26:49 +03:00
<li>Can be overridden to get different functionality (e.g. dropping items on
2014-12-28 22:55:14 +03:00
ground)</li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
</li>
</ul>
<h3 id="rollback">Rollback</h3>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestrollback_get_node_actionsposrangesecondslimit" name="minetestrollback_get_node_actionsposrangesecondslimit">#</a><code>minetest.rollback_get_node_actions(pos, range, seconds, limit)</code>:
2015-01-24 22:07:00 +03:00
returns <code>{ {actor, pos, time, oldnode, newnode}, ...}</code><ul>
2014-12-28 22:26:49 +03:00
<li>Find who has done something to a node, or near a node</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#actor" name="actor">#</a><code>actor</code>: <code>"player:&lt;name&gt;"</code>, also <code>"liquid"</code>.</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestrollback_revert_actions_byactorseconds" name="minetestrollback_revert_actions_byactorseconds">#</a><code>minetest.rollback_revert_actions_by(actor, seconds)</code>: returns <code>boolean, log_messages</code><ul>
2014-12-28 22:26:49 +03:00
<li>Revert latest actions of someone</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#actor_1" name="actor_1">#</a><code>actor</code>: <code>"player:&lt;name&gt;"</code>, also <code>"liquid"</code>.</li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
</li>
</ul>
<h3 id="defaults-for-the-on_-item-definition-functions">Defaults for the <code>on_*</code> item definition functions</h3>
2014-12-28 22:26:49 +03:00
<p>These functions return the leftover itemstack.</p>
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestitem_place_nodeitemstackplacerpointed_thingparam2" name="minetestitem_place_nodeitemstackplacerpointed_thingparam2">#</a><code>minetest.item_place_node(itemstack, placer, pointed_thing, param2)</code><ul>
2014-12-28 22:26:49 +03:00
<li>Place item as a node</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#param2_2" name="param2_2">#</a><code>param2</code> overrides <code>facedir</code> and wallmounted <code>param2</code></li>
<li><a class="anchor" href="#itemstacksuccess" name="itemstacksuccess">#</a>returns <code>itemstack, success</code></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestitem_place_objectitemstackplacerpointed_thing" name="minetestitem_place_objectitemstackplacerpointed_thing">#</a><code>minetest.item_place_object(itemstack, placer, pointed_thing)</code><ul>
2014-12-28 22:26:49 +03:00
<li>Place item as-is</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestitem_placeitemstackplacerpointed_thingparam2" name="minetestitem_placeitemstackplacerpointed_thingparam2">#</a><code>minetest.item_place(itemstack, placer, pointed_thing, param2)</code><ul>
2014-12-28 22:26:49 +03:00
<li>Use one of the above based on what the item is.</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#on_rightclick" name="on_rightclick">#</a>Calls <code>on_rightclick</code> of <code>pointed_thing.under</code> if defined instead</li>
<li><a class="anchor" href="#on_place" name="on_place">#</a><strong>Note</strong>: is not called when wielded item overrides <code>on_place</code></li>
<li><a class="anchor" href="#param2_3" name="param2_3">#</a><code>param2</code> overrides <code>facedir</code> and wallmounted <code>param2</code></li>
<li><a class="anchor" href="#itemstacksuccess_1" name="itemstacksuccess_1">#</a>returns <code>itemstack, success</code></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestitem_dropitemstackdropperpos" name="minetestitem_dropitemstackdropperpos">#</a><code>minetest.item_drop(itemstack, dropper, pos)</code><ul>
2014-12-28 22:26:49 +03:00
<li>Drop the item</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestitem_eathp_changereplace_with_item" name="minetestitem_eathp_changereplace_with_item">#</a><code>minetest.item_eat(hp_change, replace_with_item)</code><ul>
2015-02-16 20:35:00 +03:00
<li>Eat the item.</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#replace_with_item" name="replace_with_item">#</a><code>replace_with_item</code> is the itemstring which is added to the inventory.
2015-02-16 20:35:00 +03:00
If the player is eating a stack, then replace_with_item goes to a
different spot. Can be <code>nil</code></li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestdo_item_eat" name="minetestdo_item_eat">#</a>See <code>minetest.do_item_eat</code></li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
</li>
</ul>
<h3 id="defaults-for-the-on_punch-and-on_dig-node-definition-callbacks">Defaults for the <code>on_punch</code> and <code>on_dig</code> node definition callbacks</h3>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestnode_punchposnodepuncherpointed_thing" name="minetestnode_punchposnodepuncherpointed_thing">#</a><code>minetest.node_punch(pos, node, puncher, pointed_thing)</code><ul>
<li><a class="anchor" href="#minetestregister_on_punchnode" name="minetestregister_on_punchnode">#</a>Calls functions registered by <code>minetest.register_on_punchnode()</code></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestnode_digposnodedigger" name="minetestnode_digposnodedigger">#</a><code>minetest.node_dig(pos, node, digger)</code><ul>
2014-12-28 22:26:49 +03:00
<li>Checks if node can be dug, puts item into inventory, removes node</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestregistered_on_dignodes" name="minetestregistered_on_dignodes">#</a>Calls functions registered by <code>minetest.registered_on_dignodes()</code></li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
</li>
</ul>
<h3 id="sounds_1">Sounds</h3>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestsound_playspecparameters" name="minetestsound_playspecparameters">#</a><code>minetest.sound_play(spec, parameters)</code>: returns a handle<ul>
<li><a class="anchor" href="#spec" name="spec">#</a><code>spec</code> is a <code>SimpleSoundSpec</code></li>
<li><a class="anchor" href="#parameters" name="parameters">#</a><code>parameters</code> is a sound parameter table</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestsound_stophandle" name="minetestsound_stophandle">#</a><code>minetest.sound_stop(handle)</code></li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
<h3 id="timing">Timing</h3>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestaftertimefunc" name="minetestaftertimefunc">#</a><code>minetest.after(time, func, ...)</code><ul>
2016-03-19 17:25:33 +03:00
<li><a class="anchor" href="#func" name="func">#</a>Call the function <code>func</code> after <code>time</code> seconds, may be fractional</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#func_1" name="func_1">#</a>Optional: Variable number of arguments that are passed to <code>func</code></li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
</li>
</ul>
<h3 id="server">Server</h3>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestrequest_shutdownmessagereconnect" name="minetestrequest_shutdownmessagereconnect">#</a><code>minetest.request_shutdown([message],[reconnect])</code>: request for server shutdown. Will display <code>message</code> to clients,
2015-08-12 16:54:11 +03:00
and <code>reconnect</code> == true displays a reconnect button.</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestget_server_status" name="minetestget_server_status">#</a><code>minetest.get_server_status()</code>: returns server status string</li>
2016-11-12 19:27:07 +03:00
<li><a class="anchor" href="#minetestget_server_uptime" name="minetestget_server_uptime">#</a><code>minetest.get_server_uptime()</code>: returns the server uptime in seconds</li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
<h3 id="bans">Bans</h3>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestget_ban_list" name="minetestget_ban_list">#</a><code>minetest.get_ban_list()</code>: returns the ban list (same as <code>minetest.get_ban_description("")</code>)</li>
<li><a class="anchor" href="#minetestget_ban_descriptionip_or_name" name="minetestget_ban_descriptionip_or_name">#</a><code>minetest.get_ban_description(ip_or_name)</code>: returns ban description (string)</li>
<li><a class="anchor" href="#minetestban_playername" name="minetestban_playername">#</a><code>minetest.ban_player(name)</code>: ban a player</li>
<li><a class="anchor" href="#minetestunban_player_or_ipname" name="minetestunban_player_or_ipname">#</a><code>minetest.unban_player_or_ip(name)</code>: unban player or IP address</li>
<li><a class="anchor" href="#minetestkick_playernamereason" name="minetestkick_playernamereason">#</a><code>minetest.kick_player(name, [reason])</code>: disconnect a player with a optional reason</li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
<h3 id="particles">Particles</h3>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestadd_particleparticledefinition" name="minetestadd_particleparticledefinition">#</a>
2014-12-28 22:55:14 +03:00
<p><code>minetest.add_particle(particle definition)</code></p>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestadd_particleposvelocityaccelerationexpirationtimesizecollisiondetectiontextureplayername" name="minetestadd_particleposvelocityaccelerationexpirationtimesizecollisiondetectiontextureplayername">#</a>Deprecated: <code>minetest.add_particle(pos, velocity, acceleration, expirationtime,
2014-12-28 22:55:14 +03:00
size, collisiondetection, texture, playername)</code></li>
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestadd_particlespawnerparticlespawnerdefinition" name="minetestadd_particlespawnerparticlespawnerdefinition">#</a>
2014-12-28 22:55:14 +03:00
<p><code>minetest.add_particlespawner(particlespawner definition)</code></p>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#ParticleSpawner" name="ParticleSpawner">#</a>Add a <code>ParticleSpawner</code>, an object that spawns an amount of particles over <code>time</code> seconds</li>
<li><a class="anchor" href="#id" name="id">#</a>Returns an <code>id</code>, and -1 if adding didn't succeed</li>
<li><a class="anchor" href="#Deprecatedminetestadd_particlespawneramounttimeminposmaxposminvelmaxvelminaccmaxaccminexptimemaxexptimeminsizemaxsizecollisiondetectiontextureplayername" name="Deprecatedminetestadd_particlespawneramounttimeminposmaxposminvelmaxvelminaccmaxaccminexptimemaxexptimeminsizemaxsizecollisiondetectiontextureplayername">#</a><code>Deprecated: minetest.add_particlespawner(amount, time,
2014-12-28 22:55:14 +03:00
minpos, maxpos,
minvel, maxvel,
minacc, maxacc,
minexptime, maxexptime,
minsize, maxsize,
collisiondetection, texture, playername)</code></li>
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#ParticleSpawner_1" name="ParticleSpawner_1">#</a>
2014-12-28 22:55:14 +03:00
<p>`minetest.delete_particlespawner(id, player)``</p>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#ParticleSpawner_2" name="ParticleSpawner_2">#</a>Delete <code>ParticleSpawner</code> with <code>id</code> (return value from <code>minetest.add_particlespawner</code>)</li>
2014-12-28 22:26:49 +03:00
<li>If playername is specified, only deletes on the player's client,</li>
<li>otherwise on all clients</li>
</ul>
2014-12-28 22:55:14 +03:00
</li>
</ul>
<h3 id="schematics">Schematics</h3>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestcreate_schematicp1p2probability_listfilenameslice_prob_list" name="minetestcreate_schematicp1p2probability_listfilenameslice_prob_list">#</a>
2014-12-28 22:55:14 +03:00
<p><code>minetest.create_schematic(p1, p2, probability_list, filename, slice_prob_list)</code></p>
2014-12-28 22:26:49 +03:00
<ul>
<li>Create a schematic from the volume of map specified by the box formed by p1 and p2.</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#probability_list" name="probability_list">#</a>Apply the specified probability values to the specified nodes in <code>probability_list</code>.<ul>
<li><a class="anchor" href="#probability_list_1" name="probability_list_1">#</a><code>probability_list</code> is an array of tables containing two fields, <code>pos</code> and <code>prob</code>.<ul>
<li><a class="anchor" href="#pos_2" name="pos_2">#</a><code>pos</code> is the 3D vector specifying the absolute coordinates of the
2015-03-17 21:18:48 +03:00
node being modified,</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#prob_1" name="prob_1">#</a><code>prob</code> is the integer value from <code>0</code> to <code>255</code> of the probability (see: Schematic specifier).</li>
2015-03-17 21:18:48 +03:00
<li>If there are two or more entries with the same pos value, the
last entry is used.</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#pos_3" name="pos_3">#</a>If <code>pos</code> is not inside the box formed by <code>p1</code> and <code>p2</code>, it is ignored.</li>
<li><a class="anchor" href="#probability_list_2" name="probability_list_2">#</a>If <code>probability_list</code> equals <code>nil</code>, no probabilities are applied.</li>
<li><a class="anchor" href="#ypos" name="ypos">#</a>Slice probability works in the same manner, except takes a field
2015-03-17 21:18:48 +03:00
called <code>ypos</code> instead which
2015-01-24 22:07:00 +03:00
indicates the y position of the slice with a probability applied.</li>
2016-03-19 17:25:33 +03:00
<li><a class="anchor" href="#nil_3" name="nil_3">#</a>If slice probability list equals <code>nil</code>, no slice probabilities are applied.</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
</ul>
</li>
2014-12-28 22:26:49 +03:00
<li>Saves schematic in the Minetest Schematic format to filename.</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestplace_schematicposschematicrotationreplacementsforce_placement" name="minetestplace_schematicposschematicrotationreplacementsforce_placement">#</a>
2014-12-28 22:55:14 +03:00
<p><code>minetest.place_schematic(pos, schematic, rotation, replacements, force_placement)</code></p>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#pos_4" name="pos_4">#</a>Place the schematic specified by schematic (see: Schematic specifier) at <code>pos</code>.</li>
<li><a class="anchor" href="#rotation" name="rotation">#</a><code>rotation</code> can equal <code>"0"</code>, <code>"90"</code>, <code>"180"</code>, <code>"270"</code>, or <code>"random"</code>.</li>
<li><a class="anchor" href="#rotation_1" name="rotation_1">#</a>If the <code>rotation</code> parameter is omitted, the schematic is not rotated.</li>
<li><a class="anchor" href="#replacements" name="replacements">#</a><code>replacements</code> = <code>{["old_name"] = "convert_to", ...}</code></li>
<li><a class="anchor" href="#force_placement_1" name="force_placement_1">#</a><code>force_placement</code> is a boolean indicating whether nodes other than <code>air</code> and
2014-12-28 22:55:14 +03:00
<code>ignore</code> are replaced by the schematic</li>
2015-11-21 18:26:52 +03:00
<li>Returns nil if the schematic could not be loaded.</li>
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestplace_schematic_on_vmanipvmanipposschematicrotationreplacementforce_placement" name="minetestplace_schematic_on_vmanipvmanipposschematicrotationreplacementforce_placement">#</a>
2015-11-21 18:26:52 +03:00
<p><code>minetest.place_schematic_on_vmanip(vmanip, pos, schematic, rotation, replacement, force_placement)</code>:</p>
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#vmanip" name="vmanip">#</a>This function is analagous to minetest.place_schematic, but places a schematic onto the
2015-11-21 18:26:52 +03:00
specified VoxelManip object <code>vmanip</code> instead of the whole map.</li>
<li>Returns false if any part of the schematic was cut-off due to the VoxelManip not
containing the full area required, and true if the whole schematic was able to fit.</li>
<li>Returns nil if the schematic could not be loaded.</li>
<li>After execution, any external copies of the VoxelManip contents are invalidated.</li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestserialize_schematicschematicformatoptions" name="minetestserialize_schematicschematicformatoptions">#</a>
2015-04-29 20:17:32 +03:00
<p><code>minetest.serialize_schematic(schematic, format, options)</code></p>
<ul>
<li>Return the serialized schematic specified by schematic (see: Schematic specifier)</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#format" name="format">#</a>in the <code>format</code> of either "mts" or "lua".</li>
2015-04-29 20:17:32 +03:00
<li>"mts" - a string containing the binary MTS data used in the MTS file format</li>
<li>"lua" - a string containing Lua code representing the schematic in table format</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#options" name="options">#</a><code>options</code> is a table containing the following optional parameters:</li>
<li><a class="anchor" href="#lua_use_comments" name="lua_use_comments">#</a>If <code>lua_use_comments</code> is true and <code>format</code> is "lua", the Lua code generated will have (X, Z)</li>
2015-04-29 20:17:32 +03:00
<li>position comments for every X row generated in the schematic data for easier reading.</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#lua_num_indent_spaces" name="lua_num_indent_spaces">#</a>If <code>lua_num_indent_spaces</code> is a nonzero number and <code>format</code> is "lua", the Lua code generated</li>
2015-05-08 20:55:17 +03:00
<li>will use that number of spaces as indentation instead of a tab character.</li>
2015-04-29 20:17:32 +03:00
</ul>
</li>
2014-12-28 22:55:14 +03:00
</ul>
2016-03-19 17:25:33 +03:00
<h3 id="http-requests">HTTP Requests:</h3>
<ul>
<li><a class="anchor" href="#minetestrequest_http_api" name="minetestrequest_http_api">#</a><code>minetest.request_http_api()</code>:<ul>
<li><a class="anchor" href="#HTTPApiTable" name="HTTPApiTable">#</a>returns <code>HTTPApiTable</code> containing http functions if the calling mod has been granted
access by being listed in the <code>secure.http_mods</code> or <code>secure.trusted_mods</code> setting,
otherwise returns <code>nil</code>.</li>
<li><a class="anchor" href="#fetch" name="fetch">#</a>The returned table contains the functions <code>fetch</code>, <code>fetch_async</code> and <code>fetch_async_get</code>
described below.</li>
<li>Only works at init time and must be called from the mod's main scope (not from a function).</li>
<li>Function only exists if minetest server was built with cURL support.</li>
<li><strong>DO NOT ALLOW ANY OTHER MODS TO ACCESS THE RETURNED TABLE, STORE IT IN
A LOCAL VARIABLE!</strong></li>
</ul>
</li>
<li><a class="anchor" href="#HTTPApiTablefetchHTTPRequestreqcallback" name="HTTPApiTablefetchHTTPRequestreqcallback">#</a><code>HTTPApiTable.fetch(HTTPRequest req, callback)</code><ul>
<li>Performs given request asynchronously and calls callback upon completion</li>
<li><a class="anchor" href="#functionHTTPRequestResultres" name="functionHTTPRequestResultres">#</a>callback: <code>function(HTTPRequestResult res)</code></li>
<li>Use this HTTP function if you are unsure, the others are for advanced use.</li>
</ul>
</li>
<li><a class="anchor" href="#HTTPApiTablefetch_asyncHTTPRequestreq" name="HTTPApiTablefetch_asyncHTTPRequestreq">#</a><code>HTTPApiTable.fetch_async(HTTPRequest req)</code>: returns handle<ul>
2016-07-22 21:37:58 +03:00
<li><a class="anchor" href="#HTTPApiTablefetch_async_get" name="HTTPApiTablefetch_async_get">#</a>Performs given request asynchronously and returns handle for <code>HTTPApiTable.fetch_async_get</code></li>
2016-03-19 17:25:33 +03:00
</ul>
</li>
<li><a class="anchor" href="#HTTPApiTablefetch_async_gethandle" name="HTTPApiTablefetch_async_gethandle">#</a><code>HTTPApiTable.fetch_async_get(handle)</code>: returns HTTPRequestResult<ul>
<li>Return response data for given asynchronous HTTP request</li>
</ul>
</li>
</ul>
2017-02-19 16:15:50 +03:00
<h3 id="storage-api">Storage API:</h3>
<ul>
<li><a class="anchor" href="#minetestget_mod_storage" name="minetestget_mod_storage">#</a><code>minetest.get_mod_storage()</code>:<ul>
<li><a class="anchor" href="#StorageRef" name="StorageRef">#</a>returns reference to mod private <code>StorageRef</code></li>
<li>must be called during mod load time</li>
</ul>
</li>
</ul>
2014-12-28 22:55:14 +03:00
<h3 id="misc">Misc.</h3>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestget_connected_players" name="minetestget_connected_players">#</a><code>minetest.get_connected_players()</code>: returns list of <code>ObjectRefs</code></li>
2017-01-31 17:21:12 +03:00
<li><a class="anchor" href="#minetestplayer_existsname" name="minetestplayer_existsname">#</a><code>minetest.player_exists(name)</code>: boolean, whether player exists (regardless of online status)</li>
2016-12-29 00:57:48 +03:00
<li><a class="anchor" href="#minetesthud_replace_builtinnamehud_definition" name="minetesthud_replace_builtinnamehud_definition">#</a><code>minetest.hud_replace_builtin(name, hud_definition)</code><ul>
<li>Replaces definition of a builtin hud element</li>
<li><a class="anchor" href="#name_12" name="name_12">#</a><code>name</code>: <code>"breath"</code> or <code>"health"</code></li>
<li><a class="anchor" href="#hud_definition" name="hud_definition">#</a><code>hud_definition</code>: definition to replace builtin definition</li>
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetesthash_node_positionxyz" name="minetesthash_node_positionxyz">#</a><code>minetest.hash_node_position({x=,y=,z=})</code>: returns an 48-bit integer<ul>
2014-12-28 22:26:49 +03:00
<li>Gives a unique hash number for a node position (16+16+16=48bit)</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestget_position_from_hashhash" name="minetestget_position_from_hashhash">#</a><code>minetest.get_position_from_hash(hash)</code>: returns a position<ul>
<li><a class="anchor" href="#minetesthash_node_position" name="minetesthash_node_position">#</a>Inverse transform of <code>minetest.hash_node_position</code></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestget_item_groupnamegroup" name="minetestget_item_groupnamegroup">#</a><code>minetest.get_item_group(name, group)</code>: returns a rating<ul>
<li><a class="anchor" href="#0_8" name="0_8">#</a>Get rating of a group of an item. (<code>0</code> means: not in group)</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestget_node_groupnamegroup" name="minetestget_node_groupnamegroup">#</a><code>minetest.get_node_group(name, group)</code>: returns a rating<ul>
2014-12-28 22:26:49 +03:00
<li>Deprecated: An alias for the former.</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestraillike_groupname" name="minetestraillike_groupname">#</a><code>minetest.raillike_group(name)</code>: returns a rating<ul>
2015-05-27 12:53:46 +03:00
<li>Returns rating of the connect_to_raillike group corresponding to name</li>
<li>If name is not yet the name of a connect_to_raillike group, a new group id</li>
<li>is created, with that name</li>
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestget_content_idname" name="minetestget_content_idname">#</a><code>minetest.get_content_id(name)</code>: returns an integer<ul>
2016-12-29 00:57:48 +03:00
<li><a class="anchor" href="#name_13" name="name_13">#</a>Gets the internal content ID of <code>name</code></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestget_name_from_content_idcontent_id" name="minetestget_name_from_content_idcontent_id">#</a><code>minetest.get_name_from_content_id(content_id)</code>: returns a string<ul>
2014-12-28 22:26:49 +03:00
<li>Gets the name of the content with that content ID</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestparse_jsonstringnullvalue" name="minetestparse_jsonstringnullvalue">#</a><code>minetest.parse_json(string[, nullvalue])</code>: returns something<ul>
2014-12-28 22:26:49 +03:00
<li>Convert a string containing JSON data into the Lua equivalent</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#nullvalue" name="nullvalue">#</a><code>nullvalue</code>: returned in place of the JSON null; defaults to <code>nil</code></li>
<li><a class="anchor" href="#nullvalue_1" name="nullvalue_1">#</a>On success returns a table, a string, a number, a boolean or <code>nullvalue</code></li>
2016-03-19 17:25:33 +03:00
<li><a class="anchor" href="#nil_4" name="nil_4">#</a>On failure outputs an error message and returns <code>nil</code></li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#parse_json10afalse" name="parse_json10afalse">#</a>Example: <code>parse_json("[10, {\"a\":false}]")</code>, returns <code>{10, {a = false}}</code></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestwrite_jsondatastyled" name="minetestwrite_jsondatastyled">#</a><code>minetest.write_json(data[, styled])</code>: returns a string or <code>nil</code> and an error message<ul>
2014-12-28 22:26:49 +03:00
<li>Convert a Lua table into a JSON string</li>
<li>styled: Outputs in a human-readable format if this is set, defaults to false</li>
<li>Unserializable things like functions and userdata are saved as null.</li>
2014-12-28 22:55:14 +03:00
<li><strong>Warning</strong>: JSON is more strict than the Lua table format.<ol>
2014-12-28 22:26:49 +03:00
<li>You can only use strings and positive integers of at least one as keys.</li>
<li>You can not mix string and integer keys.
2014-12-28 22:55:14 +03:00
This is due to the fact that JSON has two distinct array and object values.</li>
</ol>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#write_json10afalse" name="write_json10afalse">#</a>Example: <code>write_json({10, {a = false}})</code>, returns <code>"[10, {\"a\": false}]"</code></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestserializetable" name="minetestserializetable">#</a><code>minetest.serialize(table)</code>: returns a string<ul>
2016-03-19 17:25:33 +03:00
<li><a class="anchor" href="#nil_5" name="nil_5">#</a>Convert a table containing tables, strings, numbers, booleans and <code>nil</code>s
2014-12-28 22:55:14 +03:00
into string form readable by <code>minetest.deserialize</code></li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#serializefoobar" name="serializefoobar">#</a>Example: <code>serialize({foo='bar'})</code>, returns <code>'return { ["foo"] = "bar" }'</code></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestdeserializestring" name="minetestdeserializestring">#</a><code>minetest.deserialize(string)</code>: returns a table<ul>
<li><a class="anchor" href="#minetestdeserialize" name="minetestdeserialize">#</a>Convert a string returned by <code>minetest.deserialize</code> into a table</li>
2016-11-12 19:27:07 +03:00
<li><a class="anchor" href="#string_1" name="string_1">#</a><code>string</code> is loaded in an empty sandbox environment.</li>
2014-12-28 22:26:49 +03:00
<li>Will load functions, but they cannot access the global environment.</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#deserializereturnfoobar" name="deserializereturnfoobar">#</a>Example: <code>deserialize('return { ["foo"] = "bar" }')</code>, returns <code>{foo='bar'}</code></li>
<li><a class="anchor" href="#deserializeprintfoo" name="deserializeprintfoo">#</a>Example: <code>deserialize('print("foo")')</code>, returns <code>nil</code> (function call fails)<ul>
<li><a class="anchor" href="#errorstringprintfoo1attempttocallglobalprintanilvalue" name="errorstringprintfoo1attempttocallglobalprintanilvalue">#</a><code>error:[string "print("foo")"]:1: attempt to call global 'print' (a nil value)</code></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestcompressdatamethod" name="minetestcompressdatamethod">#</a><code>minetest.compress(data, method, ...)</code>: returns <code>compressed_data</code><ul>
2014-12-28 22:26:49 +03:00
<li>Compress a string of data.</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#method" name="method">#</a><code>method</code> is a string identifying the compression method to be used.</li>
2014-12-28 22:26:49 +03:00
<li>Supported compression methods:</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#deflate" name="deflate">#</a>Deflate (zlib): <code>"deflate"</code></li>
2014-12-28 22:26:49 +03:00
<li><code>...</code> indicates method-specific arguments. Currently defined arguments are:</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#level_5" name="level_5">#</a>Deflate: <code>level</code> - Compression level, <code>0</code>-<code>9</code> or <code>nil</code>.</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestdecompresscompressed_datamethod" name="minetestdecompresscompressed_datamethod">#</a><code>minetest.decompress(compressed_data, method, ...)</code>: returns data<ul>
2014-12-28 22:26:49 +03:00
<li>Decompress a string of data (using ZLib).</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestcompress" name="minetestcompress">#</a>See documentation on <code>minetest.compress()</code> for supported compression methods.</li>
2014-12-28 22:26:49 +03:00
<li>currently supported.</li>
<li><code>...</code> indicates method-specific arguments. Currently, no methods use this.</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2016-07-22 21:37:58 +03:00
<li><a class="anchor" href="#minetestencode_base64string" name="minetestencode_base64string">#</a><code>minetest.encode_base64(string)</code>: returns string encoded in base64<ul>
<li>Encodes a string in base64.</li>
</ul>
</li>
<li><a class="anchor" href="#minetestdecode_base64string" name="minetestdecode_base64string">#</a><code>minetest.decode_base64(string)</code>: returns string<ul>
<li>Decodes a string encoded in base64.</li>
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestis_protectedposname" name="minetestis_protectedposname">#</a>
2014-12-28 22:55:14 +03:00
<p><code>minetest.is_protected(pos, name)</code>: returns boolean</p>
2014-12-28 22:26:49 +03:00
<ul>
2016-12-29 00:57:48 +03:00
<li><a class="anchor" href="#name_14" name="name_14">#</a>Returns true, if player <code>name</code> shouldn't be abled to dig at <code>pos</code> or do other
2015-08-12 16:54:11 +03:00
actions, defineable by mods, due to some mod-defined ownership-like concept.
Returns false or nil, if the player is allowed to do such actions.</li>
2014-12-28 22:26:49 +03:00
<li>This function should be overridden by protection mods and should be used to
2014-12-28 22:55:14 +03:00
check if a player can interact at a position.</li>
2014-12-28 22:26:49 +03:00
<li>This function should call the old version of itself if the position is not
2014-12-28 22:55:14 +03:00
protected by the mod.</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#localold_is_protectedminetestis_protectedfunctionminetestis_protectedposnameifmymodposition_protected_fromposnamethenreturntrueendreturnold_is_protectedposnameend" name="localold_is_protectedminetestis_protectedfunctionminetestis_protectedposnameifmymodposition_protected_fromposnamethenreturntrueendreturnold_is_protectedposnameend">#</a>Example:<pre><code>local old_is_protected = minetest.is_protected
2014-12-28 22:26:49 +03:00
function minetest.is_protected(pos, name)
if mymod:position_protected_from(pos, name) then
return true
end
return old_is_protected(pos, name)
end
2014-12-28 22:55:14 +03:00
</code></pre>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestrecord_protection_violationposname" name="minetestrecord_protection_violationposname">#</a><code>minetest.record_protection_violation(pos, name)</code><ul>
<li><a class="anchor" href="#minetestregister_on_protection_violation" name="minetestregister_on_protection_violation">#</a>This function calls functions registered with
2014-12-28 22:55:14 +03:00
<code>minetest.register_on_protection_violation</code>.</li>
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestrotate_and_placeitemstackplacerpointed_thinginfinitestacksorient_flags" name="minetestrotate_and_placeitemstackplacerpointed_thinginfinitestacksorient_flags">#</a><code>minetest.rotate_and_place(itemstack, placer, pointed_thing, infinitestacks, orient_flags)</code><ul>
<li><a class="anchor" href="#itemstack_3" name="itemstack_3">#</a>Attempt to predict the desired orientation of the facedir-capable node
2014-12-28 22:55:14 +03:00
defined by <code>itemstack</code>, and place it accordingly (on-wall, on the floor, or
hanging from the ceiling). Stacks are handled normally if the <code>infinitestacks</code>
field is false or omitted (else, the itemstack is not changed). <code>orient_flags</code>
is an optional table containing extra tweaks to the placement code:</li>
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#invert_wall" name="invert_wall">#</a><code>invert_wall</code>: if <code>true</code>, place wall-orientation on the ground and ground-
2014-12-28 22:55:14 +03:00
orientation on the wall.</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#force_wall" name="force_wall">#</a><code>force_wall</code> : if <code>true</code>, always place the node in wall orientation.</li>
<li><a class="anchor" href="#force_ceiling" name="force_ceiling">#</a><code>force_ceiling</code>: if <code>true</code>, always place on the ceiling.</li>
<li><a class="anchor" href="#force_floor" name="force_floor">#</a><code>force_floor</code>: if <code>true</code>, always place the node on the floor.</li>
<li><a class="anchor" href="#force_facedir" name="force_facedir">#</a><code>force_facedir</code>: if <code>true</code>, forcefully reset the facedir to north when placing on
2014-12-28 22:55:14 +03:00
the floor or ceiling</li>
2014-12-28 22:26:49 +03:00
<li>The first four options are mutually-exclusive; the last in the list takes
2014-12-28 22:55:14 +03:00
precedence over the first.</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestrotate_nodeitemstackplacerpointed_thing" name="minetestrotate_nodeitemstackplacerpointed_thing">#</a><code>minetest.rotate_node(itemstack, placer, pointed_thing)</code><ul>
<li><a class="anchor" href="#rotate_and_place" name="rotate_and_place">#</a>calls <code>rotate_and_place()</code> with infinitestacks set according to the state of
2015-05-27 12:53:46 +03:00
the creative mode setting, and checks for "sneak" to set the <code>invert_wall</code>
parameter.</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
</ul>
</li>
</ul>
</li>
2016-11-12 19:27:07 +03:00
<li><a class="anchor" href="#minetestforceload_blockpostransient" name="minetestforceload_blockpostransient">#</a>
<p><code>minetest.forceload_block(pos[, transient])</code></p>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#pos_5" name="pos_5">#</a>forceloads the position <code>pos</code>.</li>
<li><a class="anchor" href="#true_10" name="true_10">#</a>returns <code>true</code> if area could be forceloaded</li>
2016-11-12 19:27:07 +03:00
<li><a class="anchor" href="#transient" name="transient">#</a>If <code>transient</code> is <code>false</code> or absent, the forceload will be persistent
(saved between server runs). If <code>true</code>, the forceload will be transient
(not saved between server runs).</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2016-11-12 19:27:07 +03:00
<li><a class="anchor" href="#minetestforceload_free_blockpostransient" name="minetestforceload_free_blockpostransient">#</a>
<p><code>minetest.forceload_free_block(pos[, transient])</code></p>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#pos_6" name="pos_6">#</a>stops forceloading the position <code>pos</code></li>
2016-11-12 19:27:07 +03:00
<li><a class="anchor" href="#transient_1" name="transient_1">#</a>If <code>transient</code> is <code>false</code> or absent, frees a persistent forceload.
If <code>true</code>, frees a transient forceload.</li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestrequest_insecure_environment" name="minetestrequest_insecure_environment">#</a>
2015-05-27 12:53:46 +03:00
<p><code>minetest.request_insecure_environment()</code>: returns an environment containing
insecure functions if the calling mod has been listed as trusted in the
<code>secure.trusted_mods</code> setting or security is disabled, otherwise returns <code>nil</code>.</p>
<ul>
2016-03-19 17:25:33 +03:00
<li>Only works at init time and must be called from the mod's main scope (not from a function).</li>
2015-05-27 12:53:46 +03:00
<li><strong>DO NOT ALLOW ANY OTHER MODS TO ACCESS THE RETURNED ENVIRONMENT, STORE IT IN
A LOCAL VARIABLE!</strong></li>
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestglobal_existsname" name="minetestglobal_existsname">#</a>
2015-05-27 12:53:46 +03:00
<p><code>minetest.global_exists(name)</code></p>
<ul>
<li>Checks if a global variable has been set, without triggering a warning.</li>
</ul>
</li>
2014-12-28 22:55:14 +03:00
</ul>
<h3 id="global-objects">Global objects</h3>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestenv" name="minetestenv">#</a><code>minetest.env</code>: <code>EnvRef</code> of the server environment and world.<ul>
<li><a class="anchor" href="#minetestenvsomefunctionsomearguments" name="minetestenvsomefunctionsomearguments">#</a>Any function in the minetest namespace can be called using the syntax
2014-12-28 22:55:14 +03:00
<code>minetest.env:somefunction(somearguments)</code>
instead of <code>minetest.somefunction(somearguments)</code></li>
2015-05-27 12:53:46 +03:00
<li>Deprecated, but support is not to be dropped soon</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
<h3 id="global-tables">Global tables</h3>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestregistered_items" name="minetestregistered_items">#</a><code>minetest.registered_items</code><ul>
2015-01-09 21:54:25 +03:00
<li>Map of registered items, indexed by name</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestregistered_nodes" name="minetestregistered_nodes">#</a><code>minetest.registered_nodes</code><ul>
2015-01-09 21:54:25 +03:00
<li>Map of registered node definitions, indexed by name</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestregistered_craftitems" name="minetestregistered_craftitems">#</a><code>minetest.registered_craftitems</code><ul>
2015-01-09 21:54:25 +03:00
<li>Map of registered craft item definitions, indexed by name</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestregistered_tools" name="minetestregistered_tools">#</a><code>minetest.registered_tools</code><ul>
2015-01-09 21:54:25 +03:00
<li>Map of registered tool definitions, indexed by name</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestregistered_entities" name="minetestregistered_entities">#</a><code>minetest.registered_entities</code><ul>
2015-01-09 21:54:25 +03:00
<li>Map of registered entity prototypes, indexed by name</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestobject_refs" name="minetestobject_refs">#</a><code>minetest.object_refs</code><ul>
2015-01-09 21:54:25 +03:00
<li>Map of object references, indexed by active object id</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestluaentities" name="minetestluaentities">#</a><code>minetest.luaentities</code><ul>
2015-01-09 21:54:25 +03:00
<li>Map of Lua entities, indexed by active object id</li>
</ul>
</li>
2017-01-31 17:21:12 +03:00
<li><a class="anchor" href="#minetestregistered_chatcommands" name="minetestregistered_chatcommands">#</a><code>minetest.registered_chatcommands</code><ul>
<li>Map of registered chat command definitions, indexed by name</li>
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestregistered_ores_1" name="minetestregistered_ores_1">#</a><code>minetest.registered_ores</code><ul>
2015-01-09 21:54:25 +03:00
<li>List of registered ore definitions.</li>
</ul>
</li>
2016-03-19 17:25:33 +03:00
<li><a class="anchor" href="#minetestregistered_biomes" name="minetestregistered_biomes">#</a><code>minetest.registered_biomes</code><ul>
<li>List of registered biome definitions.</li>
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minetestregistered_decorations_1" name="minetestregistered_decorations_1">#</a><code>minetest.registered_decorations</code><ul>
2015-01-09 21:54:25 +03:00
<li>List of registered decoration definitions.</li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
</li>
</ul>
<h2 id="class-reference">Class reference</h2>
2017-02-19 16:15:50 +03:00
<h3 id="metadataref"><code>MetaDataRef</code></h3>
<p>See <code>StorageRef</code>, <code>NodeMetaRef</code> and <code>ItemStackMetaRef</code>.</p>
2014-12-28 22:55:14 +03:00
<h4 id="methods">Methods</h4>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#set_stringnamevalue" name="set_stringnamevalue">#</a><code>set_string(name, value)</code></li>
<li><a class="anchor" href="#get_stringname" name="get_stringname">#</a><code>get_string(name)</code></li>
<li><a class="anchor" href="#set_intnamevalue" name="set_intnamevalue">#</a><code>set_int(name, value)</code></li>
<li><a class="anchor" href="#get_intname" name="get_intname">#</a><code>get_int(name)</code></li>
<li><a class="anchor" href="#set_floatnamevalue" name="set_floatnamevalue">#</a><code>set_float(name, value)</code></li>
<li><a class="anchor" href="#get_floatname" name="get_floatname">#</a><code>get_float(name)</code></li>
2017-02-19 16:15:50 +03:00
<li><a class="anchor" href="#to_table" name="to_table">#</a><code>to_table()</code>: returns <code>nil</code> or a table with keys:<ul>
<li><a class="anchor" href="#fields" name="fields">#</a><code>fields</code>: key-value storage</li>
<li><a class="anchor" href="#inventory_2" name="inventory_2">#</a><code>inventory</code>: <code>{list1 = {}, ...}}</code> (NodeMetaRef only)</li>
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#from_tablenilor" name="from_tablenilor">#</a><code>from_table(nil or {})</code><ul>
2017-01-31 17:21:12 +03:00
<li>Any non-table value will clear the metadata</li>
2017-02-19 16:15:50 +03:00
<li>See "Node Metadata" for an example</li>
2017-01-31 17:21:12 +03:00
<li><a class="anchor" href="#true_11" name="true_11">#</a>returns <code>true</code> on success</li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
</li>
</ul>
2017-02-19 16:15:50 +03:00
<h3 id="nodemetaref"><code>NodeMetaRef</code></h3>
<p>Node metadata: reference extra data and functionality stored in a node.
Can be obtained via <code>minetest.get_meta(pos)</code>.</p>
<h4 id="methods_1">Methods</h4>
<ul>
<li>All methods in MetaDataRef</li>
<li><a class="anchor" href="#get_inventory" name="get_inventory">#</a><code>get_inventory()</code>: returns <code>InvRef</code></li>
</ul>
<h3 id="itemstackmetaref"><code>ItemStackMetaRef</code></h3>
<p>ItemStack metadata: reference extra data and functionality stored in a stack.
Can be obtained via <code>item:get_meta()</code>.</p>
<h4 id="methods_2">Methods</h4>
<ul>
<li>All methods in MetaDataRef</li>
</ul>
<h3 id="storageref"><code>StorageRef</code></h3>
<p>Mod metadata: per mod metadata, saved automatically.
Can be obtained via <code>minetest.get_mod_storage()</code> during load time.</p>
<h4 id="methods_3">Methods</h4>
<ul>
<li>All methods in MetaDataRef</li>
</ul>
2015-09-25 02:24:04 +03:00
<h3 id="nodetimerref"><code>NodeTimerRef</code></h3>
2015-02-16 20:35:00 +03:00
<p>Node Timers: a high resolution persistent per-node timer.
2014-12-28 22:26:49 +03:00
Can be gotten via <code>minetest.get_node_timer(pos)</code>.</p>
2017-02-19 16:15:50 +03:00
<h4 id="methods_4">Methods</h4>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#settimeoutelapsed" name="settimeoutelapsed">#</a><code>set(timeout,elapsed)</code><ul>
2014-12-28 22:26:49 +03:00
<li>set a timer's state</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#timeout" name="timeout">#</a><code>timeout</code> is in seconds, and supports fractional values (0.1 etc)</li>
<li><a class="anchor" href="#elapsed" name="elapsed">#</a><code>elapsed</code> is in seconds, and supports fractional values (0.1 etc)</li>
<li><a class="anchor" href="#on_timer" name="on_timer">#</a>will trigger the node's <code>on_timer</code> function after <code>timeout</code>-elapsed seconds</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#starttimeout" name="starttimeout">#</a><code>start(timeout)</code><ul>
2014-12-28 22:26:49 +03:00
<li>start a timer</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#settimeout0" name="settimeout0">#</a>equivalent to <code>set(timeout,0)</code></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#stop" name="stop">#</a><code>stop()</code><ul>
2014-12-28 22:26:49 +03:00
<li>stops the timer</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#get_timeout" name="get_timeout">#</a><code>get_timeout()</code>: returns current timeout in seconds<ul>
<li><a class="anchor" href="#timeout_1" name="timeout_1">#</a>if <code>timeout</code> equals <code>0</code>, timer is inactive</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#get_elapsed" name="get_elapsed">#</a><code>get_elapsed()</code>: returns current elapsed time in seconds<ul>
<li><a class="anchor" href="#on_timer_1" name="on_timer_1">#</a>the node's <code>on_timer</code> function will be called after <code>timeout</code>-elapsed seconds</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#is_started" name="is_started">#</a><code>is_started()</code>: returns boolean state of timer<ul>
2017-01-31 17:21:12 +03:00
<li><a class="anchor" href="#true_12" name="true_12">#</a>returns <code>true</code> if timer is started, otherwise <code>false</code></li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
</li>
</ul>
<h3 id="objectref"><code>ObjectRef</code></h3>
2014-12-28 22:26:49 +03:00
<p>Moving things in the game are generally these.</p>
<p>This is basically a reference to a C++ <code>ServerActiveObject</code></p>
2017-02-19 16:15:50 +03:00
<h4 id="methods_5">Methods</h4>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#remove" name="remove">#</a><code>remove()</code>: remove object (after returning from Lua)<ul>
2015-03-17 21:18:48 +03:00
<li>Note: Doesn't work on players, use minetest.kick_player instead</li>
</ul>
</li>
2017-01-31 17:21:12 +03:00
<li><a class="anchor" href="#get_pos" name="get_pos">#</a><code>get_pos()</code>: returns <code>{x=num, y=num, z=num}</code></li>
<li><a class="anchor" href="#set_pospos" name="set_pospos">#</a><code>set_pos(pos)</code>; <code>pos</code>=<code>{x=num, y=num, z=num}</code></li>
<li><a class="anchor" href="#move_toposcontinuousfalse" name="move_toposcontinuousfalse">#</a><code>move_to(pos, continuous=false)</code>: interpolated move</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#punchpunchertime_from_last_punchtool_capabilitiesdirection" name="punchpunchertime_from_last_punchtool_capabilitiesdirection">#</a><code>punch(puncher, time_from_last_punch, tool_capabilities, direction)</code><ul>
<li><a class="anchor" href="#puncher_1" name="puncher_1">#</a><code>puncher</code> = another <code>ObjectRef</code>,</li>
<li><a class="anchor" href="#time_from_last_punch_2" name="time_from_last_punch_2">#</a><code>time_from_last_punch</code> = time since last punch action of the puncher</li>
<li><a class="anchor" href="#direction_4" name="direction_4">#</a><code>direction</code>: can be <code>nil</code></li>
</ul>
</li>
<li><a class="anchor" href="#right_clickclicker" name="right_clickclicker">#</a><code>right_click(clicker)</code>; <code>clicker</code> is another <code>ObjectRef</code></li>
<li><a class="anchor" href="#get_hp" name="get_hp">#</a><code>get_hp()</code>: returns number of hitpoints (2 * number of hearts)</li>
<li><a class="anchor" href="#set_hphp" name="set_hphp">#</a><code>set_hp(hp)</code>: set number of hitpoints (2 * number of hearts)</li>
<li><a class="anchor" href="#get_inventory_1" name="get_inventory_1">#</a><code>get_inventory()</code>: returns an <code>InvRef</code></li>
<li><a class="anchor" href="#get_wield_list" name="get_wield_list">#</a><code>get_wield_list()</code>: returns the name of the inventory list the wielded item is in</li>
<li><a class="anchor" href="#get_wield_index" name="get_wield_index">#</a><code>get_wield_index()</code>: returns the index of the wielded item</li>
<li><a class="anchor" href="#get_wielded_item" name="get_wielded_item">#</a><code>get_wielded_item()</code>: returns an <code>ItemStack</code></li>
<li><a class="anchor" href="#set_wielded_itemitem" name="set_wielded_itemitem">#</a><code>set_wielded_item(item)</code>: replaces the wielded item, returns <code>true</code> if successful</li>
<li><a class="anchor" href="#set_armor_groupsgroup1ratinggroup2rating" name="set_armor_groupsgroup1ratinggroup2rating">#</a><code>set_armor_groups({group1=rating, group2=rating, ...})</code></li>
<li><a class="anchor" href="#get_armor_groups" name="get_armor_groups">#</a><code>get_armor_groups()</code>: returns a table with the armor group ratings</li>
<li><a class="anchor" href="#set_animationx1y1frame_speed15frame_blend0frame_looptrue" name="set_animationx1y1frame_speed15frame_blend0frame_looptrue">#</a><code>set_animation({x=1,y=1}, frame_speed=15, frame_blend=0, frame_loop=true)</code></li>
<li><a class="anchor" href="#get_animation" name="get_animation">#</a><code>get_animation()</code>: returns range, frame_speed, frame_blend and frame_loop</li>
<li><a class="anchor" href="#set_attachparentbonepositionrotation" name="set_attachparentbonepositionrotation">#</a><code>set_attach(parent, bone, position, rotation)</code><ul>
<li><a class="anchor" href="#bone" name="bone">#</a><code>bone</code>: string</li>
<li><a class="anchor" href="#position" name="position">#</a><code>position</code>: <code>{x=num, y=num, z=num}</code> (relative)</li>
<li><a class="anchor" href="#rotation_2" name="rotation_2">#</a><code>rotation</code>: <code>{x=num, y=num, z=num}</code></li>
</ul>
</li>
<li><a class="anchor" href="#get_attach" name="get_attach">#</a><code>get_attach()</code>: returns parent, bone, position, rotation or nil if it isn't attached</li>
<li><a class="anchor" href="#set_detach" name="set_detach">#</a><code>set_detach()</code></li>
<li><a class="anchor" href="#set_bone_positionbonepositionrotation" name="set_bone_positionbonepositionrotation">#</a><code>set_bone_position(bone, position, rotation)</code><ul>
<li><a class="anchor" href="#bone_1" name="bone_1">#</a><code>bone</code>: string</li>
<li><a class="anchor" href="#position_1" name="position_1">#</a><code>position</code>: <code>{x=num, y=num, z=num}</code> (relative)</li>
<li><a class="anchor" href="#rotation_3" name="rotation_3">#</a><code>rotation</code>: <code>{x=num, y=num, z=num}</code></li>
</ul>
</li>
<li><a class="anchor" href="#get_bone_positionbone" name="get_bone_positionbone">#</a><code>get_bone_position(bone)</code>: returns position and rotation of the bone</li>
<li><a class="anchor" href="#set_propertiesobjectpropertytable" name="set_propertiesobjectpropertytable">#</a><code>set_properties(object property table)</code></li>
<li><a class="anchor" href="#get_properties" name="get_properties">#</a><code>get_properties()</code>: returns object property table</li>
<li><a class="anchor" href="#is_player" name="is_player">#</a><code>is_player()</code>: returns true for players, false otherwise</li>
2016-03-19 17:25:33 +03:00
<li><a class="anchor" href="#get_nametag_attributes" name="get_nametag_attributes">#</a><code>get_nametag_attributes()</code><ul>
<li>returns a table with the attributes of the nametag of an object</li>
<li>{
color = {a=0..255, r=0..255, g=0..255, b=0..255},
text = "",
}</li>
</ul>
</li>
<li><a class="anchor" href="#set_nametag_attributesattributes" name="set_nametag_attributesattributes">#</a><code>set_nametag_attributes(attributes)</code><ul>
<li>sets the attributes of the nametag of an object</li>
<li><a class="anchor" href="#attributes" name="attributes">#</a><code>attributes</code>:
{
color = ColorSpec,
text = "My Nametag",
}</li>
</ul>
</li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
<h5 id="luaentitysao-only-no-op-for-other-objects">LuaEntitySAO-only (no-op for other objects)</h5>
2014-12-28 22:26:49 +03:00
<ul>
2017-01-31 17:21:12 +03:00
<li><a class="anchor" href="#set_velocityxnumynumznum" name="set_velocityxnumynumznum">#</a><code>set_velocity({x=num, y=num, z=num})</code></li>
<li><a class="anchor" href="#get_velocity" name="get_velocity">#</a><code>get_velocity()</code>: returns <code>{x=num, y=num, z=num}</code></li>
<li><a class="anchor" href="#set_accelerationxnumynumznum" name="set_accelerationxnumynumznum">#</a><code>set_acceleration({x=num, y=num, z=num})</code></li>
<li><a class="anchor" href="#get_acceleration" name="get_acceleration">#</a><code>get_acceleration()</code>: returns <code>{x=num, y=num, z=num}</code></li>
<li><a class="anchor" href="#set_yawradians" name="set_yawradians">#</a><code>set_yaw(radians)</code></li>
<li><a class="anchor" href="#get_yaw" name="get_yaw">#</a><code>get_yaw()</code>: returns number in radians</li>
<li><a class="anchor" href="#set_texture_modmod" name="set_texture_modmod">#</a><code>set_texture_mod(mod)</code></li>
<li><a class="anchor" href="#get_texture_mod" name="get_texture_mod">#</a><code>get_texture_mod()</code> returns current texture modifier</li>
<li><a class="anchor" href="#set_spritepx0y0num_frames1framelength02select_horiz_by_yawpitchfalse" name="set_spritepx0y0num_frames1framelength02select_horiz_by_yawpitchfalse">#</a><code>set_sprite(p={x=0,y=0}, num_frames=1, framelength=0.2,
2014-12-28 22:55:14 +03:00
select_horiz_by_yawpitch=false)</code><ul>
2014-12-28 22:26:49 +03:00
<li>Select sprite from spritesheet with optional animation and DM-style
2014-12-28 22:55:14 +03:00
texture selection based on yaw relative to camera</li>
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#get_entity_name" name="get_entity_name">#</a><code>get_entity_name()</code> (<strong>Deprecated</strong>: Will be removed in a future version)</li>
<li><a class="anchor" href="#get_luaentity" name="get_luaentity">#</a><code>get_luaentity()</code></li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
<h5 id="player-only-no-op-for-other-objects">Player-only (no-op for other objects)</h5>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#get_player_name" name="get_player_name">#</a><code>get_player_name()</code>: returns <code>""</code> if is not a player</li>
2016-07-22 21:37:58 +03:00
<li><a class="anchor" href="#get_player_velocity" name="get_player_velocity">#</a><code>get_player_velocity()</code>: returns <code>nil</code> if is not a player, otherwise a
table {x, y, z} representing the player's instantaneous velocity in nodes/s</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#get_look_dir" name="get_look_dir">#</a><code>get_look_dir()</code>: get camera direction as a unit vector</li>
2016-07-22 21:37:58 +03:00
<li><a class="anchor" href="#get_look_vertical" name="get_look_vertical">#</a><code>get_look_vertical()</code>: pitch in radians<ul>
<li>Angle ranges between -pi/2 and pi/2, which are straight up and down respectively.</li>
</ul>
</li>
<li><a class="anchor" href="#get_look_horizontal" name="get_look_horizontal">#</a><code>get_look_horizontal()</code>: yaw in radians<ul>
<li>Angle is counter-clockwise from the +z direction.</li>
</ul>
</li>
<li><a class="anchor" href="#set_look_verticalradians" name="set_look_verticalradians">#</a><code>set_look_vertical(radians)</code>: sets look pitch<ul>
<li>radians - Angle from looking forward, where positive is downwards.</li>
</ul>
</li>
<li><a class="anchor" href="#set_look_horizontalradians" name="set_look_horizontalradians">#</a><code>set_look_horizontal(radians)</code>: sets look yaw<ul>
<li>radians - Angle from the +z direction, where positive is counter-clockwise.</li>
</ul>
</li>
<li><a class="anchor" href="#get_look_pitch" name="get_look_pitch">#</a><code>get_look_pitch()</code>: pitch in radians - Deprecated as broken. Use get_look_vertical.<ul>
<li>Angle ranges between -pi/2 and pi/2, which are straight down and up respectively.</li>
</ul>
</li>
<li><a class="anchor" href="#get_look_yaw" name="get_look_yaw">#</a><code>get_look_yaw()</code>: yaw in radians - Deprecated as broken. Use get_look_horizontal.<ul>
<li>Angle is counter-clockwise from the +x direction.</li>
</ul>
</li>
<li><a class="anchor" href="#set_look_pitchradians" name="set_look_pitchradians">#</a><code>set_look_pitch(radians)</code>: sets look pitch - Deprecated. Use set_look_vertical.</li>
<li><a class="anchor" href="#set_look_yawradians" name="set_look_yawradians">#</a><code>set_look_yaw(radians)</code>: sets look yaw - Deprecated. Use set_look_horizontal.</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#get_breath" name="get_breath">#</a><code>get_breath()</code>: returns players breath</li>
<li><a class="anchor" href="#set_breathvalue" name="set_breathvalue">#</a><code>set_breath(value)</code>: sets players breath<ul>
<li><a class="anchor" href="#0_9" name="0_9">#</a>values:<ul>
<li><a class="anchor" href="#0_10" name="0_10">#</a><code>0</code>: player is drowning,</li>
<li><a class="anchor" href="#1" name="1">#</a><code>1</code>-<code>10</code>: remaining number of bubbles</li>
<li><a class="anchor" href="#11" name="11">#</a><code>11</code>: bubbles bar is not shown</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
</ul>
</li>
2017-01-31 17:21:12 +03:00
<li><a class="anchor" href="#set_attributeattributevalue" name="set_attributeattributevalue">#</a><code>set_attribute(attribute, value)</code>: sets an extra attribute with value on player</li>
<li><a class="anchor" href="#get_attributeattribute" name="get_attributeattribute">#</a><code>get_attribute(attribute)</code>: returns value for extra attribute. Returns nil if no attribute found.</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#set_inventory_formspecformspec" name="set_inventory_formspecformspec">#</a><code>set_inventory_formspec(formspec)</code><ul>
2014-12-28 22:26:49 +03:00
<li>Redefine player's inventory form</li>
<li>Should usually be called in on_joinplayer</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#get_inventory_formspec" name="get_inventory_formspec">#</a><code>get_inventory_formspec()</code>: returns a formspec string</li>
<li><a class="anchor" href="#get_player_control" name="get_player_control">#</a><code>get_player_control()</code>: returns table with player pressed keys<ul>
<li><a class="anchor" href="#jumpboolrightboolleftboolLMBboolRMBboolsneakboolaux1booldownboolupbool" name="jumpboolrightboolleftboolLMBboolRMBboolsneakboolaux1booldownboolupbool">#</a><code>{jump=bool,right=bool,left=bool,LMB=bool,RMB=bool,sneak=bool,aux1=bool,down=bool,up=bool}</code></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#get_player_control_bits" name="get_player_control_bits">#</a><code>get_player_control_bits()</code>: returns integer with bit packed player pressed keys<ul>
2014-12-28 22:26:49 +03:00
<li>bit nr/meaning: 0/up ,1/down ,2/left ,3/right ,4/jump ,5/aux1 ,6/sneak ,7/LMB ,8/RMB</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#set_physics_overrideoverride_table" name="set_physics_overrideoverride_table">#</a><code>set_physics_override(override_table)</code><ul>
<li><a class="anchor" href="#override_table" name="override_table">#</a><code>override_table</code> is a table with the following fields:<ul>
<li><a class="anchor" href="#speed" name="speed">#</a><code>speed</code>: multiplier to default walking speed value (default: <code>1</code>)</li>
<li><a class="anchor" href="#jump" name="jump">#</a><code>jump</code>: multiplier to default jump value (default: <code>1</code>)</li>
<li><a class="anchor" href="#gravity" name="gravity">#</a><code>gravity</code>: multiplier to default gravity value (default: <code>1</code>)</li>
<li><a class="anchor" href="#sneak" name="sneak">#</a><code>sneak</code>: whether player can sneak (default: <code>true</code>)</li>
<li><a class="anchor" href="#sneak_glitch" name="sneak_glitch">#</a><code>sneak_glitch</code>: whether player can use the sneak glitch (default: <code>true</code>)</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#get_physics_override" name="get_physics_override">#</a><code>get_physics_override()</code>: returns the table given to set_physics_override</li>
<li><a class="anchor" href="#hud_addhuddefinition" name="hud_addhuddefinition">#</a><code>hud_add(hud definition)</code>: add a HUD element described by HUD def, returns ID
2015-03-17 21:18:48 +03:00
number on success</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#hud_removeid" name="hud_removeid">#</a><code>hud_remove(id)</code>: remove the HUD element of the specified id</li>
<li><a class="anchor" href="#hud_changeidstatvalue" name="hud_changeidstatvalue">#</a><code>hud_change(id, stat, value)</code>: change a value of a previously added HUD element<ul>
<li><a class="anchor" href="#stat" name="stat">#</a>element <code>stat</code> values: <code>position</code>, <code>name</code>, <code>scale</code>, <code>text</code>, <code>number</code>, <code>item</code>, <code>dir</code></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#hud_getid" name="hud_getid">#</a><code>hud_get(id)</code>: gets the HUD element definition structure of the specified ID</li>
<li><a class="anchor" href="#hud_set_flagsflags" name="hud_set_flagsflags">#</a><code>hud_set_flags(flags)</code>: sets specified HUD flags to <code>true</code>/<code>false</code><ul>
<li><a class="anchor" href="#flags_4" name="flags_4">#</a><code>flags</code>: (is visible) <code>hotbar</code>, <code>healthbar</code>, <code>crosshair</code>, <code>wielditem</code>, <code>minimap</code></li>
2017-01-31 17:21:12 +03:00
<li><a class="anchor" href="#true_13" name="true_13">#</a>pass a table containing a <code>true</code>/<code>false</code> value of each flag to be set or unset</li>
2016-03-19 17:25:33 +03:00
<li><a class="anchor" href="#nil_6" name="nil_6">#</a>if a flag equals <code>nil</code>, the flag is not modified</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#minimap" name="minimap">#</a>note that setting <code>minimap</code> modifies the client's permission to view the minimap -</li>
2015-09-03 14:37:50 +03:00
<li>the client may locally elect to not view the minimap</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#hud_get_flags" name="hud_get_flags">#</a><code>hud_get_flags()</code>: returns a table containing status of hud flags<ul>
<li><a class="anchor" href="#hotbartruehealthbartruecrosshairtruewielditemtruebreathbartrueminimaptrue" name="hotbartruehealthbartruecrosshairtruewielditemtruebreathbartrueminimaptrue">#</a>returns <code>{ hotbar=true, healthbar=true, crosshair=true, wielditem=true, breathbar=true, minimap=true }</code></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#hud_set_hotbar_itemcountcount" name="hud_set_hotbar_itemcountcount">#</a><code>hud_set_hotbar_itemcount(count)</code>: sets number of items in builtin hotbar<ul>
<li><a class="anchor" href="#count" name="count">#</a><code>count</code>: number of items, must be between <code>1</code> and <code>23</code></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#hud_get_hotbar_itemcount" name="hud_get_hotbar_itemcount">#</a><code>hud_get_hotbar_itemcount</code>: returns number of visible items</li>
<li><a class="anchor" href="#hud_set_hotbar_imagetexturename" name="hud_set_hotbar_imagetexturename">#</a><code>hud_set_hotbar_image(texturename)</code><ul>
2014-12-28 22:26:49 +03:00
<li>sets background image for hotbar</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#hud_get_hotbar_image" name="hud_get_hotbar_image">#</a><code>hud_get_hotbar_image</code>: returns texturename</li>
<li><a class="anchor" href="#hud_set_hotbar_selected_imagetexturename" name="hud_set_hotbar_selected_imagetexturename">#</a><code>hud_set_hotbar_selected_image(texturename)</code><ul>
2014-12-28 22:26:49 +03:00
<li>sets image for selected item of hotbar</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#hud_get_hotbar_selected_image" name="hud_get_hotbar_selected_image">#</a><code>hud_get_hotbar_selected_image</code>: returns texturename</li>
<li><a class="anchor" href="#set_skybgcolortypetexturenames" name="set_skybgcolortypetexturenames">#</a><code>set_sky(bgcolor, type, {texture names})</code><ul>
<li><a class="anchor" href="#bgcolor_1" name="bgcolor_1">#</a><code>bgcolor</code>: ColorSpec, defaults to white</li>
<li><a class="anchor" href="#regular" name="regular">#</a>Available types:<ul>
<li><a class="anchor" href="#regular_1" name="regular_1">#</a><code>"regular"</code>: Uses 0 textures, <code>bgcolor</code> ignored</li>
<li><a class="anchor" href="#skybox" name="skybox">#</a><code>"skybox"</code>: Uses 6 textures, <code>bgcolor</code> used</li>
<li><a class="anchor" href="#plain" name="plain">#</a><code>"plain"</code>: Uses 0 textures, <code>bgcolor</code> used</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#get_sky" name="get_sky">#</a><code>get_sky()</code>: returns bgcolor, type and a table with the textures</li>
<li><a class="anchor" href="#override_day_night_ratioratioornil" name="override_day_night_ratioratioornil">#</a><code>override_day_night_ratio(ratio or nil)</code><ul>
<li><a class="anchor" href="#0_11" name="0_11">#</a><code>0</code>...<code>1</code>: Overrides day-night ratio, controlling sunlight to a specific amount</li>
2016-03-19 17:25:33 +03:00
<li><a class="anchor" href="#nil_7" name="nil_7">#</a><code>nil</code>: Disables override, defaulting to sunlight based on day-night cycle</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#get_day_night_ratio" name="get_day_night_ratio">#</a><code>get_day_night_ratio()</code>: returns the ratio or nil if it isn't overridden</li>
<li><a class="anchor" href="#set_local_animationstandidlewalkdigwalkdigframe_speedframe_speed" name="set_local_animationstandidlewalkdigwalkdigframe_speedframe_speed">#</a>
2015-06-01 20:48:45 +03:00
<p><code>set_local_animation(stand/idle, walk, dig, walk+dig, frame_speed=frame_speed)</code></p>
2015-03-17 21:18:48 +03:00
<p>set animation for player model in third person view</p>
<pre><code>set_local_animation({x=0, y=79}, -- &lt; stand/idle animation key frames
{x=168, y=187}, -- &lt; walk animation key frames
{x=189, y=198}, -- &lt; dig animation key frames
{x=200, y=219}, -- &lt; walk+dig animation key frames
frame_speed=30): -- &lt; animation frame speed
</code></pre>
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#get_local_animation" name="get_local_animation">#</a><code>get_local_animation()</code>: returns stand, walk, dig, dig+walk tables and frame_speed</li>
<li><a class="anchor" href="#set_eye_offsetx0y0z0x0y0z0" name="set_eye_offsetx0y0z0x0y0z0">#</a><code>set_eye_offset({x=0,y=0,z=0},{x=0,y=0,z=0})</code>: defines offset value for camera per player</li>
2014-12-28 22:26:49 +03:00
<li>in first person view</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#x1010y1015z55" name="x1010y1015z55">#</a>in third person view (max. values <code>{x=-10/10,y=-10,15,z=-5/5}</code>)</li>
<li><a class="anchor" href="#get_eye_offset" name="get_eye_offset">#</a><code>get_eye_offset()</code>: returns offset_first and offset_third</li>
2015-05-27 12:53:46 +03:00
</ul>
</li>
2014-12-28 22:55:14 +03:00
</ul>
<h3 id="invref"><code>InvRef</code></h3>
2014-12-28 22:26:49 +03:00
<p>An <code>InvRef</code> is a reference to an inventory.</p>
2017-02-19 16:15:50 +03:00
<h4 id="methods_6">Methods</h4>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#is_emptylistname" name="is_emptylistname">#</a><code>is_empty(listname)</code>: return <code>true</code> if list is empty</li>
<li><a class="anchor" href="#get_sizelistname" name="get_sizelistname">#</a><code>get_size(listname)</code>: get size of a list</li>
<li><a class="anchor" href="#set_sizelistnamesize" name="set_sizelistnamesize">#</a><code>set_size(listname, size)</code>: set size of a list<ul>
<li><a class="anchor" href="#false_1" name="false_1">#</a>returns <code>false</code> on error (e.g. invalid <code>listname</code> or <code>size</code>)</li>
</ul>
</li>
<li><a class="anchor" href="#get_widthlistname" name="get_widthlistname">#</a><code>get_width(listname)</code>: get width of a list</li>
<li><a class="anchor" href="#set_widthlistnamewidth" name="set_widthlistnamewidth">#</a><code>set_width(listname, width)</code>: set width of list; currently used for crafting</li>
<li><a class="anchor" href="#get_stacklistnamei" name="get_stacklistnamei">#</a><code>get_stack(listname, i)</code>: get a copy of stack index <code>i</code> in list</li>
<li><a class="anchor" href="#set_stacklistnameistack" name="set_stacklistnameistack">#</a><code>set_stack(listname, i, stack)</code>: copy <code>stack</code> to index <code>i</code> in list</li>
<li><a class="anchor" href="#get_listlistname" name="get_listlistname">#</a><code>get_list(listname)</code>: return full list</li>
<li><a class="anchor" href="#set_listlistnamelist" name="set_listlistnamelist">#</a><code>set_list(listname, list)</code>: set full list (size will not change)</li>
<li><a class="anchor" href="#get_lists" name="get_lists">#</a><code>get_lists()</code>: returns list of inventory lists</li>
<li><a class="anchor" href="#set_listslists" name="set_listslists">#</a><code>set_lists(lists)</code>: sets inventory lists (size will not change)</li>
<li><a class="anchor" href="#add_itemlistnamestack" name="add_itemlistnamestack">#</a><code>add_item(listname, stack)</code>: add item somewhere in list, returns leftover <code>ItemStack</code></li>
<li><a class="anchor" href="#room_for_itemlistnamestack" name="room_for_itemlistnamestack">#</a><code>room_for_item(listname, stack):</code> returns <code>true</code> if the stack of items
2014-12-28 22:55:14 +03:00
can be fully added to the list</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#contains_itemlistnamestack" name="contains_itemlistnamestack">#</a><code>contains_item(listname, stack)</code>: returns <code>true</code> if the stack of items
2014-12-28 22:55:14 +03:00
can be fully taken from the list</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#remove_itemlistnamestack" name="remove_itemlistnamestack">#</a><code>remove_item(listname, stack)</code>: take as many items as specified from the list,
2014-12-28 22:55:14 +03:00
returns the items that were actually removed (as an <code>ItemStack</code>) -- note that
any item metadata is ignored, so attempting to remove a specific unique
item this way will likely remove the wrong one -- to do that use <code>set_stack</code>
with an empty <code>ItemStack</code></li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#get_location" name="get_location">#</a><code>get_location()</code>: returns a location compatible to <code>minetest.get_inventory(location)</code><ul>
<li><a class="anchor" href="#typeundefined" name="typeundefined">#</a>returns <code>{type="undefined"}</code> in case location is not known</li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
</li>
</ul>
2015-08-12 16:54:11 +03:00
<h3 id="areastore"><code>AreaStore</code></h3>
<p>A fast access data structure to store areas, and find areas near a given position or area.
Every area has a <code>data</code> string attribute to store additional information.
You can create an empty <code>AreaStore</code> by calling <code>AreaStore()</code>, or <code>AreaStore(type_name)</code>.
2016-07-22 21:37:58 +03:00
If you chose the parameter-less constructor, a fast implementation will be automatically
chosen for you.</p>
2017-02-19 16:15:50 +03:00
<h4 id="methods_7">Methods</h4>
2015-08-12 16:54:11 +03:00
<ul>
2016-07-22 21:37:58 +03:00
<li><a class="anchor" href="#get_areaidinclude_bordersinclude_data" name="get_areaidinclude_bordersinclude_data">#</a><code>get_area(id, include_borders, include_data)</code>: returns the area with the id <code>id</code>.
2016-11-12 19:27:07 +03:00
(optional) Boolean values <code>include_borders</code> and <code>include_data</code> control what's copied.
Returns nil if specified area id does not exist.</li>
2016-07-22 21:37:58 +03:00
<li><a class="anchor" href="#get_areas_for_posposinclude_bordersinclude_data" name="get_areas_for_posposinclude_bordersinclude_data">#</a><code>get_areas_for_pos(pos, include_borders, include_data)</code>: returns all areas that contain
the position <code>pos</code>. (optional) Boolean values <code>include_borders</code> and <code>include_data</code> control
what's copied.</li>
<li><a class="anchor" href="#get_areas_in_areaedge1edge2accept_overlapinclude_bordersinclude_data" name="get_areas_in_areaedge1edge2accept_overlapinclude_bordersinclude_data">#</a><code>get_areas_in_area(edge1, edge2, accept_overlap, include_borders, include_data)</code>:
returns all areas that contain all nodes inside the area specified by <code>edge1</code> and <code>edge2</code> (inclusive).
If <code>accept_overlap</code> is true, also areas are returned that have nodes in common with the specified area.
(optional) Boolean values <code>include_borders</code> and <code>include_data</code> control what's copied.</li>
<li><a class="anchor" href="#insert_areaedge1edge2dataid" name="insert_areaedge1edge2dataid">#</a><code>insert_area(edge1, edge2, data, [id])</code>: inserts an area into the store. Returns the new area's ID,
or nil if the insertion failed. The (inclusive) positions <code>edge1</code> and <code>edge2</code> describe the area.
<code>data</code> is a string stored with the area. If passed, <code>id</code> will be used as the internal area ID,
it must be a unique number between 0 and 2^32-2. If you use the <code>id</code> parameter you must always use it,
or insertions are likely to fail due to conflicts.</li>
<li><a class="anchor" href="#reservecount" name="reservecount">#</a><code>reserve(count)</code>: reserves resources for at most <code>count</code> many contained areas.
Only needed for efficiency, and only some implementations profit.</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#remove_areaid" name="remove_areaid">#</a><code>remove_area(id)</code>: removes the area with the given id from the store, returns success.</li>
2016-07-22 21:37:58 +03:00
<li><a class="anchor" href="#set_cache_paramsparams" name="set_cache_paramsparams">#</a><code>set_cache_params(params)</code>: sets params for the included prefiltering cache.
Calling invalidates the cache, so that its elements have to be newly generated.<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#params" name="params">#</a><code>params</code>:
2015-08-12 16:54:11 +03:00
{
enabled = boolean, -- whether to enable, default true
2016-07-22 21:37:58 +03:00
block_radius = number, -- the radius (in nodes) of the areas the cache generates
prefiltered lists for, minimum 16, default 64
2015-08-12 16:54:11 +03:00
limit = number, -- the cache's size, minimum 20, default 1000
}</li>
</ul>
</li>
2016-03-19 17:25:33 +03:00
<li><a class="anchor" href="#to_string" name="to_string">#</a><code>to_string()</code>: Experimental. Returns area store serialized as a (binary) string.</li>
<li><a class="anchor" href="#to_filefilename" name="to_filefilename">#</a><code>to_file(filename)</code>: Experimental. Like <code>to_string()</code>, but writes the data to a file.</li>
2016-07-22 21:37:58 +03:00
<li><a class="anchor" href="#from_stringstr" name="from_stringstr">#</a><code>from_string(str)</code>: Experimental. Deserializes string and loads it into the AreaStore.
Returns success and, optionally, an error message.</li>
2016-03-19 17:25:33 +03:00
<li><a class="anchor" href="#from_filefilename" name="from_filefilename">#</a><code>from_file(filename)</code>: Experimental. Like <code>from_string()</code>, but reads the data from a file.</li>
2015-08-12 16:54:11 +03:00
</ul>
2014-12-28 22:55:14 +03:00
<h3 id="itemstack_1"><code>ItemStack</code></h3>
2014-12-28 22:26:49 +03:00
<p>An <code>ItemStack</code> is a stack of items.</p>
<p>It can be created via <code>ItemStack(x)</code>, where x is an <code>ItemStack</code>,
an itemstring, a table or <code>nil</code>.</p>
2017-02-19 16:15:50 +03:00
<h4 id="methods_8">Methods</h4>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#is_empty" name="is_empty">#</a><code>is_empty()</code>: Returns <code>true</code> if stack is empty.</li>
<li><a class="anchor" href="#get_name" name="get_name">#</a><code>get_name()</code>: Returns item name (e.g. <code>"default:stone"</code>).</li>
2016-11-12 19:27:07 +03:00
<li><a class="anchor" href="#set_nameitem_name" name="set_nameitem_name">#</a><code>set_name(item_name)</code>: Returns boolean whether item was cleared</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#get_count" name="get_count">#</a><code>get_count()</code>: Returns number of items on the stack.</li>
2016-11-12 19:27:07 +03:00
<li><a class="anchor" href="#set_countcount" name="set_countcount">#</a><code>set_count(count)</code>: Returns boolean whether item was cleared</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#get_wear" name="get_wear">#</a><code>get_wear()</code>: Returns tool wear (<code>0</code>-<code>65535</code>), <code>0</code> for non-tools.</li>
2016-11-12 19:27:07 +03:00
<li><a class="anchor" href="#set_wearwear" name="set_wearwear">#</a><code>set_wear(wear)</code>: Returns boolean whether item was cleared</li>
2017-02-19 16:15:50 +03:00
<li><a class="anchor" href="#get_meta" name="get_meta">#</a><code>get_meta()</code>: Returns ItemStackMetaRef. See section for more details</li>
<li><a class="anchor" href="#get_metadata" name="get_metadata">#</a><code>get_metadata()</code>: (DEPRECATED) Returns metadata (a string attached to an item stack).</li>
<li><a class="anchor" href="#set_metadatametadata" name="set_metadatametadata">#</a><code>set_metadata(metadata)</code>: (DEPRECATED) Returns true.</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#clear" name="clear">#</a><code>clear()</code>: removes all items from the stack, making it empty.</li>
<li><a class="anchor" href="#replaceitem" name="replaceitem">#</a><code>replace(item)</code>: replace the contents of this stack.<ul>
<li><a class="anchor" href="#item_1" name="item_1">#</a><code>item</code> can also be an itemstring or table.</li>
</ul>
</li>
2016-03-19 17:25:33 +03:00
<li><a class="anchor" href="#to_string_1" name="to_string_1">#</a><code>to_string()</code>: Returns the stack in itemstring form.</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#to_table_1" name="to_table_1">#</a><code>to_table()</code>: Returns the stack in Lua table form.</li>
<li><a class="anchor" href="#get_stack_max" name="get_stack_max">#</a><code>get_stack_max()</code>: Returns the maximum size of the stack (depends on the item).</li>
<li><a class="anchor" href="#get_free_space" name="get_free_space">#</a><code>get_free_space()</code>: Returns <code>get_stack_max() - get_count()</code>.</li>
<li><a class="anchor" href="#is_known" name="is_known">#</a><code>is_known()</code>: Returns <code>true</code> if the item name refers to a defined item type.</li>
<li><a class="anchor" href="#get_definition" name="get_definition">#</a><code>get_definition()</code>: Returns the item definition table.</li>
<li><a class="anchor" href="#get_tool_capabilities" name="get_tool_capabilities">#</a><code>get_tool_capabilities()</code>: Returns the digging properties of the item,
2014-12-28 22:55:14 +03:00
or those of the hand if none are defined for this item type</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#add_wearamount" name="add_wearamount">#</a><code>add_wear(amount)</code>: Increases wear by <code>amount</code> if the item is a tool.</li>
<li><a class="anchor" href="#add_itemitem" name="add_itemitem">#</a><code>add_item(item)</code>: Put some item or stack onto this stack.
Returns leftover <code>ItemStack</code>.</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#item_fitsitem" name="item_fitsitem">#</a><code>item_fits(item)</code>: Returns <code>true</code> if item or stack can be fully added to
this one.</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#take_itemn1" name="take_itemn1">#</a><code>take_item(n=1)</code>: Take (and remove) up to <code>n</code> items from this stack.
Returns taken <code>ItemStack</code>.</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#peek_itemn1" name="peek_itemn1">#</a><code>peek_item(n=1)</code>: copy (don't remove) up to <code>n</code> items from this stack.
Returns taken <code>ItemStack</code>.</li>
2014-12-28 22:55:14 +03:00
</ul>
<h3 id="pseudorandom"><code>PseudoRandom</code></h3>
2015-04-29 20:17:32 +03:00
<p>A 16-bit pseudorandom number generator.
Uses a well-known LCG algorithm introduced by K&amp;R.</p>
2014-12-28 22:26:49 +03:00
<p>It can be created via <code>PseudoRandom(seed)</code>.</p>
2017-02-19 16:15:50 +03:00
<h4 id="methods_9">Methods</h4>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#next" name="next">#</a><code>next()</code>: return next integer random number [<code>0</code>...<code>32767</code>]</li>
<li><a class="anchor" href="#nextminmax" name="nextminmax">#</a><code>next(min, max)</code>: return next integer random number [<code>min</code>...<code>max</code>]<ul>
<li><a class="anchor" href="#maxmin32767ormaxmin6553" name="maxmin32767ormaxmin6553">#</a><code>((max - min) == 32767) or ((max-min) &lt;= 6553))</code> must be true
2014-12-28 22:55:14 +03:00
due to the simple implementation making bad distribution otherwise.</li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
</li>
</ul>
2015-04-29 20:17:32 +03:00
<h3 id="pcgrandom"><code>PcgRandom</code></h3>
<p>A 32-bit pseudorandom number generator.
Uses PCG32, an algorithm of the permuted congruential generator family, offering very strong randomness.</p>
<p>It can be created via <code>PcgRandom(seed)</code> or <code>PcgRandom(seed, sequence)</code>.</p>
2017-02-19 16:15:50 +03:00
<h4 id="methods_10">Methods</h4>
2015-04-29 20:17:32 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#next_1" name="next_1">#</a><code>next()</code>: return next integer random number [<code>-2147483648</code>...<code>2147483647</code>]</li>
<li><a class="anchor" href="#nextminmax_1" name="nextminmax_1">#</a><code>next(min, max)</code>: return next integer random number [<code>min</code>...<code>max</code>]</li>
<li><a class="anchor" href="#rand_normal_distminmaxnum_trials6" name="rand_normal_distminmaxnum_trials6">#</a><code>rand_normal_dist(min, max, num_trials=6)</code>: return normally distributed random number [<code>min</code>...<code>max</code>]<ul>
2016-07-22 21:37:58 +03:00
<li>This is only a rough approximation of a normal distribution with:</li>
<li>mean = (max - min) / 2, and</li>
<li>variance = (((max - min + 1) ^ 2) - 1) / (12 * num_trials)</li>
2015-04-29 20:17:32 +03:00
<li>Increasing num_trials improves accuracy of the approximation</li>
</ul>
</li>
</ul>
2015-11-21 18:26:52 +03:00
<h3 id="securerandom"><code>SecureRandom</code></h3>
<p>Interface for the operating system's crypto-secure PRNG.</p>
<p>It can be created via <code>SecureRandom()</code>. The constructor returns nil if a secure random device cannot be
be found on the system.</p>
2017-02-19 16:15:50 +03:00
<h4 id="methods_11">Methods</h4>
2015-11-21 18:26:52 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#next_bytescount" name="next_bytescount">#</a><code>next_bytes([count])</code>: return next <code>count</code> (default 1, capped at 2048) many random bytes, as a string.</li>
2015-11-21 18:26:52 +03:00
</ul>
2014-12-28 22:55:14 +03:00
<h3 id="perlinnoise"><code>PerlinNoise</code></h3>
2014-12-28 22:26:49 +03:00
<p>A perlin noise generator.
It can be created via <code>PerlinNoise(seed, octaves, persistence, scale)</code>
2015-02-16 20:35:00 +03:00
or <code>PerlinNoise(noiseparams)</code>.
2014-12-28 22:26:49 +03:00
Alternatively with <code>minetest.get_perlin(seeddiff, octaves, persistence, scale)</code>
or <code>minetest.get_perlin(noiseparams)</code>.</p>
2017-02-19 16:15:50 +03:00
<h4 id="methods_12">Methods</h4>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#get2dpos" name="get2dpos">#</a><code>get2d(pos)</code>: returns 2D noise value at <code>pos={x=,y=}</code></li>
<li><a class="anchor" href="#get3dpos" name="get3dpos">#</a><code>get3d(pos)</code>: returns 3D noise value at <code>pos={x=,y=,z=}</code></li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
<h3 id="perlinnoisemap"><code>PerlinNoiseMap</code></h3>
2014-12-28 22:26:49 +03:00
<p>A fast, bulk perlin noise generator.</p>
<p>It can be created via <code>PerlinNoiseMap(noiseparams, size)</code> or
<code>minetest.get_perlin_map(noiseparams, size)</code>.</p>
<p>Format of <code>size</code> is <code>{x=dimx, y=dimy, z=dimz}</code>. The <code>z</code> conponent is ommitted
for 2D noise, and it must be must be larger than 1 for 3D noise (otherwise
<code>nil</code> is returned).</p>
2015-05-27 12:53:46 +03:00
<p>For each of the functions with an optional <code>buffer</code> parameter: If <code>buffer</code> is not
nil, this table will be used to store the result instead of creating a new table.</p>
2017-02-19 16:15:50 +03:00
<h4 id="methods_13">Methods</h4>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#get2dMappos" name="get2dMappos">#</a><code>get2dMap(pos)</code>: returns a <code>&lt;size.x&gt;</code> times <code>&lt;size.y&gt;</code> 2D array of 2D noise
2014-12-28 22:55:14 +03:00
with values starting at <code>pos={x=,y=}</code></li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#get3dMappos" name="get3dMappos">#</a><code>get3dMap(pos)</code>: returns a <code>&lt;size.x&gt;</code> times <code>&lt;size.y&gt;</code> times <code>&lt;size.z&gt;</code> 3D array
2014-12-28 22:55:14 +03:00
of 3D noise with values starting at <code>pos={x=,y=,z=}</code></li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#get2dMap_flatposbuffer" name="get2dMap_flatposbuffer">#</a><code>get2dMap_flat(pos, buffer)</code>: returns a flat <code>&lt;size.x * size.y&gt;</code> element array of 2D noise
2015-01-24 22:07:00 +03:00
with values starting at <code>pos={x=,y=}</code></li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#get3dMap_flatposbuffer" name="get3dMap_flatposbuffer">#</a><code>get3dMap_flat(pos, buffer)</code>: Same as <code>get2dMap_flat</code>, but 3D noise</li>
<li><a class="anchor" href="#calc2dMappos" name="calc2dMappos">#</a><code>calc2dMap(pos)</code>: Calculates the 2d noise map starting at <code>pos</code>. The result is stored internally.</li>
<li><a class="anchor" href="#calc3dMappos" name="calc3dMappos">#</a><code>calc3dMap(pos)</code>: Calculates the 3d noise map starting at <code>pos</code>. The result is stored internally.</li>
<li><a class="anchor" href="#getMapSliceslice_offsetslice_sizebuffer" name="getMapSliceslice_offsetslice_sizebuffer">#</a><code>getMapSlice(slice_offset, slice_size, buffer)</code>: In the form of an array, returns a slice of the
2015-05-27 12:53:46 +03:00
most recently computed noise results. The result slice begins at coordinates <code>slice_offset</code> and
takes a chunk of <code>slice_size</code>.
E.g. to grab a 2-slice high horizontal 2d plane of noise starting at buffer offset y = 20:
<code>noisevals = noise:getMapSlice({y=20}, {y=2})</code>
It is important to note that <code>slice_offset</code> offset coordinates begin at 1, and are relative to
the starting position of the most recently calculated noise.
To grab a single vertical column of noise starting at map coordinates x = 1023, y=1000, z = 1000:
<code>noise:calc3dMap({x=1000, y=1000, z=1000})</code>
2015-11-22 19:41:52 +03:00
<code>noisevals = noise:getMapSlice({x=24, z=1}, {x=1, z=1})</code></li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
<h3 id="voxelmanip"><code>VoxelManip</code></h3>
2015-11-21 18:26:52 +03:00
<h4 id="about-voxelmanip">About VoxelManip</h4>
<p>VoxelManip is a scripting interface to the internal 'Map Voxel Manipulator' facility. The purpose of
this object is for fast, low-level, bulk access to reading and writing Map content. As such, setting
map nodes through VoxelManip will lack many of the higher level features and concepts you may be used
to with other methods of setting nodes. For example, nodes will not have their construction and
destruction callbacks run, and no rollback information is logged.</p>
<p>It is important to note that VoxelManip is designed for speed, and <em>not</em> ease of use or flexibility.
If your mod requires a map manipulation facility that will handle 100% of all edge cases, or the use
of high level node placement features, perhaps minetest.set_node() is better suited for the job.</p>
<p>In addition, VoxelManip might not be faster, or could even be slower, for your specific use case.
VoxelManip is most effective when setting very large areas of map at once - for example, if only
setting a 5x5x5 node area, a minetest.set_node() loop may be more optimal. Always profile code
using both methods of map manipulation to determine which is most appropriate for your usage.</p>
<h4 id="using-voxelmanip">Using VoxelManip</h4>
<p>A VoxelManip object can be created any time using either:
<code>VoxelManip([p1, p2])</code>, or <code>minetest.get_voxel_manip([p1, p2])</code>.</p>
<p>If the optional position parameters are present for either of these routines, the specified region
will be pre-loaded into the VoxelManip object on creation. Otherwise, the area of map you wish to
manipulate must first be loaded into the VoxelManip object using <code>VoxelManip:read_from_map()</code>.</p>
<p>Note that <code>VoxelManip:read_from_map()</code> returns two position vectors. The region formed by these
positions indicate the minimum and maximum (respectively) positions of the area actually loaded in
the VoxelManip, which may be larger than the area requested. For convenience, the loaded area
coordinates can also be queried any time after loading map data with <code>VoxelManip:get_emerged_area()</code>.</p>
<p>Now that the VoxelManip object is populated with map data, your mod can fetch a copy of this data
using either of two methods. <code>VoxelManip:get_node_at()</code>, which retrieves an individual node in a
MapNode formatted table at the position requested is the simplest method to use, but also the slowest.</p>
<p>Nodes in a VoxelManip object may also be read in bulk to a flat array table using:
<code>VoxelManip:get_data()</code> for node content (in Content ID form, see section 'Content IDs'),
<code>VoxelManip:get_light_data()</code> for node light levels, and
<code>VoxelManip:get_param2_data()</code> for the node type-dependent "param2" values.</p>
<p>See section 'Flat array format' for more details.</p>
<p>It is very important to understand that the tables returned by any of the above three functions
represent a snapshot of the VoxelManip's internal state at the time of the call. This copy of the
data will <em>not</em> magically update itself if another function modifies the internal VoxelManip state.
Any functions that modify a VoxelManip's contents work on the VoxelManip's internal state unless
otherwise explicitly stated.</p>
<p>Once the bulk data has been edited to your liking, the internal VoxelManip state can be set using:
<code>VoxelManip:set_data()</code> for node content (in Content ID form, see section 'Content IDs'),
<code>VoxelManip:set_light_data()</code> for node light levels, and
<code>VoxelManip:set_param2_data()</code> for the node type-dependent "param2" values.</p>
<p>The parameter to each of the above three functions can use any table at all in the same flat array
format as produced by get_data() et al. and is <em>not required</em> to be a table retrieved from get_data().</p>
<p>Once the internal VoxelManip state has been modified to your liking, the changes can be committed back
to the map by calling <code>VoxelManip:write_to_map()</code>.</p>
<p>Finally, a call to <code>VoxelManip:update_map()</code> is required to re-calculate lighting and set the blocks
as being modified so that connected clients are sent the updated parts of map.</p>
<h5 id="flat-array-format">Flat array format</h5>
<p>Let
<code>Nx = p2.X - p1.X + 1</code>,
<code>Ny = p2.Y - p1.Y + 1</code>, and
<code>Nz = p2.Z - p1.Z + 1</code>.</p>
<p>Then, for a loaded region of p1..p2, this array ranges from <code>1</code> up to and including the value of
the expression <code>Nx * Ny * Nz</code>.</p>
<p>Positions offset from p1 are present in the array with the format of:
<code>[
(0, 0, 0), (1, 0, 0), (2, 0, 0), ... (Nx, 0, 0),
(0, 1, 0), (1, 1, 0), (2, 1, 0), ... (Nx, 1, 0),
...
(0, Ny, 0), (1, Ny, 0), (2, Ny, 0), ... (Nx, Ny, 0),
(0, 0, 1), (1, 0, 1), (2, 0, 1), ... (Nx, 0, 1),
...
(0, Ny, 2), (1, Ny, 2), (2, Ny, 2), ... (Nx, Ny, 2),
...
(0, Ny, Nz), (1, Ny, Nz), (2, Ny, Nz), ... (Nx, Ny, Nz)
]</code></p>
<p>and the array index for a position p contained completely in p1..p2 is:</p>
<p><code>(p.Z - p1.Z) * Ny * Nx + (p.Y - p1.Y) * Nx + (p.X - p1.X) + 1</code></p>
<p>Note that this is the same "flat 3D array" format as <code>PerlinNoiseMap:get3dMap_flat()</code>.
VoxelArea objects (see section 'VoxelArea') can be used to simplify calculation of the index
for a single point in a flat VoxelManip array.</p>
<h5 id="content-ids">Content IDs</h5>
<p>A Content ID is a unique integer identifier for a specific node type. These IDs are used by VoxelManip
in place of the node name string for <code>VoxelManip:get_data()</code> and <code>VoxelManip:set_data()</code>. You can use
<code>minetest.get_content_id()</code> to look up the Content ID for the specified node name, and
<code>minetest.get_name_from_content_id()</code> to look up the node name string for a given Content ID.
After registration of a node, its Content ID will remain the same throughout execution of the mod.
Note that the node being queried needs to have already been been registered.</p>
<p>The following builtin node types have their Content IDs defined as constants:
<code>core.CONTENT_UNKNOWN (ID for "unknown" nodes)
core.CONTENT_AIR (ID for "air" nodes)
core.CONTENT_IGNORE (ID for "ignore" nodes)</code></p>
<h5 id="mapgen-voxelmanip-objects">Mapgen VoxelManip objects</h5>
<p>Inside of <code>on_generated()</code> callbacks, it is possible to retrieve the same VoxelManip object used by the
core's Map Generator (commonly abbreviated Mapgen). Most of the rules previously described still apply
2015-12-07 21:04:11 +03:00
but with a few differences:</p>
<ul>
<li><a class="anchor" href="#minetestget_mapgen_objectvoxelmanip" name="minetestget_mapgen_objectvoxelmanip">#</a>The Mapgen VoxelManip object is retrieved using: <code>minetest.get_mapgen_object("voxelmanip")</code></li>
<li><a class="anchor" href="#VoxelManipread_from_map" name="VoxelManipread_from_map">#</a>This VoxelManip object already has the region of map just generated loaded into it; it's not necessary
to call <code>VoxelManip:read_from_map()</code> before using a Mapgen VoxelManip.</li>
<li><a class="anchor" href="#on_generated" name="on_generated">#</a>The <code>on_generated()</code> callbacks of some mods may place individual nodes in the generated area using
2015-11-21 18:26:52 +03:00
non-VoxelManip map modification methods. Because the same Mapgen VoxelManip object is passed through
each <code>on_generated()</code> callback, it becomes necessary for the Mapgen VoxelManip object to maintain
consistency with the current map state. For this reason, calling any of the following functions:
<code>minetest.add_node()</code>, <code>minetest.set_node()</code>, or <code>minetest.swap_node()</code>
2015-12-07 21:04:11 +03:00
will also update the Mapgen VoxelManip object's internal state active on the current thread.</li>
<li><a class="anchor" href="#VoxelManipcalc_lighting" name="VoxelManipcalc_lighting">#</a>After modifying the Mapgen VoxelManip object's internal buffer, it may be necessary to update lighting
information using either: <code>VoxelManip:calc_lighting()</code> or <code>VoxelManip:set_lighting()</code>.</li>
<li><a class="anchor" href="#VoxelManipupdate_map" name="VoxelManipupdate_map">#</a><code>VoxelManip:update_map()</code> does not need to be called after <code>write_to_map()</code>. The map update is performed
automatically after all on_generated callbacks have been run for that generated block.</li>
</ul>
2015-11-21 18:26:52 +03:00
<h5 id="other-api-functions-operating-on-a-voxelmanip">Other API functions operating on a VoxelManip</h5>
<p>If any VoxelManip contents were set to a liquid node, <code>VoxelManip:update_liquids()</code> must be called
for these liquid nodes to begin flowing. It is recommended to call this function only after having
written all buffered data back to the VoxelManip object, save for special situations where the modder
desires to only have certain liquid nodes begin flowing.</p>
<p>The functions <code>minetest.generate_ores()</code> and <code>minetest.generate_decorations()</code> will generate all
registered decorations and ores throughout the full area inside of the specified VoxelManip object.</p>
<p><code>minetest.place_schematic_on_vmanip()</code> is otherwise identical to <code>minetest.place_schematic()</code>,
except instead of placing the specified schematic directly on the map at the specified position, it
will place the schematic inside of the VoxelManip.</p>
<h5 id="notes">Notes</h5>
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#VoxelManipget_data" name="VoxelManipget_data">#</a>Attempting to read data from a VoxelManip object before map is read will result in a zero-length
2015-11-21 18:26:52 +03:00
array table for <code>VoxelManip:get_data()</code>, and an "ignore" node at any position for
<code>VoxelManip:get_node_at()</code>.</li>
<li>If either a region of map has not yet been generated or is out-of-bounds of the map, that region is
filled with "ignore" nodes.</li>
<li>Other mods, or the core itself, could possibly modify the area of map currently loaded into a VoxelManip
object. With the exception of Mapgen VoxelManips (see above section), the internal buffers are not
updated. For this reason, it is strongly encouraged to complete the usage of a particular VoxelManip
object in the same callback it had been created.</li>
2015-12-07 21:04:11 +03:00
<li><a class="anchor" href="#on_generated_1" name="on_generated_1">#</a>If a VoxelManip object will be used often, such as in an <code>on_generated()</code> callback, consider passing
2015-11-21 18:26:52 +03:00
a file-scoped table as the optional parameter to <code>VoxelManip:get_data()</code>, which serves as a static
buffer the function can use to write map data to instead of returning a new table each call. This
greatly enhances performance by avoiding unnecessary memory allocations.</li>
</ul>
2017-02-19 16:15:50 +03:00
<h4 id="methods_14">Methods</h4>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#read_from_mapp1p2" name="read_from_mapp1p2">#</a><code>read_from_map(p1, p2)</code>: Loads a chunk of map into the VoxelManip object containing
2015-11-21 18:26:52 +03:00
the region formed by <code>p1</code> and <code>p2</code>.<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#pmin" name="pmin">#</a>returns actual emerged <code>pmin</code>, actual emerged <code>pmax</code></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#write_to_map" name="write_to_map">#</a><code>write_to_map()</code>: Writes the data loaded from the <code>VoxelManip</code> back to the map.<ul>
<li><a class="anchor" href="#VoxelManipset_data" name="VoxelManipset_data">#</a><strong>important</strong>: data must be set using <code>VoxelManip:set_data()</code> before calling this</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#get_node_atpos" name="get_node_atpos">#</a><code>get_node_at(pos)</code>: Returns a <code>MapNode</code> table of the node currently loaded in
2015-03-17 21:18:48 +03:00
the <code>VoxelManip</code> at that position</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#set_node_atposnode" name="set_node_atposnode">#</a><code>set_node_at(pos, node)</code>: Sets a specific <code>MapNode</code> in the <code>VoxelManip</code> at that position</li>
<li><a class="anchor" href="#get_databuffer" name="get_databuffer">#</a><code>get_data([buffer])</code>: Retrieves the node content data loaded into the <code>VoxelManip</code> object<ul>
2015-05-27 12:53:46 +03:00
<li>returns raw node data in the form of an array of node content IDs</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#buffer" name="buffer">#</a>if the param <code>buffer</code> is present, this table will be used to store the result instead</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#set_datadata" name="set_datadata">#</a><code>set_data(data)</code>: Sets the data contents of the <code>VoxelManip</code> object</li>
<li><a class="anchor" href="#update_map" name="update_map">#</a><code>update_map()</code>: Update map after writing chunk back to map.<ul>
<li><a class="anchor" href="#VoxelManip" name="VoxelManip">#</a>To be used only by <code>VoxelManip</code> objects created by the mod itself;
2015-03-17 21:18:48 +03:00
not a <code>VoxelManip</code> that was retrieved from <code>minetest.get_mapgen_object</code></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-12-07 21:04:11 +03:00
<li><a class="anchor" href="#set_lightinglightp1p2" name="set_lightinglightp1p2">#</a><code>set_lighting(light, [p1, p2])</code>: Set the lighting within the <code>VoxelManip</code> to a uniform value<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#light" name="light">#</a><code>light</code> is a table, <code>{day=&lt;0...15&gt;, night=&lt;0...15&gt;}</code></li>
<li><a class="anchor" href="#VoxelManip_1" name="VoxelManip_1">#</a>To be used only by a <code>VoxelManip</code> object from <code>minetest.get_mapgen_object</code></li>
<li><a class="anchor" href="#p1" name="p1">#</a>(<code>p1</code>, <code>p2</code>) is the area in which lighting is set;
2015-03-17 21:18:48 +03:00
defaults to the whole area if left out</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#get_light_data" name="get_light_data">#</a><code>get_light_data()</code>: Gets the light data read into the <code>VoxelManip</code> object<ul>
<li><a class="anchor" href="#0_12" name="0_12">#</a>Returns an array (indices 1 to volume) of integers ranging from <code>0</code> to <code>255</code></li>
<li><a class="anchor" href="#0_13" name="0_13">#</a>Each value is the bitwise combination of day and night light values (<code>0</code> to <code>15</code> each)</li>
<li><a class="anchor" href="#lightdaynight16" name="lightdaynight16">#</a><code>light = day + (night * 16)</code></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#set_light_datalight_data" name="set_light_datalight_data">#</a><code>set_light_data(light_data)</code>: Sets the <code>param1</code> (light) contents of each node
2015-03-17 21:18:48 +03:00
in the <code>VoxelManip</code><ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#get_light_data_1" name="get_light_data_1">#</a>expects lighting data in the same format that <code>get_light_data()</code> returns</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2016-11-12 19:27:07 +03:00
<li><a class="anchor" href="#get_param2_databuffer" name="get_param2_databuffer">#</a><code>get_param2_data([buffer])</code>: Gets the raw <code>param2</code> data read into the <code>VoxelManip</code> object<ul>
<li><a class="anchor" href="#0_14" name="0_14">#</a>Returns an array (indices 1 to volume) of integers ranging from <code>0</code> to <code>255</code></li>
<li><a class="anchor" href="#buffer_1" name="buffer_1">#</a>If the param <code>buffer</code> is present, this table will be used to store the result instead</li>
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#set_param2_dataparam2_data" name="set_param2_dataparam2_data">#</a><code>set_param2_data(param2_data)</code>: Sets the <code>param2</code> contents of each node in the <code>VoxelManip</code></li>
2015-12-07 21:04:11 +03:00
<li><a class="anchor" href="#calc_lightingp1p2propagate_shadow" name="calc_lightingp1p2propagate_shadow">#</a><code>calc_lighting([p1, p2], [propagate_shadow])</code>: Calculate lighting within the <code>VoxelManip</code><ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#VoxelManip_2" name="VoxelManip_2">#</a>To be used only by a <code>VoxelManip</code> object from <code>minetest.get_mapgen_object</code></li>
<li><a class="anchor" href="#p1_1" name="p1_1">#</a>(<code>p1</code>, <code>p2</code>) is the area in which lighting is set; defaults to the whole area
2015-12-07 21:04:11 +03:00
if left out or nil</li>
<li><a class="anchor" href="#propagate_shadow" name="propagate_shadow">#</a><code>propagate_shadow</code> is an optional boolean deciding whether shadows in a generated
mapchunk above are propagated down into the mapchunk; defaults to <code>true</code> if left out</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#update_liquids" name="update_liquids">#</a><code>update_liquids()</code>: Update liquid flow</li>
<li><a class="anchor" href="#was_modified" name="was_modified">#</a><code>was_modified()</code>: Returns <code>true</code> or <code>false</code> if the data in the voxel manipulator
2015-03-17 21:18:48 +03:00
had been modified since the last read from map, due to a call to
<code>minetest.set_data()</code> on the loaded area elsewhere</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#get_emerged_area" name="get_emerged_area">#</a><code>get_emerged_area()</code>: Returns actual emerged minimum and maximum positions.</li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
<h3 id="voxelarea"><code>VoxelArea</code></h3>
2014-12-28 22:26:49 +03:00
<p>A helper class for voxel areas.
It can be created via <code>VoxelArea:new{MinEdge=pmin, MaxEdge=pmax}</code>.
The coordinates are <em>inclusive</em>, like most other things in Minetest.</p>
2017-02-19 16:15:50 +03:00
<h4 id="methods_15">Methods</h4>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#getExtent" name="getExtent">#</a><code>getExtent()</code>: returns a 3D vector containing the size of the area formed by
2015-03-17 21:18:48 +03:00
<code>MinEdge</code> and <code>MaxEdge</code></li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#getVolume" name="getVolume">#</a><code>getVolume()</code>: returns the volume of the area formed by <code>MinEdge</code> and <code>MaxEdge</code></li>
<li><a class="anchor" href="#indexxyz" name="indexxyz">#</a><code>index(x, y, z)</code>: returns the index of an absolute position in a flat array starting at <code>1</code><ul>
<li><a class="anchor" href="#VoxelManip_3" name="VoxelManip_3">#</a>useful for things like <code>VoxelManip</code>, raw Schematic specifiers,
2015-03-17 21:18:48 +03:00
<code>PerlinNoiseMap:get2d</code>/<code>3dMap</code>, and so on</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#indexpp" name="indexpp">#</a><code>indexp(p)</code>: same as above, except takes a vector</li>
<li><a class="anchor" href="#positioni" name="positioni">#</a><code>position(i)</code>: returns the absolute position vector corresponding to index <code>i</code></li>
<li><a class="anchor" href="#containsxyz" name="containsxyz">#</a><code>contains(x, y, z)</code>: check if (<code>x</code>,<code>y</code>,<code>z</code>) is inside area formed by <code>MinEdge</code> and <code>MaxEdge</code></li>
<li><a class="anchor" href="#containspp" name="containspp">#</a><code>containsp(p)</code>: same as above, except takes a vector</li>
<li><a class="anchor" href="#containsii" name="containsii">#</a><code>containsi(i)</code>: same as above, except takes an index <code>i</code></li>
<li><a class="anchor" href="#iterminxminyminzmaxxmaxymaxz" name="iterminxminyminzmaxxmaxymaxz">#</a><code>iter(minx, miny, minz, maxx, maxy, maxz)</code>: returns an iterator that returns indices<ul>
<li><a class="anchor" href="#minx" name="minx">#</a>from (<code>minx</code>,<code>miny</code>,<code>minz</code>) to (<code>maxx</code>,<code>maxy</code>,<code>maxz</code>) in the order of <code>[z [y [x]]]</code></li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#iterpminpmaxp" name="iterpminpmaxp">#</a><code>iterp(minp, maxp)</code>: same as above, except takes a vector</li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
<h3 id="settings"><code>Settings</code></h3>
2014-12-28 22:26:49 +03:00
<p>An interface to read config files in the format of <code>minetest.conf</code>.</p>
<p>It can be created via <code>Settings(filename)</code>.</p>
2017-02-19 16:15:50 +03:00
<h4 id="methods_16">Methods</h4>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#getkey" name="getkey">#</a><code>get(key)</code>: returns a value</li>
<li><a class="anchor" href="#get_boolkey" name="get_boolkey">#</a><code>get_bool(key)</code>: returns a boolean</li>
<li><a class="anchor" href="#setkeyvalue" name="setkeyvalue">#</a><code>set(key, value)</code></li>
<li><a class="anchor" href="#removekey" name="removekey">#</a><code>remove(key)</code>: returns a boolean (<code>true</code> for success)</li>
<li><a class="anchor" href="#get_names" name="get_names">#</a><code>get_names()</code>: returns <code>{key1,...}</code></li>
<li><a class="anchor" href="#write" name="write">#</a><code>write()</code>: returns a boolean (<code>true</code> for success)<ul>
2014-12-28 22:26:49 +03:00
<li>write changes to file</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#to_table_2" name="to_table_2">#</a><code>to_table()</code>: returns <code>{[key1]=value1,...}</code></li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
<h2 id="mapgen-objects">Mapgen objects</h2>
2015-03-17 21:18:48 +03:00
<p>A mapgen object is a construct used in map generation. Mapgen objects can be used
by an <code>on_generate</code> callback to speed up operations by avoiding unnecessary
recalculations; these can be retrieved using the <code>minetest.get_mapgen_object()</code>
function. If the requested Mapgen object is unavailable, or <code>get_mapgen_object()</code>
was called outside of an <code>on_generate()</code> callback, <code>nil</code> is returned.</p>
2014-12-28 22:26:49 +03:00
<p>The following Mapgen objects are currently available:</p>
2014-12-28 22:55:14 +03:00
<h3 id="voxelmanip_1"><code>voxelmanip</code></h3>
2015-03-17 21:18:48 +03:00
<p>This returns three values; the <code>VoxelManip</code> object to be used, minimum and maximum
emerged position, in that order. All mapgens support this object.</p>
2014-12-28 22:55:14 +03:00
<h3 id="heightmap"><code>heightmap</code></h3>
2015-03-17 21:18:48 +03:00
<p>Returns an array containing the y coordinates of the ground levels of nodes in
the most recently generated chunk by the current mapgen.</p>
2014-12-28 22:55:14 +03:00
<h3 id="biomemap"><code>biomemap</code></h3>
2015-03-17 21:18:48 +03:00
<p>Returns an array containing the biome IDs of nodes in the most recently
generated chunk by the current mapgen.</p>
2014-12-28 22:55:14 +03:00
<h3 id="heatmap"><code>heatmap</code></h3>
2015-03-17 21:18:48 +03:00
<p>Returns an array containing the temperature values of nodes in the most
recently generated chunk by the current mapgen.</p>
2014-12-28 22:55:14 +03:00
<h3 id="humiditymap"><code>humiditymap</code></h3>
2015-03-17 21:18:48 +03:00
<p>Returns an array containing the humidity values of nodes in the most recently
generated chunk by the current mapgen.</p>
2014-12-28 22:55:14 +03:00
<h3 id="gennotify"><code>gennotify</code></h3>
2015-03-17 21:18:48 +03:00
<p>Returns a table mapping requested generation notification types to arrays of
positions at which the corresponding generated structures are located at within
the current chunk. To set the capture of positions of interest to be recorded
on generate, use <code>minetest.set_gen_notify()</code>.</p>
2014-12-28 22:26:49 +03:00
<p>Possible fields of the table returned are:</p>
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#dungeon" name="dungeon">#</a><code>dungeon</code></li>
<li><a class="anchor" href="#temple" name="temple">#</a><code>temple</code></li>
<li><a class="anchor" href="#cave_begin" name="cave_begin">#</a><code>cave_begin</code></li>
<li><a class="anchor" href="#cave_end" name="cave_end">#</a><code>cave_end</code></li>
<li><a class="anchor" href="#large_cave_begin" name="large_cave_begin">#</a><code>large_cave_begin</code></li>
<li><a class="anchor" href="#large_cave_end" name="large_cave_end">#</a><code>large_cave_end</code></li>
<li><a class="anchor" href="#decoration" name="decoration">#</a><code>decoration</code></li>
2014-12-28 22:26:49 +03:00
</ul>
2015-03-17 21:18:48 +03:00
<p>Decorations have a key in the format of <code>"decoration#id"</code>, where <code>id</code> is the
numeric unique decoration ID.</p>
2014-12-28 22:55:14 +03:00
<h2 id="registered-entities">Registered entities</h2>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#self" name="self">#</a>Functions receive a "luaentity" as <code>self</code>:<ul>
2016-11-12 19:27:07 +03:00
<li><a class="anchor" href="#name_15" name="name_15">#</a>It has the member <code>.name</code>, which is the registered name <code>("mod:thing")</code></li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#object" name="object">#</a>It has the member <code>.object</code>, which is an <code>ObjectRef</code> pointing to the object</li>
2014-12-28 22:26:49 +03:00
<li>The original prototype stuff is visible directly via a metatable</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2016-11-12 19:27:07 +03:00
<li><a class="anchor" href="#on_activateselfstaticdatadtime_s" name="on_activateselfstaticdatadtime_s">#</a>Callbacks:<ul>
<li><a class="anchor" href="#on_activateselfstaticdatadtime_s_1" name="on_activateselfstaticdatadtime_s_1">#</a><code>on_activate(self, staticdata, dtime_s)</code><ul>
2014-12-28 22:26:49 +03:00
<li>Called when the object is instantiated.</li>
2016-11-12 19:27:07 +03:00
<li><a class="anchor" href="#dtime_s" name="dtime_s">#</a><code>dtime_s</code> is the time passed since the object was unloaded, which can
be used for updating the entity state.</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#on_stepselfdtime" name="on_stepselfdtime">#</a><code>on_step(self, dtime)</code><ul>
<li><a class="anchor" href="#dtime" name="dtime">#</a>Called on every server tick, after movement and collision processing.
2014-12-28 22:55:14 +03:00
<code>dtime</code> is usually 0.1 seconds, as per the <code>dedicated_server_step</code> setting
<code>in minetest.conf</code>.</li>
</ul>
</li>
2016-11-12 19:27:07 +03:00
<li><a class="anchor" href="#on_punchselfpunchertime_from_last_punchtool_capabilitiesdir" name="on_punchselfpunchertime_from_last_punchtool_capabilitiesdir">#</a><code>on_punch(self, puncher, time_from_last_punch, tool_capabilities, dir)</code><ul>
2014-12-28 22:26:49 +03:00
<li>Called when somebody punches the object.</li>
<li>Note that you probably want to handle most punches using the
2014-12-28 22:55:14 +03:00
automatic armor group system.</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#puncher_2" name="puncher_2">#</a><code>puncher</code>: an <code>ObjectRef</code> (can be <code>nil</code>)</li>
<li><a class="anchor" href="#time_from_last_punch_3" name="time_from_last_punch_3">#</a><code>time_from_last_punch</code>: Meant for disallowing spamming of clicks (can be <code>nil</code>)</li>
<li><a class="anchor" href="#tool_capabilities_2" name="tool_capabilities_2">#</a><code>tool_capabilities</code>: capability table of used tool (can be <code>nil</code>)</li>
<li><a class="anchor" href="#dir_1" name="dir_1">#</a><code>dir</code>: unit vector of direction of punch. Always defined. Points from
2014-12-28 22:55:14 +03:00
the puncher to the punched.</li>
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#on_rightclickselfclicker" name="on_rightclickselfclicker">#</a><code>on_rightclick(self, clicker)</code></li>
<li><a class="anchor" href="#get_staticdataself" name="get_staticdataself">#</a><code>get_staticdata(self)</code><ul>
<li><a class="anchor" href="#on_activate" name="on_activate">#</a>Should return a string that will be passed to <code>on_activate</code> when
2014-12-28 22:55:14 +03:00
the object is instantiated the next time.</li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
</li>
</ul>
</li>
</ul>
<h2 id="l-system-trees">L-system trees</h2>
2016-05-26 20:47:50 +03:00
<p><strong>Warning</strong>
L-system generation currently creates lighting bugs in the form of mapblock-sized shadows.
Often these bugs appear as subtle shadows in water.</p>
2014-12-28 22:55:14 +03:00
<h3 id="tree-definition">Tree definition</h3>
2014-12-28 22:26:49 +03:00
<pre><code>treedef={
axiom, --string initial tree axiom
rules_a, --string rules set A
rules_b, --string rules set B
rules_c, --string rules set C
rules_d, --string rules set D
trunk, --string trunk node name
leaves, --string leaves node name
leaves2, --string secondary leaves node name
leaves2_chance,--num chance (0-100) to replace leaves with leaves2
angle, --num angle in deg
iterations, --num max # of iterations, usually 2 -5
random_level, --num factor to lower nr of iterations, usually 0 - 3
2015-03-17 21:18:48 +03:00
trunk_type, --string single/double/crossed) type of trunk: 1 node,
-- 2x2 nodes or 3x3 in cross shape
2014-12-28 22:26:49 +03:00
thin_branches, --boolean true -&gt; use thin (1 node) branches
fruit, --string fruit node name
fruit_chance, --num chance (0-100) to replace leaves with fruit node
seed, --num random seed; if no seed is provided, the engine will create one
}
</code></pre>
2014-12-28 22:55:14 +03:00
<h3 id="key-for-special-l-system-symbols-used-in-axioms">Key for Special L-System Symbols used in Axioms</h3>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#G" name="G">#</a><code>G</code>: move forward one unit with the pen up</li>
<li><a class="anchor" href="#F" name="F">#</a><code>F</code>: move forward one unit with the pen down drawing trunks and branches</li>
<li><a class="anchor" href="#f" name="f">#</a><code>f</code>: move forward one unit with the pen down drawing leaves (100% chance)</li>
<li><a class="anchor" href="#T" name="T">#</a><code>T</code>: move forward one unit with the pen down drawing trunks only</li>
<li><a class="anchor" href="#R" name="R">#</a><code>R</code>: move forward one unit with the pen down placing fruit</li>
<li><a class="anchor" href="#A" name="A">#</a><code>A</code>: replace with rules set A</li>
<li><a class="anchor" href="#B" name="B">#</a><code>B</code>: replace with rules set B</li>
<li><a class="anchor" href="#C" name="C">#</a><code>C</code>: replace with rules set C</li>
<li><a class="anchor" href="#D" name="D">#</a><code>D</code>: replace with rules set D</li>
2016-03-19 17:25:33 +03:00
<li><a class="anchor" href="#a_1" name="a_1">#</a><code>a</code>: replace with rules set A, chance 90%</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#b" name="b">#</a><code>b</code>: replace with rules set B, chance 80%</li>
<li><a class="anchor" href="#c" name="c">#</a><code>c</code>: replace with rules set C, chance 70%</li>
<li><a class="anchor" href="#d" name="d">#</a><code>d</code>: replace with rules set D, chance 60%</li>
2014-12-28 22:26:49 +03:00
<li><code>+</code>: yaw the turtle right by <code>angle</code> parameter</li>
<li><code>-</code>: yaw the turtle left by <code>angle</code> parameter</li>
<li><code>&amp;</code>: pitch the turtle down by <code>angle</code> parameter</li>
<li><code>^</code>: pitch the turtle up by <code>angle</code> parameter</li>
<li><code>/</code>: roll the turtle to the right by <code>angle</code> parameter</li>
<li><code>*</code>: roll the turtle to the left by <code>angle</code> parameter</li>
<li><code>[</code>: save in stack current state info</li>
<li><code>]</code>: recover from stack state info</li>
</ul>
2014-12-28 22:55:14 +03:00
<h3 id="example_1">Example</h3>
2014-12-28 22:26:49 +03:00
<p>Spawn a small apple tree:</p>
<pre><code>pos = {x=230,y=20,z=4}
apple_tree={
axiom="FFFFFAFFBF",
rules_a="[&amp;&amp;&amp;FFFFF&amp;&amp;FFFF][&amp;&amp;&amp;++++FFFFF&amp;&amp;FFFF][&amp;&amp;&amp;----FFFFF&amp;&amp;FFFF]",
rules_b="[&amp;&amp;&amp;++FFFFF&amp;&amp;FFFF][&amp;&amp;&amp;--FFFFF&amp;&amp;FFFF][&amp;&amp;&amp;------FFFFF&amp;&amp;FFFF]",
trunk="default:tree",
leaves="default:leaves",
angle=30,
iterations=2,
random_level=0,
trunk_type="single",
thin_branches=true,
fruit_chance=10,
fruit="default:apple"
}
minetest.spawn_tree(pos,apple_tree)
</code></pre>
2014-12-28 22:55:14 +03:00
<h2 id="definition-tables">Definition tables</h2>
<h3 id="object-properties">Object Properties</h3>
2014-12-28 22:26:49 +03:00
<pre><code>{
hp_max = 1,
physical = true,
collide_with_objects = true, -- collide with other objects if physical=true
weight = 5,
collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
visual = "cube"/"sprite"/"upright_sprite"/"mesh"/"wielditem",
visual_size = {x=1, y=1},
mesh = "model",
textures = {}, -- number of required textures depends on visual
colors = {}, -- number of required colors depends on visual
spritediv = {x=1, y=1},
initial_sprite_basepos = {x=0, y=0},
is_visible = true,
makes_footstep_sound = false,
automatic_rotate = false,
stepheight = 0,
automatic_face_movement_dir = 0.0,
-- ^ automatically set yaw to movement direction; offset in degrees; false to disable
2016-03-19 17:25:33 +03:00
automatic_face_movement_max_rotation_per_sec = -1,
-- ^ limit automatic rotation to this value in degrees per second. values &lt; 0 no limit
2015-10-26 03:16:41 +03:00
backface_culling = true, -- false to disable backface_culling for model
2016-03-19 17:25:33 +03:00
nametag = "", -- by default empty, for players their name is shown if empty
nametag_color = &lt;color&gt;, -- sets color of nametag as ColorSpec
infotext = "", -- by default empty, text to be shown when pointed at object
2014-12-28 22:26:49 +03:00
}
</code></pre>
2014-12-28 22:55:14 +03:00
<h3 id="entity-definition-register_entity">Entity definition (<code>register_entity</code>)</h3>
2014-12-28 22:26:49 +03:00
<pre><code>{
-- Deprecated: Everything in object properties is read directly from here
initial_properties = --[[&lt;initial object properties&gt;]],
on_activate = function(self, staticdata, dtime_s),
on_step = function(self, dtime),
2016-11-12 19:27:07 +03:00
on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir),
2014-12-28 22:26:49 +03:00
on_rightclick = function(self, clicker),
get_staticdata = function(self),
-- ^ Called sometimes; the string returned is passed to on_activate when
-- the entity is re-activated from static state
2016-12-29 00:57:48 +03:00
-- Also you can define arbitrary member variables here (see item definition for
-- more info)
_custom_field = whatever,
2014-12-28 22:26:49 +03:00
}
</code></pre>
2014-12-28 22:55:14 +03:00
<h3 id="abm-activeblockmodifier-definition-register_abm">ABM (ActiveBlockModifier) definition (<code>register_abm</code>)</h3>
2014-12-28 22:26:49 +03:00
<pre><code>{
2016-07-22 21:37:58 +03:00
label = "Lava cooling",
-- ^ Descriptive label for profiling purposes (optional).
-- Definitions with identical labels will be listed as one.
2014-12-28 22:26:49 +03:00
-- In the following two fields, also group:groupname will work.
nodenames = {"default:lava_source"},
2015-10-26 03:16:41 +03:00
neighbors = {"default:water_source", "default:water_flowing"}, -- Any of these --[[
^ If left out or empty, any neighbor will do ]]
interval = 1.0, -- Operation interval in seconds
chance = 1, -- Chance of trigger per-node per-interval is 1.0 / this
catch_up = true, -- If true, catch-up behaviour is enabled --[[
^ The chance value is temporarily reduced when returning to
an area to simulate time lost by the area being unattended.
^ Note chance value can often be reduced to 1 ]]
2014-12-28 22:26:49 +03:00
action = func(pos, node, active_object_count, active_object_count_wider),
}
</code></pre>
2016-03-19 17:25:33 +03:00
<h3 id="lbm-loadingblockmodifier-definition-register_lbm">LBM (LoadingBlockModifier) definition (<code>register_lbm</code>)</h3>
<pre><code>{
2016-07-22 21:37:58 +03:00
label = "Upgrade legacy doors",
-- ^ Descriptive label for profiling purposes (optional).
-- Definitions with identical labels will be listed as one.
2016-03-19 17:25:33 +03:00
name = "modname:replace_legacy_door",
nodenames = {"default:lava_source"},
-- ^ List of node names to trigger the LBM on.
-- Also non-registered nodes will work.
-- Groups (as of group:groupname) will work as well.
run_at_every_load = false,
-- ^ Whether to run the LBM's action every time a block gets loaded,
-- and not just for blocks that were saved last time before LBMs were
-- introduced to the world.
action = func(pos, node),
}
</code></pre>
2014-12-28 22:55:14 +03:00
<h3 id="item-definition-register_node-register_craftitem-register_tool">Item definition (<code>register_node</code>, <code>register_craftitem</code>, <code>register_tool</code>)</h3>
2014-12-28 22:26:49 +03:00
<pre><code>{
description = "Steel Axe",
2016-08-29 15:43:46 +03:00
groups = {}, -- key = name, value = rating; rating = 1..3.
2014-12-28 22:26:49 +03:00
if rating not applicable, use 1.
2016-08-29 15:43:46 +03:00
e.g. {wool = 1, fluffy = 3}
{soil = 2, outerspace = 1, crumbly = 1}
{bendy = 2, snappy = 1},
{hard = 1, metal = 1, spikes = 1}
2014-12-28 22:26:49 +03:00
inventory_image = "default_tool_steelaxe.png",
wield_image = "",
2016-08-29 15:43:46 +03:00
wield_scale = {x = 1, y = 1, z = 1},
2014-12-28 22:26:49 +03:00
stack_max = 99,
range = 4.0,
liquids_pointable = false,
tool_capabilities = {
full_punch_interval = 1.0,
2016-08-29 15:43:46 +03:00
max_drop_level = 0,
groupcaps = {
2014-12-28 22:26:49 +03:00
-- For example:
2016-08-29 15:43:46 +03:00
choppy = {times = {[1] = 2.50, [2] = 1.40, [3] = 1.00}, uses = 20, maxlevel = 2},
2014-12-28 22:26:49 +03:00
},
2016-08-29 15:43:46 +03:00
damage_groups = {groupname = damage},
2014-12-28 22:26:49 +03:00
},
node_placement_prediction = nil,
--[[
^ If nil and item is node, prediction is made automatically
^ If nil and item is not a node, no prediction is made
^ If "" and item is anything, no prediction is made
^ Otherwise should be name of node which the client immediately places
on ground when the player places the item. Server will always update
actual result to client in a short moment.
]]
sound = {
2016-12-29 00:57:48 +03:00
breaks = "default_tool_break", -- tools only
2014-12-28 22:26:49 +03:00
place = --[[&lt;SimpleSoundSpec&gt;]],
},
on_place = func(itemstack, placer, pointed_thing),
--[[
^ Shall place item and return the leftover itemstack
2016-11-12 19:27:07 +03:00
^ The placer may be any ObjectRef or nil.
2014-12-28 22:26:49 +03:00
^ default: minetest.item_place ]]
2015-12-07 21:04:11 +03:00
on_secondary_use = func(itemstack, user, pointed_thing),
--[[
^ Same as on_place but called when pointing at nothing.
2016-11-12 19:27:07 +03:00
^ The user may be any ObjectRef or nil.
2015-12-07 21:04:11 +03:00
^ pointed_thing : always { type = "nothing" }
]]
2014-12-28 22:26:49 +03:00
on_drop = func(itemstack, dropper, pos),
--[[
^ Shall drop item and return the leftover itemstack
2016-11-12 19:27:07 +03:00
^ The dropper may be any ObjectRef or nil.
2014-12-28 22:26:49 +03:00
^ default: minetest.item_drop ]]
on_use = func(itemstack, user, pointed_thing),
--[[
^ default: nil
^ Function must return either nil if no item shall be removed from
inventory, or an itemstack to replace the original itemstack.
e.g. itemstack:take_item(); return itemstack
^ Otherwise, the function is free to do what it wants.
2016-11-12 19:27:07 +03:00
^ The user may be any ObjectRef or nil.
2014-12-28 22:26:49 +03:00
^ The default functions handle regular use cases.
]]
after_use = func(itemstack, user, node, digparams),
--[[
^ default: nil
^ If defined, should return an itemstack and will be called instead of
wearing out the tool. If returns nil, does nothing.
If after_use doesn't exist, it is the same as:
function(itemstack, user, node, digparams)
itemstack:add_wear(digparams.wear)
return itemstack
end
2016-11-12 19:27:07 +03:00
^ The user may be any ObjectRef or nil.
2014-12-28 22:26:49 +03:00
]]
2016-12-29 00:57:48 +03:00
_custom_field = whatever,
--[[
^ Add your own custom fields. By convention, all custom field names
should start with `_` to avoid naming collisions with future engine
usage.
]]
2014-12-28 22:26:49 +03:00
}
</code></pre>
2014-12-28 22:55:14 +03:00
<h3 id="tile-definition">Tile definition</h3>
2014-12-28 22:26:49 +03:00
<ul>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#imagepng" name="imagepng">#</a><code>"image.png"</code></li>
<li><a class="anchor" href="#nameimagepnganimationTileAnimationdefinition" name="nameimagepnganimationTileAnimationdefinition">#</a><code>{name="image.png", animation={Tile Animation definition}}</code></li>
<li><a class="anchor" href="#nameimagepngbackface_cullingbooltileable_verticalbooltileable_horizontalbool" name="nameimagepngbackface_cullingbooltileable_verticalbooltileable_horizontalbool">#</a><code>{name="image.png", backface_culling=bool, tileable_vertical=bool,
2015-08-12 16:54:11 +03:00
tileable_horizontal=bool}</code><ul>
2016-03-19 17:25:33 +03:00
<li>backface culling enabled by default for most nodes</li>
2015-08-12 16:54:11 +03:00
<li>tileable flags are info for shaders, how they should treat texture
when displacement mapping is used
Directions are from the point of view of the tile texture,
not the node it's on</li>
2014-12-28 22:55:14 +03:00
</ul>
</li>
2017-01-31 17:21:12 +03:00
<li><a class="anchor" href="#nameimagepngcolorColorSpec" name="nameimagepngcolorColorSpec">#</a><code>{name="image.png", color=ColorSpec}</code><ul>
<li>the texture's color will be multiplied with this color.</li>
<li>the tile's color overrides the owning node's color in all cases.</li>
</ul>
</li>
2015-11-22 19:41:52 +03:00
<li><a class="anchor" href="#image_3" name="image_3">#</a>deprecated, yet still supported field names:<ul>
<li><a class="anchor" href="#image_4" name="image_4">#</a><code>image</code> (name)</li>
2014-12-28 22:26:49 +03:00
</ul>
2014-12-28 22:55:14 +03:00
</li>
</ul>
<h3 id="tile-animation-definition">Tile animation definition</h3>
2017-01-31 17:21:12 +03:00
<pre><code>{
type = "vertical_frames",
aspect_w = 16,
-- ^ specify width of a frame in pixels
aspect_h = 16,
-- ^ specify height of a frame in pixels
length = 3.0,
-- ^ specify full loop length
}
{
type = "sheet_2d",
frames_w = 5,
-- ^ specify width in number of frames
frames_h = 3,
-- ^ specify height in number of frames
frame_length = 0.5,
-- ^ specify length of a single frame
}
</code></pre>
2014-12-28 22:55:14 +03:00
<h3 id="node-definition-register_node">Node definition (<code>register_node</code>)</h3>
2014-12-28 22:26:49 +03:00
<pre><code>{
-- &lt;all fields allowed in item definitions&gt;,
drawtype = "normal", -- See "Node drawtypes"
visual_scale = 1.0, --[[
^ Supported for drawtypes "plantlike", "signlike", "torchlike", "mesh".
^ For plantlike, the image will start at the bottom of the node; for the
^ other drawtypes, the image will be centered on the node.
^ Note that positioning for "torchlike" may still change. ]]
tiles = {tile definition 1, def2, def3, def4, def5, def6}, --[[
^ Textures of node; +Y, -Y, +X, -X, +Z, -Z (old field name: tile_images)
^ List can be shortened to needed length ]]
special_tiles = {tile definition 1, Tile definition 2}, --[[
^ Special textures of node; used rarely (old field name: special_materials)
^ List can be shortened to needed length ]]
2017-01-31 17:21:12 +03:00
color = ColorSpec, --[[
^ The node's original color will be multiplied with this color.
^ If the node has a palette, then this setting only has an effect
^ in the inventory and on the wield item. ]]
2014-12-28 22:26:49 +03:00
use_texture_alpha = false, -- Use texture's alpha channel
2017-01-31 17:21:12 +03:00
palette = "palette.png", --[[
^ The node's `param2` is used to select a pixel from the image
^ (pixels are arranged from left to right and from top to bottom).
^ The node's color will be multiplied with the selected pixel's
^ color. Tiles can override this behavior.
^ Only when `paramtype2` supports palettes. ]]
2015-05-27 12:53:46 +03:00
post_effect_color = "green#0F", -- If player is inside node, see "ColorSpec"
2015-01-24 22:07:00 +03:00
paramtype = "none", -- See "Nodes" --[[
^ paramtype = "light" allows light to propagate from or through the node with light value
^ falling by 1 per node. This line is essential for a light source node to spread its light. ]]
2014-12-28 22:26:49 +03:00
paramtype2 = "none", -- See "Nodes"
2016-07-22 21:37:58 +03:00
place_param2 = nil, -- Force value for param2 when player places node
2014-12-28 22:26:49 +03:00
is_ground_content = true, -- If false, the cave generator will not carve through this
sunlight_propagates = false, -- If true, sunlight will go infinitely through this
walkable = true, -- If true, objects collide with node
pointable = true, -- If true, can be pointed at
diggable = true, -- If false, can never be dug
climbable = false, -- If true, can be climbed on (ladder)
buildable_to = false, -- If true, placed nodes can replace this node
2016-03-19 17:25:33 +03:00
floodable = false, -- If true, liquids flow into and replace this node
2014-12-28 22:26:49 +03:00
liquidtype = "none", -- "none"/"source"/"flowing"
liquid_alternative_flowing = "", -- Flowing version of source liquid
liquid_alternative_source = "", -- Source version of flowing liquid
liquid_viscosity = 0, -- Higher viscosity = slower flow (max. 7)
2016-07-22 21:37:58 +03:00
liquid_renewable = true, --[[
^ If true, a new liquid source can be created by placing two or more sources nearby ]]
2015-01-24 22:07:00 +03:00
leveled = 0, --[[
^ Block contains level in param2. Value is default level, used for snow.
^ Don't forget to use "leveled" type nodebox. ]]
2014-12-28 22:26:49 +03:00
liquid_range = 8, -- number of flowing nodes around source (max. 8)
drowning = 0, -- Player will take this amount of damage if no bubbles are left
2016-11-12 19:27:07 +03:00
light_source = 0, --[[
^ Amount of light emitted by node.
^ To set the maximum (currently 14), use the value 'minetest.LIGHT_MAX'.
^ A value outside the range 0 to minetest.LIGHT_MAX causes undefined behavior.]]
2014-12-28 22:26:49 +03:00
damage_per_second = 0, -- If player is inside node, this damage is caused
node_box = {type="regular"}, -- See "Node boxes"
2016-03-19 17:25:33 +03:00
connects_to = nodenames, --[[
* Used for nodebox nodes with the type == "connected"
* Specifies to what neighboring nodes connections will be drawn
* e.g. `{"group:fence", "default:wood"}` or `"default:stone"` ]]
connect_sides = { "top", "bottom", "front", "left", "back", "right" }, --[[
^ Tells connected nodebox nodes to connect only to these sides of this node. ]]
2014-12-28 22:26:49 +03:00
mesh = "model",
2015-01-24 22:07:00 +03:00
selection_box = {type="regular"}, -- See "Node boxes" --[[
^ If drawtype "nodebox" is used and selection_box is nil, then node_box is used. ]]
2014-12-28 22:26:49 +03:00
legacy_facedir_simple = false, -- Support maps made in and before January 2012
legacy_wallmounted = false, -- Support maps made in and before January 2012
sounds = {
footstep = &lt;SimpleSoundSpec&gt;,
dig = &lt;SimpleSoundSpec&gt;, -- "__group" = group-based sound (default)
dug = &lt;SimpleSoundSpec&gt;,
place = &lt;SimpleSoundSpec&gt;,
2015-11-21 18:26:52 +03:00
place_failed = &lt;SimpleSoundSpec&gt;,
2014-12-28 22:26:49 +03:00
},
drop = "", -- Name of dropped node when dug. Default is the node itself.
-- Alternatively:
drop = {
max_items = 1, -- Maximum number of items to drop.
items = { -- Choose max_items randomly from this list.
{
2016-07-22 21:37:58 +03:00
items = {"foo:bar", "baz:frob"}, -- Items to drop.
rarity = 1, -- Probability of dropping is 1 / rarity.
2014-12-28 22:26:49 +03:00
},
},
},
on_construct = func(pos), --[[
2015-10-26 03:16:41 +03:00
^ Node constructor; called after adding node
2014-12-28 22:26:49 +03:00
^ Can set up metadata and stuff like that
2015-10-26 03:16:41 +03:00
^ Not called for bulk node placement (i.e. schematics and VoxelManip)
2014-12-28 22:26:49 +03:00
^ default: nil ]]
on_destruct = func(pos), --[[
2015-10-26 03:16:41 +03:00
^ Node destructor; called before removing node
^ Not called for bulk node placement (i.e. schematics and VoxelManip)
2014-12-28 22:26:49 +03:00
^ default: nil ]]
after_destruct = func(pos, oldnode), --[[
2015-10-26 03:16:41 +03:00
^ Node destructor; called after removing node
^ Not called for bulk node placement (i.e. schematics and VoxelManip)
2014-12-28 22:26:49 +03:00
^ default: nil ]]
after_place_node = func(pos, placer, itemstack, pointed_thing) --[[
^ Called after constructing node when node was placed using
minetest.item_place_node / minetest.place_node
^ If return true no item is taken from itemstack
^ default: nil ]]
after_dig_node = func(pos, oldnode, oldmetadata, digger), --[[
^ oldmetadata is in table format
^ Called after destructing node when node was dug using
minetest.node_dig / minetest.dig_node
^ default: nil ]]
2015-04-29 20:17:32 +03:00
can_dig = function(pos, [player]) --[[
2014-12-28 22:26:49 +03:00
^ returns true if node can be dug, or false if not
^ default: nil ]]
on_punch = func(pos, node, puncher, pointed_thing), --[[
^ default: minetest.node_punch
^ By default: Calls minetest.register_on_punchnode callbacks ]]
on_rightclick = func(pos, node, clicker, itemstack, pointed_thing), --[[
^ default: nil
^ if defined, itemstack will hold clicker's wielded item
^ Shall return the leftover itemstack
^ Note: pointed_thing can be nil, if a mod calls this function ]]
on_dig = func(pos, node, digger), --[[
^ default: minetest.node_dig
^ By default: checks privileges, wears out tool and removes node ]]
on_timer = function(pos,elapsed), --[[
^ default: nil
^ called by NodeTimers, see minetest.get_node_timer and NodeTimerRef
^ elapsed is the total time passed since the timer was started
^ return true to run the timer for another cycle with the same timeout value ]]
on_receive_fields = func(pos, formname, fields, sender), --[[
^ fields = {name1 = value1, name2 = value2, ...}
^ Called when an UI form (e.g. sign text input) returns data
^ default: nil ]]
allow_metadata_inventory_move = func(pos, from_list, from_index,
to_list, to_index, count, player), --[[
^ Called when a player wants to move items inside the inventory
^ Return value: number of items allowed to move ]]
allow_metadata_inventory_put = func(pos, listname, index, stack, player), --[[
^ Called when a player wants to put something into the inventory
^ Return value: number of items allowed to put
^ Return value: -1: Allow and don't modify item count in inventory ]]
allow_metadata_inventory_take = func(pos, listname, index, stack, player), --[[
^ Called when a player wants to take something out of the inventory
^ Return value: number of items allowed to take
^ Return value: -1: Allow and don't modify item count in inventory ]]
on_metadata_inventory_move = func(pos, from_list, from_index,
to_list, to_index, count, player),
on_metadata_inventory_put = func(pos, listname, index, stack, player),
on_metadata_inventory_take = func(pos, listname, index, stack, player), --[[
^ Called after the actual action has happened, according to what was allowed.
^ No return value ]]
on_blast = func(pos, intensity), --[[
^ intensity: 1.0 = mid range of regular TNT
^ If defined, called when an explosion touches the node, instead of
removing the node ]]
}
</code></pre>
2014-12-28 22:55:14 +03:00
<h3 id="recipe-for-register_craft-shaped">Recipe for <code>register_craft</code> (shaped)</h3>
2014-12-28 22:26:49 +03:00
<pre><code>{
output = 'default:pick_stone',
recipe = {
{'default:cobble', 'default:cobble', 'default:cobble'},
{'', 'default:stick', ''},
{'', 'default:stick', ''}, -- Also groups; e.g. 'group:crumbly'
},
replacements = --[[&lt;optional list of item pairs,
replace one input item with another item on crafting&gt;]]
}
</code></pre>
2014-12-28 22:55:14 +03:00
<h3 id="recipe-for-register_craft-shapeless">Recipe for <code>register_craft</code> (shapeless)</h3>
2014-12-28 22:26:49 +03:00
<pre><code>{
type = "shapeless",
output = 'mushrooms:mushroom_stew',
recipe = {
"mushrooms:bowl",
"mushrooms:mushroom_brown",
"mushrooms:mushroom_red",
},
replacements = --[[&lt;optional list of item pairs,
replace one input item with another item on crafting&gt;]]
</code></pre>
<p>}</p>
2014-12-28 22:55:14 +03:00
<h3 id="recipe-for-register_craft-tool-repair">Recipe for <code>register_craft</code> (tool repair)</h3>
2014-12-28 22:26:49 +03:00
<pre><code>{
type = "toolrepair",
additional_wear = -0.02,
}
</code></pre>
2014-12-28 22:55:14 +03:00
<h3 id="recipe-for-register_craft-cooking">Recipe for <code>register_craft</code> (cooking)</h3>
2014-12-28 22:26:49 +03:00
<pre><code>{
type = "cooking",
output = "default:glass",
recipe = "default:sand",
cooktime = 3,
}
</code></pre>
2014-12-28 22:55:14 +03:00
<h3 id="recipe-for-register_craft-furnace-fuel">Recipe for <code>register_craft</code> (furnace fuel)</h3>
2014-12-28 22:26:49 +03:00
<pre><code>{
type = "fuel",
recipe = "default:leaves",
burntime = 1,
}
</code></pre>
2014-12-28 22:55:14 +03:00
<h3 id="ore-definition-register_ore">Ore definition (<code>register_ore</code>)</h3>
2014-12-28 22:26:49 +03:00
<pre><code>{
ore_type = "scatter", -- See "Ore types"
ore = "default:stone_with_coal",
wherein = "default:stone",
-- ^ a list of nodenames is supported too
clust_scarcity = 8*8*8,
-- ^ Ore has a 1 out of clust_scarcity chance of spawning in a node
-- ^ This value should be *MUCH* higher than your intuition might tell you!
clust_num_ores = 8,
-- ^ Number of ores in a cluster
clust_size = 3,
-- ^ Size of the bounding box of the cluster
-- ^ In this example, there is a 3x3x3 cluster where 8 out of the 27 nodes are coal ore
y_min = -31000,
y_max = 64,
2014-12-28 22:26:49 +03:00
flags = "",
-- ^ Attributes for this ore generation
2015-12-07 21:04:11 +03:00
noise_threshold = 0.5,
2014-12-28 22:26:49 +03:00
-- ^ If noise is above this threshold, ore is placed. Not needed for a uniform distribution
noise_params = {offset=0, scale=1, spread={x=100, y=100, z=100}, seed=23, octaves=3, persist=0.70}
-- ^ NoiseParams structure describing the perlin noise used for ore distribution.
-- ^ Needed for sheet ore_type. Omit from scatter ore_type for a uniform ore distribution
random_factor = 1.0,
-- ^ Multiplier of the randomness contribution to the noise value at any
-- given point to decide if ore should be placed. Set to 0 for solid veins.
-- ^ This parameter is only valid for ore_type == "vein".
2015-04-29 20:17:32 +03:00
biomes = {"desert", "rainforest"}
-- ^ List of biomes in which this decoration occurs. Occurs in all biomes if this is omitted,
-- ^ and ignored if the Mapgen being used does not support biomes.
-- ^ Can be a list of (or a single) biome names, IDs, or definitions.
2014-12-28 22:26:49 +03:00
}
</code></pre>
2015-12-07 21:04:11 +03:00
<h3 id="biome-definition-register_biome">Biome definition (<code>register_biome</code>)</h3>
2016-07-22 21:37:58 +03:00
<p><strong>Note</strong>
The Biome API is still in an experimental phase and subject to change.</p>
2015-12-07 21:04:11 +03:00
<pre><code>{
name = "tundra",
node_dust = "default:snow",
-- ^ Node dropped onto upper surface after all else is generated.
node_top = "default:dirt_with_snow",
depth_top = 1,
-- ^ Node forming surface layer of biome and thickness of this layer.
node_filler = "default:permafrost",
depth_filler = 3,
-- ^ Node forming lower layer of biome and thickness of this layer.
node_stone = "default:bluestone",
-- ^ Node that replaces all stone nodes between roughly y_min and y_max.
node_water_top = "default:ice",
depth_water_top = 10,
-- ^ Node forming a surface layer in seawater with the defined thickness.
node_water = "",
-- ^ Node that replaces all seawater nodes not in the defined surface layer.
node_river_water = "default:ice",
-- ^ Node that replaces river water in mapgens that use default:river_water.
2016-07-22 21:37:58 +03:00
node_riverbed = "default:gravel",
depth_riverbed = 2,
-- ^ Node placed under river water and thickness of this layer.
2015-12-07 21:04:11 +03:00
y_min = 1,
y_max = 31000,
-- ^ Lower and upper limits for biome.
-- ^ Because biome is not recalculated for every node in a node column
-- ^ some biome materials can exceed their limits, especially stone.
-- ^ For each node column in a mapchunk, biome is only recalculated at column
-- ^ top and at each of these surfaces:
-- ^ Ground below air, water below air, ground below water.
-- ^ The selected biome then stays in effect for all nodes below until
-- ^ column base or the next biome recalculation.
heat_point = 0,
humidity_point = 50,
-- ^ Characteristic average temperature and humidity for the biome.
-- ^ These values create 'biome points' on a voronoi diagram that has heat
-- ^ and humidity as axes. The resulting voronoi cells determine which
-- ^ heat/humidity points belong to which biome, and therefore determine
-- ^ the area and location of each biome in the world.
-- ^ The biome points need to be carefully and evenly spaced on the voronoi
-- ^ diagram to result in roughly equal size biomes.
-- ^ Heat and humidity have average values of 50, vary mostly between
-- ^ 0 and 100 but also often exceed these values.
-- ^ Heat is not in degrees celcius, both values are abstract.
}
</code></pre>
2014-12-28 22:55:14 +03:00
<h3 id="decoration-definition-register_decoration">Decoration definition (<code>register_decoration</code>)</h3>
2014-12-28 22:26:49 +03:00
<pre><code>{
deco_type = "simple", -- See "Decoration types"
place_on = "default:dirt_with_grass",
2016-11-12 19:27:07 +03:00
-- ^ Node (or list of nodes) that the decoration can be placed on
2014-12-28 22:26:49 +03:00
sidelen = 8,
-- ^ Size of divisions made in the chunk being generated.
-- ^ If the chunk size is not evenly divisible by sidelen, sidelen is made equal to the chunk size.
fill_ratio = 0.02,
-- ^ Ratio of the area to be uniformly filled by the decoration.
-- ^ Used only if noise_params is not specified.
noise_params = {offset=0, scale=.45, spread={x=100, y=100, z=100}, seed=354, octaves=3, persist=0.7},
-- ^ NoiseParams structure describing the perlin noise used for decoration distribution.
-- ^ The result of this is multiplied by the 2d area of the division being decorated.
biomes = {"Oceanside", "Hills", "Plains"},
-- ^ List of biomes in which this decoration occurs. Occurs in all biomes if this is omitted,
-- ^ and ignored if the Mapgen being used does not support biomes.
2015-04-29 20:17:32 +03:00
-- ^ Can be a list of (or a single) biome names, IDs, or definitions.
y_min = -31000
y_max = 31000
-- ^ Minimum and maximum `y` positions these decorations can be generated at.
-- ^ This parameter refers to the `y` position of the decoration base, so
-- the actual maximum height would be `height_max + size.Y`.
2016-11-12 19:27:07 +03:00
spawn_by = "default:water",
-- ^ Node (or list of nodes) that the decoration only spawns next to.
-- ^ Checks two horizontal planes of neighbouring nodes (including diagonal neighbours),
-- ^ one plane at Y = surface and one plane at Y = surface = + 1.
num_spawn_by = 1,
-- ^ Number of spawn_by nodes that must be surrounding the decoration position to occur.
-- ^ If absent or -1, decorations occur next to any nodes.
2016-03-19 17:25:33 +03:00
flags = "liquid_surface, force_placement",
2015-10-26 03:16:41 +03:00
-- ^ Flags for all decoration types.
-- ^ "liquid_surface": Instead of placement on the highest solid surface
-- ^ in a mapchunk column, placement is on the highest liquid surface.
-- ^ Placement is disabled if solid nodes are found above the liquid surface.
2016-03-19 17:25:33 +03:00
-- ^ "force_placement": Nodes other than "air" and "ignore" are replaced by the decoration.
2014-12-28 22:26:49 +03:00
----- Simple-type parameters
decoration = "default:grass",
-- ^ The node name used as the decoration.
-- ^ If instead a list of strings, a randomly selected node from the list is placed as the decoration.
height = 1,
-- ^ Number of nodes high the decoration is made.
2014-12-28 22:26:49 +03:00
-- ^ If height_max is not 0, this is the lower bound of the randomly selected height.
height_max = 0,
2016-12-29 00:57:48 +03:00
-- ^ Number of nodes the decoration can be at maximum.
2014-12-28 22:26:49 +03:00
-- ^ If absent, the parameter 'height' is used as a constant.
2016-12-29 00:57:48 +03:00
param2 = 0,
-- ^ Param2 value of placed decoration node.
2014-12-28 22:26:49 +03:00
----- Schematic-type parameters
schematic = "foobar.mts",
-- ^ If schematic is a string, it is the filepath relative to the current working directory of the
-- ^ specified Minetest schematic file.
2015-04-29 20:17:32 +03:00
-- ^ - OR -, could be the ID of a previously registered schematic
2014-12-28 22:26:49 +03:00
-- ^ - OR -, could instead be a table containing two mandatory fields, size and data,
-- ^ and an optional table yslice_prob:
schematic = {
size = {x=4, y=6, z=4},
data = {
2015-03-17 21:18:48 +03:00
{name="default:cobble", param1=255, param2=0},
{name="default:dirt_with_grass", param1=255, param2=0},
{name="ignore", param1=255, param2=0},
{name="air", param1=255, param2=0},
2014-12-28 22:26:49 +03:00
...
},
yslice_prob = {
{ypos=2, prob=128},
{ypos=5, prob=64},
...
},
},
-- ^ See 'Schematic specifier' for details.
replacements = {["oldname"] = "convert_to", ...},
2016-03-19 17:25:33 +03:00
flags = "place_center_x, place_center_y, place_center_z",
2014-12-28 22:26:49 +03:00
-- ^ Flags for schematic decorations. See 'Schematic attributes'.
rotation = "90" -- rotate schematic 90 degrees on placement
-- ^ Rotation can be "0", "90", "180", "270", or "random".
}
</code></pre>
2014-12-28 22:55:14 +03:00
<h3 id="chat-command-definition-register_chatcommand">Chat command definition (<code>register_chatcommand</code>)</h3>
2014-12-28 22:26:49 +03:00
<pre><code>{
params = "&lt;name&gt; &lt;privilege&gt;", -- Short parameter description
description = "Remove privilege from player", -- Full description
privs = {privs=true}, -- Require the "privs" privilege to run
func = function(name, param), -- Called when command is run.
-- Returns boolean success and text output.
}
</code></pre>
2014-12-28 22:55:14 +03:00
<h3 id="detached-inventory-callbacks">Detached inventory callbacks</h3>
2014-12-28 22:26:49 +03:00
<pre><code>{
allow_move = func(inv, from_list, from_index, to_list, to_index, count, player),
-- ^ Called when a player wants to move items inside the inventory
-- ^ Return value: number of items allowed to move
allow_put = func(inv, listname, index, stack, player),
-- ^ Called when a player wants to put something into the inventory
-- ^ Return value: number of items allowed to put
-- ^ Return value: -1: Allow and don't modify item count in inventory
allow_take = func(inv, listname, index, stack, player),
-- ^ Called when a player wants to take something out of the inventory
-- ^ Return value: number of items allowed to take
-- ^ Return value: -1: Allow and don't modify item count in inventory
on_move = func(inv, from_list, from_index, to_list, to_index, count, player),
on_put = func(inv, listname, index, stack, player),
on_take = func(inv, listname, index, stack, player),
-- ^ Called after the actual action has happened, according to what was allowed.
-- ^ No return value
}
</code></pre>
2014-12-28 22:55:14 +03:00
<h3 id="hud-definition-hud_add-hud_get">HUD Definition (<code>hud_add</code>, <code>hud_get</code>)</h3>
2014-12-28 22:26:49 +03:00
<pre><code>{
hud_elem_type = "image", -- see HUD element types
-- ^ type of HUD element, can be either of "image", "text", "statbar", or "inventory"
position = {x=0.5, y=0.5},
-- ^ Left corner position of element
name = "&lt;name&gt;",
scale = {x=2, y=2},
text = "&lt;text&gt;",
number = 2,
item = 3,
-- ^ Selected item in inventory. 0 for no item selected.
direction = 0,
-- ^ Direction: 0: left-right, 1: right-left, 2: top-bottom, 3: bottom-top
alignment = {x=0, y=0},
-- ^ See "HUD Element Types"
offset = {x=0, y=0},
-- ^ See "HUD Element Types"
size = { x=100, y=100 },
-- ^ Size of element in pixels
}
</code></pre>
2014-12-28 22:55:14 +03:00
<h3 id="particle-definition-add_particle">Particle definition (<code>add_particle</code>)</h3>
2014-12-28 22:26:49 +03:00
<pre><code>{
pos = {x=0, y=0, z=0},
velocity = {x=0, y=0, z=0},
acceleration = {x=0, y=0, z=0},
-- ^ Spawn particle at pos with velocity and acceleration
expirationtime = 1,
-- ^ Disappears after expirationtime seconds
size = 1,
collisiondetection = false,
-- ^ collisiondetection: if true collides with physical objects
2016-07-22 21:37:58 +03:00
collision_removal = false,
-- ^ collision_removal: if true then particle is removed when it collides,
-- ^ requires collisiondetection = true to have any effect
2014-12-28 22:26:49 +03:00
vertical = false,
-- ^ vertical: if true faces player using y axis only
texture = "image.png",
-- ^ Uses texture (string)
2017-01-31 17:21:12 +03:00
playername = "singleplayer",
2014-12-28 22:26:49 +03:00
-- ^ optional, if specified spawns particle only on the player's client
2017-01-31 17:21:12 +03:00
animation = {Tile Animation definition},
-- ^ optional, specifies how to animate the particle texture
glow = 0
-- ^ optional, specify particle self-luminescence in darkness
2014-12-28 22:26:49 +03:00
}
</code></pre>
2014-12-28 22:55:14 +03:00
<h3 id="particlespawner-definition-add_particlespawner"><code>ParticleSpawner</code> definition (<code>add_particlespawner</code>)</h3>
2014-12-28 22:26:49 +03:00
<pre><code>{
amount = 1,
time = 1,
-- ^ If time is 0 has infinite lifespan and spawns the amount on a per-second base
minpos = {x=0, y=0, z=0},
maxpos = {x=0, y=0, z=0},
minvel = {x=0, y=0, z=0},
maxvel = {x=0, y=0, z=0},
minacc = {x=0, y=0, z=0},
maxacc = {x=0, y=0, z=0},
minexptime = 1,
maxexptime = 1,
minsize = 1,
maxsize = 1,
-- ^ The particle's properties are random values in between the bounds:
-- ^ minpos/maxpos, minvel/maxvel (velocity), minacc/maxacc (acceleration),
-- ^ minsize/maxsize, minexptime/maxexptime (expirationtime)
collisiondetection = false,
-- ^ collisiondetection: if true uses collision detection
2016-07-22 21:37:58 +03:00
collision_removal = false,
-- ^ collision_removal: if true then particle is removed when it collides,
-- ^ requires collisiondetection = true to have any effect
2016-11-12 19:27:07 +03:00
attached = ObjectRef,
2016-12-29 00:57:48 +03:00
-- ^ attached: if defined, particle positions, velocities and accelerations
-- ^ are relative to this object's position and yaw.
2014-12-28 22:26:49 +03:00
vertical = false,
-- ^ vertical: if true faces player using y axis only
texture = "image.png",
-- ^ Uses texture (string)
playername = "singleplayer"
-- ^ Playername is optional, if specified spawns particle only on the player's client
}
2016-03-19 17:25:33 +03:00
</code></pre>
2016-07-22 21:37:58 +03:00
<h3 id="httprequest-definition-httpapitablefetch_async-httpapitablefetch_async"><code>HTTPRequest</code> definition (<code>HTTPApiTable.fetch_async</code>, <code>HTTPApiTable.fetch_async</code>)</h3>
2016-03-19 17:25:33 +03:00
<pre><code>{
url = "http://example.org",
timeout = 10,
-- ^ Timeout for connection in seconds. Default is 3 seconds.
post_data = "Raw POST request data string" OR { field1 = "data1", field2 = "data2" },
-- ^ Optional, if specified a POST request with post_data is performed.
-- ^ Accepts both a string and a table. If a table is specified, encodes table
-- ^ as x-www-form-urlencoded key-value pairs.
-- ^ If post_data ist not specified, a GET request is performed instead.
user_agent = "ExampleUserAgent",
-- ^ Optional, if specified replaces the default minetest user agent with given string
extra_headers = { "Accept-Language: en-us", "Accept-Charset: utf-8" },
-- ^ Optional, if specified adds additional headers to the HTTP request. You must make sure
-- ^ that the header strings follow HTTP specification ("Key: Value").
multipart = boolean
-- ^ Optional, if true performs a multipart HTTP request. Default is false.
}
</code></pre>
2016-07-22 21:37:58 +03:00
<h3 id="httprequestresult-definition-httpapitablefetch-callback-httpapitablefetch_async_get"><code>HTTPRequestResult</code> definition (<code>HTTPApiTable.fetch</code> callback, <code>HTTPApiTable.fetch_async_get</code>)</h3>
2016-03-19 17:25:33 +03:00
<pre><code>{
completed = true,
-- ^ If true, the request has finished (either succeeded, failed or timed out)
succeeded = true,
-- ^ If true, the request was succesful
timeout = false,
-- ^ If true, the request timed out
code = 200,
-- ^ HTTP status code
data = "response"
}
</code></pre>