lua_api.html 109 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576
  1. <!DOCTYPE html>
  2. <html class="writer-html5" lang="en" >
  3. <head>
  4. <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
  5. <meta property="article:modified_time" content="2026-01-19T11:32:05+00:00" /><meta property="og:title" content="Lua API reference" />
  6. <meta property="og:type" content="website" />
  7. <meta property="og:url" content="https://docs.crownengine.org/html/latest/lua_api.html" />
  8. <meta property="og:site_name" content="Crown 0.60.0 Manual" />
  9. <meta property="og:description" content="AnimationStateMachine: create(asm, unit, state_machine_resource), Id, Creates a new state machine instance for unit and returns its id.,, destroy(asm, state_machine), Destroys the state_machine instance.,, instance(asm, unit), Id, Returns the ID of the state machine owned by t..." />
  10. <meta name="description" content="AnimationStateMachine: create(asm, unit, state_machine_resource), Id, Creates a new state machine instance for unit and returns its id.,, destroy(asm, state_machine), Destroys the state_machine instance.,, instance(asm, unit), Id, Returns the ID of the state machine owned by t..." />
  11. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  12. <title>Lua API reference &mdash; Crown 0.60.0 Manual 0.61.0 documentation</title>
  13. <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
  14. <link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
  15. <link rel="stylesheet" href="_static/css/custom.css" type="text/css" />
  16. <link rel="shortcut icon" href="_static/org.crownengine.Crown.svg"/>
  17. <link rel="canonical" href="https://docs.crownengine.org/html/latest/lua_api.html" />
  18. <!--[if lt IE 9]>
  19. <script src="_static/js/html5shiv.min.js"></script>
  20. <![endif]-->
  21. <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
  22. <script src="_static/jquery.js"></script>
  23. <script src="_static/underscore.js"></script>
  24. <script src="_static/doctools.js"></script>
  25. <script src="_static/js/theme.js"></script>
  26. <link rel="index" title="Index" href="genindex.html" />
  27. <link rel="search" title="Search" href="search.html" />
  28. <link rel="copyright" title="Copyright" href="copyright.html" />
  29. <link rel="next" title="Glossary" href="glossary.html" />
  30. <link rel="prev" title="Command line" href="reference/command_line.html" />
  31. </head>
  32. <body class="wy-body-for-nav">
  33. <div class="wy-grid-for-nav">
  34. <nav data-toggle="wy-nav-shift" class="wy-nav-side">
  35. <div class="wy-side-scroll">
  36. <div class="wy-side-nav-search" >
  37. <a href="index.html">
  38. <img src="_static/org.crownengine.Crown.svg" class="logo" alt="Logo"/>
  39. </a>
  40. <div class="version">
  41. Crown 0.60.0 Manual
  42. </div>
  43. <div role="search">
  44. <form id="rtd-search-form" class="wy-form" action="search.html" method="get">
  45. <input type="text" name="q" placeholder="Search docs" />
  46. <input type="hidden" name="check_keywords" value="yes" />
  47. <input type="hidden" name="area" value="default" />
  48. </form>
  49. </div>
  50. </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
  51. <ul class="current">
  52. <li class="toctree-l1"><a class="reference internal" href="changelog.html">Changelog</a></li>
  53. <li class="toctree-l1"><a class="reference internal" href="introduction.html">Introduction</a></li>
  54. <li class="toctree-l1"><a class="reference internal" href="installing_crown/index.html">Installing Crown</a></li>
  55. <li class="toctree-l1"><a class="reference internal" href="getting_started/index.html">Getting Started</a></li>
  56. <li class="toctree-l1"><a class="reference internal" href="importing_resources/index.html">Importing Resources</a></li>
  57. <li class="toctree-l1"><a class="reference internal" href="gameplay/index.html">Writing Gameplay</a></li>
  58. <li class="toctree-l1"><a class="reference internal" href="deploying/index.html">Deploying</a></li>
  59. <li class="toctree-l1"><a class="reference internal" href="reference/index.html">Reference</a></li>
  60. <li class="toctree-l1 current"><a class="current reference internal" href="#">Lua API reference</a><ul>
  61. <li class="toctree-l2"><a class="reference internal" href="#animationstatemachine">AnimationStateMachine</a></li>
  62. <li class="toctree-l2"><a class="reference internal" href="#debugline">DebugLine</a></li>
  63. <li class="toctree-l2"><a class="reference internal" href="#device">Device</a></li>
  64. <li class="toctree-l2"><a class="reference internal" href="#display">Display</a><ul>
  65. <li class="toctree-l3"><a class="reference internal" href="#displaymode">DisplayMode</a></li>
  66. </ul>
  67. </li>
  68. <li class="toctree-l2"><a class="reference internal" href="#gui">Gui</a></li>
  69. <li class="toctree-l2"><a class="reference internal" href="#input">Input</a><ul>
  70. <li class="toctree-l3"><a class="reference internal" href="#inputevent">InputEvent</a></li>
  71. <li class="toctree-l3"><a class="reference internal" href="#inputeventtype">InputEventType</a></li>
  72. <li class="toctree-l3"><a class="reference internal" href="#keyboard">Keyboard</a><ul>
  73. <li class="toctree-l4"><a class="reference internal" href="#keyboard-button-names">Keyboard Button Names</a></li>
  74. <li class="toctree-l4"><a class="reference internal" href="#keyboard-axis-names">Keyboard Axis Names</a></li>
  75. </ul>
  76. </li>
  77. <li class="toctree-l3"><a class="reference internal" href="#mouse">Mouse</a><ul>
  78. <li class="toctree-l4"><a class="reference internal" href="#mouse-button-names">Mouse Button Names</a></li>
  79. <li class="toctree-l4"><a class="reference internal" href="#mouse-axis-names">Mouse Axis Names</a></li>
  80. </ul>
  81. </li>
  82. <li class="toctree-l3"><a class="reference internal" href="#touch">Touch</a></li>
  83. <li class="toctree-l3"><a class="reference internal" href="#pad1-pad2-pad3-pad4">Pad1, Pad2, Pad3, Pad4</a><ul>
  84. <li class="toctree-l4"><a class="reference internal" href="#pad-button-names">Pad Button Names</a></li>
  85. <li class="toctree-l4"><a class="reference internal" href="#pad-axis-names">Pad Axis Names</a></li>
  86. </ul>
  87. </li>
  88. </ul>
  89. </li>
  90. <li class="toctree-l2"><a class="reference internal" href="#material">Material</a></li>
  91. <li class="toctree-l2"><a class="reference internal" href="#math">Math</a><ul>
  92. <li class="toctree-l3"><a class="reference internal" href="#vector3">Vector3</a><ul>
  93. <li class="toctree-l4"><a class="reference internal" href="#constructors">Constructors</a></li>
  94. <li class="toctree-l4"><a class="reference internal" href="#functions">Functions</a></li>
  95. </ul>
  96. </li>
  97. <li class="toctree-l3"><a class="reference internal" href="#vector3box">Vector3Box</a><ul>
  98. <li class="toctree-l4"><a class="reference internal" href="#id1">Constructors</a></li>
  99. <li class="toctree-l4"><a class="reference internal" href="#id2">Functions</a></li>
  100. </ul>
  101. </li>
  102. <li class="toctree-l3"><a class="reference internal" href="#quaternion">Quaternion</a><ul>
  103. <li class="toctree-l4"><a class="reference internal" href="#id3">Constructors</a></li>
  104. <li class="toctree-l4"><a class="reference internal" href="#id4">Functions</a></li>
  105. </ul>
  106. </li>
  107. <li class="toctree-l3"><a class="reference internal" href="#quaternionbox">QuaternionBox</a><ul>
  108. <li class="toctree-l4"><a class="reference internal" href="#id5">Constructors</a></li>
  109. <li class="toctree-l4"><a class="reference internal" href="#id6">Functions</a></li>
  110. </ul>
  111. </li>
  112. <li class="toctree-l3"><a class="reference internal" href="#matrix4x4">Matrix4x4</a><ul>
  113. <li class="toctree-l4"><a class="reference internal" href="#id7">Constructors</a></li>
  114. <li class="toctree-l4"><a class="reference internal" href="#id8">Functions</a></li>
  115. </ul>
  116. </li>
  117. <li class="toctree-l3"><a class="reference internal" href="#matrix4x4box">Matrix4x4Box</a><ul>
  118. <li class="toctree-l4"><a class="reference internal" href="#id9">Constructors</a></li>
  119. <li class="toctree-l4"><a class="reference internal" href="#id10">Functions</a></li>
  120. </ul>
  121. </li>
  122. <li class="toctree-l3"><a class="reference internal" href="#color4">Color4</a><ul>
  123. <li class="toctree-l4"><a class="reference internal" href="#id11">Constructors</a></li>
  124. <li class="toctree-l4"><a class="reference internal" href="#id12">Functions</a></li>
  125. </ul>
  126. </li>
  127. <li class="toctree-l3"><a class="reference internal" href="#id13">Math</a></li>
  128. </ul>
  129. </li>
  130. <li class="toctree-l2"><a class="reference internal" href="#physicsworld">PhysicsWorld</a><ul>
  131. <li class="toctree-l3"><a class="reference internal" href="#raycasthit">RaycastHit</a></li>
  132. <li class="toctree-l3"><a class="reference internal" href="#actor">Actor</a></li>
  133. <li class="toctree-l3"><a class="reference internal" href="#mover">Mover</a></li>
  134. </ul>
  135. </li>
  136. <li class="toctree-l2"><a class="reference internal" href="#profiler">Profiler</a></li>
  137. <li class="toctree-l2"><a class="reference internal" href="#renderworld">RenderWorld</a><ul>
  138. <li class="toctree-l3"><a class="reference internal" href="#mesh">Mesh</a></li>
  139. <li class="toctree-l3"><a class="reference internal" href="#sprite">Sprite</a></li>
  140. <li class="toctree-l3"><a class="reference internal" href="#light">Light</a></li>
  141. <li class="toctree-l3"><a class="reference internal" href="#fog">Fog</a></li>
  142. </ul>
  143. </li>
  144. <li class="toctree-l2"><a class="reference internal" href="#resourcepackage">ResourcePackage</a></li>
  145. <li class="toctree-l2"><a class="reference internal" href="#scenegraph">SceneGraph</a></li>
  146. <li class="toctree-l2"><a class="reference internal" href="#soundworld">SoundWorld</a></li>
  147. <li class="toctree-l2"><a class="reference internal" href="#unitmanager">UnitManager</a></li>
  148. <li class="toctree-l2"><a class="reference internal" href="#window">Window</a></li>
  149. <li class="toctree-l2"><a class="reference internal" href="#world">World</a><ul>
  150. <li class="toctree-l3"><a class="reference internal" href="#camera">Camera</a></li>
  151. <li class="toctree-l3"><a class="reference internal" href="#sound">Sound</a></li>
  152. <li class="toctree-l3"><a class="reference internal" href="#level">Level</a></li>
  153. </ul>
  154. </li>
  155. </ul>
  156. </li>
  157. <li class="toctree-l1"><a class="reference internal" href="glossary.html">Glossary</a></li>
  158. <li class="toctree-l1"><a class="reference internal" href="copyright.html">License</a></li>
  159. <li class="toctree-l1"><a class="reference internal" href="hackers/index.html">Hackers</a></li>
  160. </ul>
  161. </div>
  162. </div>
  163. </nav>
  164. <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
  165. <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
  166. <a href="index.html">Crown 0.60.0 Manual</a>
  167. </nav>
  168. <div class="wy-nav-content">
  169. <div class="rst-content">
  170. <div role="navigation" aria-label="Page navigation">
  171. <ul class="wy-breadcrumbs">
  172. <li><a href="index.html" class="icon icon-home"></a> &raquo;</li>
  173. <li>Lua API reference</li>
  174. <li class="wy-breadcrumbs-aside">
  175. <a href="_sources/lua_api.rst.txt" rel="nofollow"> View page source</a>
  176. </li>
  177. </ul>
  178. <hr/>
  179. </div>
  180. <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
  181. <div itemprop="articleBody">
  182. <section id="lua-api-reference">
  183. <h1>Lua API reference<a class="headerlink" href="#lua-api-reference" title="Permalink to this headline">¶</a></h1>
  184. <section id="animationstatemachine">
  185. <h2>AnimationStateMachine<a class="headerlink" href="#animationstatemachine" title="Permalink to this headline">¶</a></h2>
  186. <dl class="simple">
  187. <dt><strong>create</strong> (asm, unit, state_machine_resource)<span class="classifier">Id</span></dt><dd><p>Creates a new state machine instance for <em>unit</em> and returns its id.</p>
  188. </dd>
  189. <dt><strong>destroy</strong> (asm, state_machine)</dt><dd><p>Destroys the <em>state_machine</em> instance.</p>
  190. </dd>
  191. <dt><strong>instance</strong> (asm, unit)<span class="classifier">Id</span></dt><dd><p>Returns the ID of the state machine owned by the <em>unit</em>, or <code class="docutils literal notranslate"><span class="pre">nil</span></code>.</p>
  192. </dd>
  193. <dt><strong>variable_id</strong> (asm, state_machine, name)<span class="classifier">Id</span></dt><dd><p>Returns the ID of the variable <em>name</em> in the <em>state_machine</em>, or <code class="docutils literal notranslate"><span class="pre">nil</span></code> if
  194. the variable does not exist.</p>
  195. </dd>
  196. <dt><strong>variable</strong> (asm, state_machine, variable_id)<span class="classifier">number</span></dt><dd><p>Returns the value of the <em>variable_id</em> in the <em>state_machine</em>.</p>
  197. </dd>
  198. <dt><strong>set_variable</strong> (asm, state_machine, variable_id, value)</dt><dd><p>Sets the <em>value</em> of the <em>variable_id</em> in the <em>state_machine</em>.</p>
  199. </dd>
  200. <dt><strong>trigger</strong> (asm, state_machine, event)</dt><dd><p>Triggers the <em>event</em> in the <em>state_machine</em>.</p>
  201. </dd>
  202. <dt><strong>set_state_machine</strong> (asm, state_machine, state_machine_resource)</dt><dd><p>Sets the <em>state_machine_resource</em> of <em>state_machine</em>.</p>
  203. </dd>
  204. </dl>
  205. </section>
  206. <section id="debugline">
  207. <h2>DebugLine<a class="headerlink" href="#debugline" title="Permalink to this headline">¶</a></h2>
  208. <dl class="simple">
  209. <dt><strong>add_line</strong> (debug_line, start, end, color)</dt><dd><p>Adds a line from <em>start</em> to <em>end</em> with the given <em>color</em>.</p>
  210. </dd>
  211. <dt><strong>add_axes</strong> (debug_line, tm, length)</dt><dd><p>Adds lines for each axis with the given <em>length</em>.</p>
  212. </dd>
  213. <dt><strong>add_arc</strong> (debug_line, center, radius, plane_normal, midpoint_normal, color, [circle_segments = 36]);</dt><dd><p>Adds an arc at <em>center</em> with the given <em>radius</em> and <em>plane_normal</em> and <em>midpoint_normal</em> vectors.</p>
  214. </dd>
  215. <dt><strong>add_circle</strong> (debug_line, center, radius, normal, color, [segments = 36])</dt><dd><p>Adds a circle at <em>center</em> with the given <em>radius</em> and <em>normal</em> vector.</p>
  216. </dd>
  217. <dt><strong>add_cone</strong> (debug_line, from, to, radius, color, [segments = 36, rays = 36])</dt><dd><p>Adds a cone with the base centered at <em>from</em> and the tip at <em>to</em>.</p>
  218. </dd>
  219. <dt><strong>add_sphere</strong> (debug_line, center, radius, color, [segments = 36])</dt><dd><p>Adds a sphere at <em>center</em> with the given <em>radius</em>.</p>
  220. </dd>
  221. <dt><strong>add_obb</strong> (debug_line, tm, half_extents, color)</dt><dd><p>Adds an orientd bounding box. <em>tm</em> describes the position and orientation of
  222. the box. <em>half_extents</em> describes the size of the box along the axis.</p>
  223. </dd>
  224. <dt><strong>add_frustum</strong> (debug_line, mvp, color)</dt><dd><p>Adds a frustum defined by <em>mvp</em>.</p>
  225. </dd>
  226. <dt><strong>reset</strong> (debug_line)</dt><dd><p>Resets all the lines.</p>
  227. </dd>
  228. <dt><strong>submit</strong> (debug_line)</dt><dd><p>Submits the lines to renderer for drawing.</p>
  229. </dd>
  230. </dl>
  231. </section>
  232. <section id="device">
  233. <h2>Device<a class="headerlink" href="#device" title="Permalink to this headline">¶</a></h2>
  234. <dl>
  235. <dt><strong>argv</strong> ()<span class="classifier">table</span></dt><dd><p>Returns a table containing the command line parameters the engine was started with.</p>
  236. </dd>
  237. <dt><strong>platform</strong> ()<span class="classifier">string</span></dt><dd><p>Returns a string identifying what platform the engine is running on.
  238. It can be either <code class="docutils literal notranslate"><span class="pre">android</span></code>, <code class="docutils literal notranslate"><span class="pre">html5</span></code>, <code class="docutils literal notranslate"><span class="pre">linux</span></code> or <code class="docutils literal notranslate"><span class="pre">windows</span></code></p>
  239. </dd>
  240. <dt><strong>architecture</strong> ()<span class="classifier">string</span></dt><dd><p>Returns a string identifying what architecture the engine is running on.
  241. It can be either <code class="docutils literal notranslate"><span class="pre">32-bit</span></code> or <code class="docutils literal notranslate"><span class="pre">64-bit</span></code>.</p>
  242. </dd>
  243. <dt><strong>version</strong> ()<span class="classifier">string</span></dt><dd><p>Returns a string identifying the engine version.
  244. The form is “major.minor.micro”.</p>
  245. </dd>
  246. <dt><strong>build</strong> ()<span class="classifier">string</span></dt><dd><p>Returns a string identifying the engine build.
  247. It can be either <code class="docutils literal notranslate"><span class="pre">debug</span></code>, <code class="docutils literal notranslate"><span class="pre">development</span></code> or <code class="docutils literal notranslate"><span class="pre">release</span></code>.</p>
  248. </dd>
  249. <dt><strong>quit</strong> ([exit_code])</dt><dd><p>Quits the application. On platforms that support it, <em>exit_code</em> is
  250. returned to the system after the application exits.</p>
  251. </dd>
  252. <dt><strong>resolution</strong> ()<span class="classifier">float, float</span></dt><dd><p>Returns the main window resolution (width, height).</p>
  253. </dd>
  254. <dt><strong>create_world</strong> ()<span class="classifier">World</span></dt><dd><p>Creates a new world.</p>
  255. </dd>
  256. <dt><strong>destroy_world</strong> (world)</dt><dd><p>Destroys the given <em>world</em>.</p>
  257. </dd>
  258. <dt><strong>render</strong> (world, camera)</dt><dd><p>Renders <em>world</em> using <em>camera</em>.</p>
  259. </dd>
  260. <dt><strong>create_resource_package</strong> (name)<span class="classifier">ResourcePackage</span></dt><dd><p>Returns the resource package with the given <em>package_name</em> name.</p>
  261. </dd>
  262. <dt><strong>destroy_resource_package</strong> (package)</dt><dd><p>Destroy a previously created resource <em>package</em>.</p>
  263. <div class="admonition note">
  264. <p class="admonition-title">Note</p>
  265. <p>To unload the resources loaded by the package, you have to call
  266. ResourcePackage.unload() first.</p>
  267. </div>
  268. </dd>
  269. <dt><strong>screenshot</strong> (path)</dt><dd><p>Captures a screenshot of the main window’s backbuffer and saves it at <em>path</em> in PNG format.
  270. The global callback <code class="docutils literal notranslate"><span class="pre">screenshot</span> <span class="pre">(path)</span></code> will be called after the file is written to disk.</p>
  271. <div class="admonition note">
  272. <p class="admonition-title">Note</p>
  273. <p>Only available in debug and development builds.</p>
  274. </div>
  275. </dd>
  276. <dt><strong>console_send</strong> (table)</dt><dd><p>Sends the given lua <em>table</em> to clients connected to the engine.
  277. Values can be either <code class="docutils literal notranslate"><span class="pre">nil</span></code>, bool, number, string, table, array, Vector2, Vector3, Quaternion, Matrix4x4 or Color4.</p>
  278. </dd>
  279. <dt><strong>can_get</strong> (type, name)<span class="classifier">bool</span></dt><dd><p>Returns whether the resource (type, name) is loaded.
  280. When resource autoload is enabled it always returns true.</p>
  281. </dd>
  282. <dt><strong>enable_resource_autoload</strong> (enable)</dt><dd><p>Sets whether resources should be automatically loaded when accessed.</p>
  283. </dd>
  284. <dt><strong>temp_count</strong> ()<span class="classifier">int, int, int</span></dt><dd><p>Returns the number of temporary objects used by Lua.</p>
  285. </dd>
  286. <dt><strong>set_temp_count</strong> (nv, nq, nm)</dt><dd><p>Sets the number of temporary objects used by Lua.</p>
  287. </dd>
  288. <dt><strong>guid</strong> ()<span class="classifier">string</span></dt><dd><p>Returns a new GUID.</p>
  289. </dd>
  290. <dt><strong>set_timestep_policy</strong> (policy)</dt><dd><p>Sets the timestep policy:</p>
  291. <ul class="simple">
  292. <li><p><code class="docutils literal notranslate"><span class="pre">variable</span></code>: the timestep is the time it took for the previous frame to simulate. This is the default;</p></li>
  293. <li><p><code class="docutils literal notranslate"><span class="pre">smoothed</span></code>: the timestep is computed as an average of the previous delta times.</p></li>
  294. </ul>
  295. </dd>
  296. <dt><strong>set_timestep_smoothing</strong> (num_samples, num_outliers, average_cap)</dt><dd><p>Sets the number of samples to be averaged, the outliers to be excluded and the maximum
  297. allowed deviation in percent from the previous average. Given a delta time series DTs, and
  298. a previous average AVGp:</p>
  299. <ul class="simple">
  300. <li><p>DTs = [ .33; .30; .32; .33; .24; .33; .25; .35; .33; .42 ]</p></li>
  301. <li><p>AVGp = 0.33</p></li>
  302. </ul>
  303. <p>A call to set_smoothing(10, 2, 0.1) would compute the new average like so:</p>
  304. <ol class="arabic simple">
  305. <li><p>Remove the 2 minimum and maximum values in DTs;</p></li>
  306. <li><p>Compute the average for the remaining 6 values in DTs: AVG = 0.323.</p></li>
  307. <li><p>Smooth the newly computed average: AVG = lerp(AVGp, AVG, 0.1) = 0.329.</p></li>
  308. </ol>
  309. </dd>
  310. </dl>
  311. </section>
  312. <section id="display">
  313. <h2>Display<a class="headerlink" href="#display" title="Permalink to this headline">¶</a></h2>
  314. <dl class="simple">
  315. <dt><strong>modes</strong> ()<span class="classifier">table</span></dt><dd><p>Returns an array of <a class="reference internal" href="#displaymode">DisplayMode</a> tables.</p>
  316. </dd>
  317. <dt><strong>set_mode</strong> (id)</dt><dd><p>Sets the display mode <em>id</em>.
  318. The initial display mode is automatically reset when the program terminates.</p>
  319. </dd>
  320. </dl>
  321. <section id="displaymode">
  322. <h3>DisplayMode<a class="headerlink" href="#displaymode" title="Permalink to this headline">¶</a></h3>
  323. <p>DisplayMode is a lua table with 3 fields:</p>
  324. <ul class="simple">
  325. <li><p><code class="docutils literal notranslate"><span class="pre">id</span></code>: The id of the display mode.</p></li>
  326. <li><p><code class="docutils literal notranslate"><span class="pre">width</span></code>: The width of the display mode.</p></li>
  327. <li><p><code class="docutils literal notranslate"><span class="pre">height</span></code>: The height of the display mode.</p></li>
  328. </ul>
  329. </section>
  330. </section>
  331. <section id="gui">
  332. <h2>Gui<a class="headerlink" href="#gui" title="Permalink to this headline">¶</a></h2>
  333. <dl class="simple">
  334. <dt><strong>move</strong> (gui, pos)</dt><dd><p>Moves the Gui to <em>pos</em>.</p>
  335. </dd>
  336. <dt><strong>triangle</strong> (gui, a, b, c [, color, depth])</dt><dd><p>Draws a triangle defined by vertices <em>a</em>, <em>b</em> and <em>c</em>.
  337. Objects with a lower depth are drawn in front. If depth is omitted its value
  338. is set to 0.</p>
  339. </dd>
  340. <dt><strong>triangle_3d</strong> (gui, local_pose, a, b, c [, color, depth])</dt><dd><p>Draws a 3D triangle defined by vertices <em>a</em>, <em>b</em> and <em>c</em>.</p>
  341. </dd>
  342. <dt><strong>rect</strong> (gui, pos, size [, color])</dt><dd><p>Draws a rectangle.
  343. If pos is a Vector3, the z element specifies the drawing depth. Objects with
  344. a lower depth are drawn in front. If pos is a Vector2, the z elements is set
  345. to 0.</p>
  346. </dd>
  347. <dt><strong>rect_3d</strong> (gui, local_pose, pos, size [, color, depth])</dt><dd><p>Draws a 3D rectangle.</p>
  348. </dd>
  349. <dt><strong>image</strong> (gui, pos, size, material_resource [, color])</dt><dd><p>Draws an image.
  350. If pos is a Vector3, the z element specifies the drawing depth. Objects with
  351. a lower depth are drawn in front. If pos is a Vector2, the z elements is set
  352. to 0.</p>
  353. </dd>
  354. <dt><strong>image_3d</strong> (gui, local_pose, pos, size, material_resource [, color, depth])</dt><dd><p>Draws a 3D image.</p>
  355. </dd>
  356. <dt><strong>image_uv</strong> (gui, pos, size, uv0, uv1, material_resource [, color])</dt><dd><p>Draws an image with explicit UV coordinates.
  357. If pos is a Vector3, the z element specifies the drawing depth. Objects with
  358. a lower depth are drawn in front. If pos is a Vector2, the z elements is set
  359. to 0.</p>
  360. </dd>
  361. <dt><strong>image_3d_uv</strong> (gui, local_pose, pos, size, uv0, uv1, material_resource [, color, depth])</dt><dd><p>Draws a 3D image with explicit UV coordinates.</p>
  362. </dd>
  363. <dt><strong>text</strong> (gui, pos, font_size, str, font_resource [, material_resource , color])</dt><dd><p>Draws text.
  364. If pos is a Vector3, the z element specifies the drawing depth. Objects with
  365. a lower depth are drawn in front. If pos is a Vector2, the z elements is set
  366. to 0.</p>
  367. </dd>
  368. <dt><strong>text_extents</strong> (gui, font_size, str, font_resource)<span class="classifier">Vector2</span></dt><dd><p>Returns the extents of the text <em>str</em> if drawn using <em>font_resource</em> at size
  369. <em>font_size</em>.</p>
  370. </dd>
  371. <dt><strong>text_3d</strong> (gui, local_pose, pos, font_size, str, font_resource [, material_resource, color, depth])</dt><dd><p>Draws 3D text.</p>
  372. </dd>
  373. <dt><strong>material</strong> (material_resource)<span class="classifier">Material</span></dt><dd><p>Returns the material <em>material_resource</em>.</p>
  374. </dd>
  375. </dl>
  376. </section>
  377. <section id="input">
  378. <h2>Input<a class="headerlink" href="#input" title="Permalink to this headline">¶</a></h2>
  379. <dl class="simple">
  380. <dt><strong>events</strong> ()<span class="classifier">table</span></dt><dd><p>Returns an array of <a class="reference internal" href="#inputevent">InputEvent</a> tables.</p>
  381. </dd>
  382. </dl>
  383. <section id="inputevent">
  384. <h3>InputEvent<a class="headerlink" href="#inputevent" title="Permalink to this headline">¶</a></h3>
  385. <p>InputEvent is a lua table with 4 fields:</p>
  386. <ul class="simple">
  387. <li><p><code class="docutils literal notranslate"><span class="pre">id</span></code>: The id of the button or axis as returned by <code class="docutils literal notranslate"><span class="pre">Keyboard.button_id()</span></code> for example.</p></li>
  388. <li><p><code class="docutils literal notranslate"><span class="pre">type</span></code>: One of the values from <a class="reference internal" href="#inputeventtype">InputEventType</a>.</p></li>
  389. <li><p><code class="docutils literal notranslate"><span class="pre">value</span></code>: The value of the axis as a Vector3 or <code class="docutils literal notranslate"><span class="pre">nil</span></code> when <code class="docutils literal notranslate"><span class="pre">type</span></code> is not an axis event.</p></li>
  390. <li><p><code class="docutils literal notranslate"><span class="pre">device</span></code>: The input device that generated the event. This is one of <code class="docutils literal notranslate"><span class="pre">Keyboard</span></code>, <code class="docutils literal notranslate"><span class="pre">Mouse</span></code>, <code class="docutils literal notranslate"><span class="pre">Pad1</span></code> etc.</p></li>
  391. </ul>
  392. </section>
  393. <section id="inputeventtype">
  394. <h3>InputEventType<a class="headerlink" href="#inputeventtype" title="Permalink to this headline">¶</a></h3>
  395. <ul class="simple">
  396. <li><p><code class="docutils literal notranslate"><span class="pre">BUTTON_PRESSED</span></code>: A button has been pressed.</p></li>
  397. <li><p><code class="docutils literal notranslate"><span class="pre">BUTTON_RELEASED</span></code>: A button has been released.</p></li>
  398. <li><p><code class="docutils literal notranslate"><span class="pre">AXIS_CHANGED</span></code>: An axis changed its value.</p></li>
  399. </ul>
  400. </section>
  401. <section id="keyboard">
  402. <h3>Keyboard<a class="headerlink" href="#keyboard" title="Permalink to this headline">¶</a></h3>
  403. <dl class="simple">
  404. <dt><strong>name</strong> ()<span class="classifier">string</span></dt><dd><p>Returns the name of keyboard.</p>
  405. </dd>
  406. <dt><strong>connected</strong> ()<span class="classifier">bool</span></dt><dd><p>Returns whether the keyboard is connected and functioning.</p>
  407. </dd>
  408. <dt><strong>num_buttons</strong> ()<span class="classifier">int</span></dt><dd><p>Returns the number of buttons of the keyboard.</p>
  409. </dd>
  410. <dt><strong>num_axes</strong> ()<span class="classifier">int</span></dt><dd><p>Returns the number of axes of the keyboard.</p>
  411. </dd>
  412. <dt><strong>pressed</strong> (id)<span class="classifier">bool</span></dt><dd><p>Returns whether the button <em>id</em> is pressed in the current frame.</p>
  413. </dd>
  414. <dt><strong>released</strong> (id)<span class="classifier">bool</span></dt><dd><p>Returns whether the button <em>id</em> is released in the current frame.</p>
  415. </dd>
  416. <dt><strong>any_pressed</strong> ()<span class="classifier">bool</span></dt><dd><p>Returns the <em>id</em> of the first button that was pressed in the current frame
  417. or <code class="docutils literal notranslate"><span class="pre">nil</span></code> if no buttons were pressed at all.</p>
  418. </dd>
  419. <dt><strong>any_released</strong> ()<span class="classifier">bool</span></dt><dd><p>Returns the <em>id</em> of the first button that was released in the current frame
  420. or <code class="docutils literal notranslate"><span class="pre">nil</span></code> if no buttons were released at all.</p>
  421. </dd>
  422. <dt><strong>button</strong> (id)<span class="classifier">float</span></dt><dd><p>Returns the value of the button <em>id</em> in the range [0..1].</p>
  423. </dd>
  424. <dt><strong>button_name</strong> (id)<span class="classifier">string</span></dt><dd><p>Returns the name of the button <em>id</em>.</p>
  425. </dd>
  426. <dt><strong>button_id</strong> (name)<span class="classifier">int</span></dt><dd><p>Returns the <em>id</em> of the button <em>name</em> or <code class="docutils literal notranslate"><span class="pre">nil</span></code> if no matching button is found.</p>
  427. </dd>
  428. </dl>
  429. <section id="keyboard-button-names">
  430. <h4>Keyboard Button Names<a class="headerlink" href="#keyboard-button-names" title="Permalink to this headline">¶</a></h4>
  431. <ul class="simple">
  432. <li><p><code class="docutils literal notranslate"><span class="pre">tab</span></code>, <code class="docutils literal notranslate"><span class="pre">enter</span></code>, <code class="docutils literal notranslate"><span class="pre">escape</span></code>, <code class="docutils literal notranslate"><span class="pre">space</span></code>, <code class="docutils literal notranslate"><span class="pre">backspace</span></code></p></li>
  433. <li><p><code class="docutils literal notranslate"><span class="pre">num_lock</span></code>, <code class="docutils literal notranslate"><span class="pre">numpad_enter</span></code>, <code class="docutils literal notranslate"><span class="pre">numpad_.</span></code>, <code class="docutils literal notranslate"><span class="pre">numpad_*</span></code>, <code class="docutils literal notranslate"><span class="pre">numpad_+</span></code>, <code class="docutils literal notranslate"><span class="pre">numpad_-</span></code>, <code class="docutils literal notranslate"><span class="pre">numpad_/</span></code>, <code class="docutils literal notranslate"><span class="pre">numpad_0</span></code>, <code class="docutils literal notranslate"><span class="pre">numpad_1</span></code>, <code class="docutils literal notranslate"><span class="pre">numpad_2</span></code>, <code class="docutils literal notranslate"><span class="pre">numpad_3</span></code>, <code class="docutils literal notranslate"><span class="pre">numpad_4</span></code>, <code class="docutils literal notranslate"><span class="pre">numpad_5</span></code>, <code class="docutils literal notranslate"><span class="pre">numpad_6</span></code>, <code class="docutils literal notranslate"><span class="pre">numpad_7</span></code>, <code class="docutils literal notranslate"><span class="pre">numpad_8</span></code>, <code class="docutils literal notranslate"><span class="pre">numpad_9</span></code></p></li>
  434. <li><p><code class="docutils literal notranslate"><span class="pre">f1</span></code>, <code class="docutils literal notranslate"><span class="pre">f2</span></code>, <code class="docutils literal notranslate"><span class="pre">f3</span></code>, <code class="docutils literal notranslate"><span class="pre">f4</span></code>, <code class="docutils literal notranslate"><span class="pre">f5</span></code>, <code class="docutils literal notranslate"><span class="pre">f6</span></code>, <code class="docutils literal notranslate"><span class="pre">f7</span></code>, <code class="docutils literal notranslate"><span class="pre">f8</span></code>, <code class="docutils literal notranslate"><span class="pre">f9</span></code>, <code class="docutils literal notranslate"><span class="pre">f10</span></code>, <code class="docutils literal notranslate"><span class="pre">f11</span></code>, <code class="docutils literal notranslate"><span class="pre">f12</span></code></p></li>
  435. <li><p><code class="docutils literal notranslate"><span class="pre">home</span></code>, <code class="docutils literal notranslate"><span class="pre">left</span></code>, <code class="docutils literal notranslate"><span class="pre">up</span></code>, <code class="docutils literal notranslate"><span class="pre">right</span></code>, <code class="docutils literal notranslate"><span class="pre">down</span></code>, <code class="docutils literal notranslate"><span class="pre">page_up</span></code>, <code class="docutils literal notranslate"><span class="pre">page_down</span></code>, <code class="docutils literal notranslate"><span class="pre">ins</span></code>, <code class="docutils literal notranslate"><span class="pre">del</span></code>, <code class="docutils literal notranslate"><span class="pre">end</span></code></p></li>
  436. <li><p><code class="docutils literal notranslate"><span class="pre">ctrl_left</span></code>, <code class="docutils literal notranslate"><span class="pre">ctrl_right</span></code>, <code class="docutils literal notranslate"><span class="pre">shift_left</span></code>, <code class="docutils literal notranslate"><span class="pre">shift_right</span></code>, <code class="docutils literal notranslate"><span class="pre">caps_lock</span></code>, <code class="docutils literal notranslate"><span class="pre">alt_left</span></code>, <code class="docutils literal notranslate"><span class="pre">alt_right</span></code>, <code class="docutils literal notranslate"><span class="pre">super_left</span></code>, <code class="docutils literal notranslate"><span class="pre">super_right</span></code></p></li>
  437. <li><p><code class="docutils literal notranslate"><span class="pre">0</span></code>, <code class="docutils literal notranslate"><span class="pre">1</span></code>, <code class="docutils literal notranslate"><span class="pre">2</span></code>, <code class="docutils literal notranslate"><span class="pre">3</span></code>, <code class="docutils literal notranslate"><span class="pre">4</span></code>, <code class="docutils literal notranslate"><span class="pre">5</span></code>, <code class="docutils literal notranslate"><span class="pre">6</span></code>, <code class="docutils literal notranslate"><span class="pre">7</span></code>, <code class="docutils literal notranslate"><span class="pre">8</span></code>, <code class="docutils literal notranslate"><span class="pre">9</span></code></p></li>
  438. <li><p><code class="docutils literal notranslate"><span class="pre">a</span></code>, <code class="docutils literal notranslate"><span class="pre">b</span></code>, <code class="docutils literal notranslate"><span class="pre">c</span></code>, <code class="docutils literal notranslate"><span class="pre">d</span></code>, <code class="docutils literal notranslate"><span class="pre">e</span></code>, <code class="docutils literal notranslate"><span class="pre">f</span></code>, <code class="docutils literal notranslate"><span class="pre">g</span></code>, <code class="docutils literal notranslate"><span class="pre">h</span></code>, <code class="docutils literal notranslate"><span class="pre">i</span></code>, <code class="docutils literal notranslate"><span class="pre">j</span></code>, <code class="docutils literal notranslate"><span class="pre">k</span></code>, <code class="docutils literal notranslate"><span class="pre">l</span></code>, <code class="docutils literal notranslate"><span class="pre">m</span></code>, <code class="docutils literal notranslate"><span class="pre">n</span></code>, <code class="docutils literal notranslate"><span class="pre">o</span></code>, <code class="docutils literal notranslate"><span class="pre">p</span></code>, <code class="docutils literal notranslate"><span class="pre">q</span></code>, <code class="docutils literal notranslate"><span class="pre">r</span></code>, <code class="docutils literal notranslate"><span class="pre">s</span></code>, <code class="docutils literal notranslate"><span class="pre">t</span></code>, <code class="docutils literal notranslate"><span class="pre">u</span></code>, <code class="docutils literal notranslate"><span class="pre">v</span></code>, <code class="docutils literal notranslate"><span class="pre">w</span></code>, <code class="docutils literal notranslate"><span class="pre">x</span></code>, <code class="docutils literal notranslate"><span class="pre">y</span></code>, <code class="docutils literal notranslate"><span class="pre">z</span></code></p></li>
  439. </ul>
  440. </section>
  441. <section id="keyboard-axis-names">
  442. <h4>Keyboard Axis Names<a class="headerlink" href="#keyboard-axis-names" title="Permalink to this headline">¶</a></h4>
  443. <p>None.</p>
  444. </section>
  445. </section>
  446. <section id="mouse">
  447. <h3>Mouse<a class="headerlink" href="#mouse" title="Permalink to this headline">¶</a></h3>
  448. <dl class="simple">
  449. <dt><strong>name</strong> ()<span class="classifier">string</span></dt><dd><p>Returns the name of the mouse.</p>
  450. </dd>
  451. <dt><strong>connected</strong> ()<span class="classifier">bool</span></dt><dd><p>Returns whether the mouse is connected and functioning.</p>
  452. </dd>
  453. <dt><strong>num_buttons</strong> ()<span class="classifier">int</span></dt><dd><p>Returns the number of buttons of the mouse.</p>
  454. </dd>
  455. <dt><strong>num_axes</strong> ()<span class="classifier">int</span></dt><dd><p>Returns the number of axes of the mouse.</p>
  456. </dd>
  457. <dt><strong>pressed</strong> (id)<span class="classifier">bool</span></dt><dd><p>Returns whether the button <em>id</em> is pressed in the current frame.</p>
  458. </dd>
  459. <dt><strong>released</strong> (id)<span class="classifier">bool</span></dt><dd><p>Returns whether the button <em>id</em> is released in the current frame.</p>
  460. </dd>
  461. <dt><strong>any_pressed</strong> ()<span class="classifier">bool</span></dt><dd><p>Returns the <em>id</em> of the first button that was pressed in the current frame
  462. or <code class="docutils literal notranslate"><span class="pre">nil</span></code> if no buttons were pressed at all.</p>
  463. </dd>
  464. <dt><strong>any_released</strong> ()<span class="classifier">bool</span></dt><dd><p>Returns the <em>id</em> of the first button that was released in the current frame
  465. or <code class="docutils literal notranslate"><span class="pre">nil</span></code> if no buttons were released at all.</p>
  466. </dd>
  467. <dt><strong>button</strong> (id)<span class="classifier">float</span></dt><dd><p>Returns the value of the button <em>id</em> in the range [0..1].</p>
  468. </dd>
  469. <dt><strong>axis</strong> (id)<span class="classifier">Vector3</span></dt><dd><p>Returns the value of the axis <em>id</em>.</p>
  470. </dd>
  471. <dt><strong>button_name</strong> (id)<span class="classifier">string</span></dt><dd><p>Returns the name of the button <em>id</em>.</p>
  472. </dd>
  473. <dt><strong>axis_name</strong> (id)<span class="classifier">string</span></dt><dd><p>Returns the name of the axis <em>id</em>.</p>
  474. </dd>
  475. <dt><strong>button_id</strong> (name)<span class="classifier">int</span></dt><dd><p>Returns the <em>id</em> of the button <em>name</em> or <code class="docutils literal notranslate"><span class="pre">nil</span></code> if no matching button is found.</p>
  476. </dd>
  477. <dt><strong>axis_id</strong> (name)<span class="classifier">int</span></dt><dd><p>Returns the <em>id</em> of the axis <em>name</em> or <code class="docutils literal notranslate"><span class="pre">nil</span></code> if no matching axis is found.</p>
  478. </dd>
  479. </dl>
  480. <section id="mouse-button-names">
  481. <h4>Mouse Button Names<a class="headerlink" href="#mouse-button-names" title="Permalink to this headline">¶</a></h4>
  482. <p><code class="docutils literal notranslate"><span class="pre">left</span></code>, <code class="docutils literal notranslate"><span class="pre">middle</span></code>, <code class="docutils literal notranslate"><span class="pre">right</span></code>, <code class="docutils literal notranslate"><span class="pre">extra_1</span></code>, <code class="docutils literal notranslate"><span class="pre">extra_2</span></code></p>
  483. </section>
  484. <section id="mouse-axis-names">
  485. <h4>Mouse Axis Names<a class="headerlink" href="#mouse-axis-names" title="Permalink to this headline">¶</a></h4>
  486. <ul class="simple">
  487. <li><p><code class="docutils literal notranslate"><span class="pre">cursor</span></code>: Returns the cursor position (x, y) in screen coordinates.</p></li>
  488. <li><p><code class="docutils literal notranslate"><span class="pre">cursor_delta</span></code>: Returns the delta of the cursor position (x, y) since last frame.</p></li>
  489. <li><p><code class="docutils literal notranslate"><span class="pre">wheel</span></code>: Returns the movement of the mouse wheel in the y axis. Positive values of y mean upward scrolling, negative values mean downward scrolling.</p></li>
  490. </ul>
  491. </section>
  492. </section>
  493. <section id="touch">
  494. <h3>Touch<a class="headerlink" href="#touch" title="Permalink to this headline">¶</a></h3>
  495. <dl class="simple">
  496. <dt><strong>name</strong> ()<span class="classifier">string</span></dt><dd><p>Returns the name of the touch.</p>
  497. </dd>
  498. <dt><strong>connected</strong> ()<span class="classifier">bool</span></dt><dd><p>Returns whether the touch is connected and functioning.</p>
  499. </dd>
  500. <dt><strong>num_buttons</strong> ()<span class="classifier">int</span></dt><dd><p>Returns the number of buttons of the touch.</p>
  501. </dd>
  502. <dt><strong>num_axes</strong> ()<span class="classifier">int</span></dt><dd><p>Returns the number of axes of the touch.</p>
  503. </dd>
  504. <dt><strong>pressed</strong> (id)<span class="classifier">bool</span></dt><dd><p>Returns whether the button <em>id</em> is pressed in the current frame.</p>
  505. </dd>
  506. <dt><strong>released</strong> (id)<span class="classifier">bool</span></dt><dd><p>Returns whether the button <em>id</em> is released in the current frame.</p>
  507. </dd>
  508. <dt><strong>any_pressed</strong> ()<span class="classifier">bool</span></dt><dd><p>Returns the <em>id</em> of the first button that was pressed in the current frame
  509. or <code class="docutils literal notranslate"><span class="pre">nil</span></code> if no buttons were pressed at all.</p>
  510. </dd>
  511. <dt><strong>any_released</strong> ()<span class="classifier">bool</span></dt><dd><p>Returns the <em>id</em> of the first button that was released in the current frame
  512. or <code class="docutils literal notranslate"><span class="pre">nil</span></code> if no buttons were released at all.</p>
  513. </dd>
  514. <dt><strong>button</strong> (id)<span class="classifier">float</span></dt><dd><p>Returns the value of the button <em>id</em> in the range [0..1].</p>
  515. </dd>
  516. <dt><strong>axis</strong> (id)<span class="classifier">Vector3</span></dt><dd><p>Returns the value of the axis <em>id</em>.</p>
  517. </dd>
  518. <dt><strong>button_name</strong> (id)<span class="classifier">string</span></dt><dd><p>Returns the name of the button <em>id</em>.</p>
  519. </dd>
  520. <dt><strong>axis_name</strong> (id)<span class="classifier">string</span></dt><dd><p>Returns the name of the axis <em>id</em>.</p>
  521. </dd>
  522. <dt><strong>button_id</strong> (name)<span class="classifier">int</span></dt><dd><p>Returns the <em>id</em> of the button <em>name</em> or <code class="docutils literal notranslate"><span class="pre">nil</span></code> if no matching button is found.</p>
  523. </dd>
  524. <dt><strong>axis_id</strong> (name)<span class="classifier">int</span></dt><dd><p>Returns the <em>id</em> of the axis <em>name</em> or <code class="docutils literal notranslate"><span class="pre">nil</span></code> if no matching axis is found.</p>
  525. </dd>
  526. </dl>
  527. </section>
  528. <section id="pad1-pad2-pad3-pad4">
  529. <h3>Pad1, Pad2, Pad3, Pad4<a class="headerlink" href="#pad1-pad2-pad3-pad4" title="Permalink to this headline">¶</a></h3>
  530. <dl class="simple">
  531. <dt><strong>name</strong> ()<span class="classifier">string</span></dt><dd><p>Returns the name of the pad.</p>
  532. </dd>
  533. <dt><strong>connected</strong> ()<span class="classifier">bool</span></dt><dd><p>Returns whether the pad is connected and functioning.</p>
  534. </dd>
  535. <dt><strong>num_buttons</strong> ()<span class="classifier">int</span></dt><dd><p>Returns the number of buttons of the pad.</p>
  536. </dd>
  537. <dt><strong>num_axes</strong> ()<span class="classifier">int</span></dt><dd><p>Returns the number of axes of the pad.</p>
  538. </dd>
  539. <dt><strong>pressed</strong> (id)<span class="classifier">bool</span></dt><dd><p>Returns whether the button <em>id</em> is pressed in the current frame.</p>
  540. </dd>
  541. <dt><strong>released</strong> (id)<span class="classifier">bool</span></dt><dd><p>Returns whether the button <em>id</em> is released in the current frame.</p>
  542. </dd>
  543. <dt><strong>any_pressed</strong> ()<span class="classifier">bool</span></dt><dd><p>Returns the <em>id</em> of the first button that was pressed in the current frame
  544. or <code class="docutils literal notranslate"><span class="pre">nil</span></code> if no buttons were pressed at all.</p>
  545. </dd>
  546. <dt><strong>any_released</strong> ()<span class="classifier">bool</span></dt><dd><p>Returns the <em>id</em> of the first button that was released in the current frame
  547. or <code class="docutils literal notranslate"><span class="pre">nil</span></code> if no buttons were released at all.</p>
  548. </dd>
  549. <dt><strong>button</strong> (id)<span class="classifier">float</span></dt><dd><p>Returns the value of the button <em>id</em> in the range [0..1].</p>
  550. </dd>
  551. <dt><strong>axis</strong> (id)<span class="classifier">Vector3</span></dt><dd><p>Returns the value of the axis <em>id</em>.</p>
  552. </dd>
  553. <dt><strong>button_name</strong> (id)<span class="classifier">string</span></dt><dd><p>Returns the name of the button <em>id</em>.</p>
  554. </dd>
  555. <dt><strong>axis_name</strong> (id)<span class="classifier">string</span></dt><dd><p>Returns the name of the axis <em>id</em>.</p>
  556. </dd>
  557. <dt><strong>button_id</strong> (name)<span class="classifier">int</span></dt><dd><p>Returns the <em>id</em> of the button <em>name</em> or <code class="docutils literal notranslate"><span class="pre">nil</span></code> if no matching button is found.</p>
  558. </dd>
  559. <dt><strong>axis_id</strong> (name)<span class="classifier">int</span></dt><dd><p>Returns the <em>id</em> of the axis <em>name</em> or <code class="docutils literal notranslate"><span class="pre">nil</span></code> if no matching axis is found.</p>
  560. </dd>
  561. <dt><strong>deadzone</strong> (id)<span class="classifier">deadzone_mode, deadzone_size</span></dt><dd><p>Returns the deadzone mode and size for the axis <em>id</em>.</p>
  562. </dd>
  563. <dt><strong>set_deadzone</strong> (id, deadzone_mode, deadzone_size)</dt><dd><p>Sets the <em>deadzone_mode</em> and <em>deadzone_size</em> for the axis <em>id</em>.</p>
  564. </dd>
  565. </dl>
  566. <section id="pad-button-names">
  567. <h4>Pad Button Names<a class="headerlink" href="#pad-button-names" title="Permalink to this headline">¶</a></h4>
  568. <ul class="simple">
  569. <li><p><code class="docutils literal notranslate"><span class="pre">up</span></code>, <code class="docutils literal notranslate"><span class="pre">down</span></code>, <code class="docutils literal notranslate"><span class="pre">left</span></code>, <code class="docutils literal notranslate"><span class="pre">right</span></code></p></li>
  570. <li><p><code class="docutils literal notranslate"><span class="pre">start</span></code>, <code class="docutils literal notranslate"><span class="pre">back</span></code>, <code class="docutils literal notranslate"><span class="pre">guide</span></code></p></li>
  571. <li><p><code class="docutils literal notranslate"><span class="pre">thumb_left</span></code>, <code class="docutils literal notranslate"><span class="pre">thumb_right</span></code></p></li>
  572. <li><p><code class="docutils literal notranslate"><span class="pre">shoulder_left</span></code>, <code class="docutils literal notranslate"><span class="pre">shoulder_right</span></code></p></li>
  573. <li><p><code class="docutils literal notranslate"><span class="pre">a</span></code>, <code class="docutils literal notranslate"><span class="pre">b</span></code>, <code class="docutils literal notranslate"><span class="pre">x</span></code>, <code class="docutils literal notranslate"><span class="pre">y</span></code></p></li>
  574. </ul>
  575. </section>
  576. <section id="pad-axis-names">
  577. <h4>Pad Axis Names<a class="headerlink" href="#pad-axis-names" title="Permalink to this headline">¶</a></h4>
  578. <ul class="simple">
  579. <li><p><code class="docutils literal notranslate"><span class="pre">left</span></code>, <code class="docutils literal notranslate"><span class="pre">right</span></code>: Returns the direction (x, y) of the left or right thumbstick [-1; +1].</p></li>
  580. <li><p><code class="docutils literal notranslate"><span class="pre">trigger_left</span></code>, <code class="docutils literal notranslate"><span class="pre">trigger_right</span></code>: The z element represents the left or right trigger [0; +1].</p></li>
  581. </ul>
  582. </section>
  583. </section>
  584. </section>
  585. <section id="material">
  586. <h2>Material<a class="headerlink" href="#material" title="Permalink to this headline">¶</a></h2>
  587. <dl class="simple">
  588. <dt><strong>set_float</strong> (material, name, value)</dt><dd><p>Sets the <em>value</em> of the variable <em>name</em>.</p>
  589. </dd>
  590. <dt><strong>set_vector2</strong> (material, name, value)</dt><dd><p>Sets the <em>value</em> of the variable <em>name</em>.</p>
  591. </dd>
  592. <dt><strong>set_vector3</strong> (material, name, value)</dt><dd><p>Sets the <em>value</em> of the variable <em>name</em>.</p>
  593. </dd>
  594. <dt><strong>set_vector4</strong> (material, name, value)</dt><dd><p>Sets the <em>value</em> of the variable <em>name</em>.</p>
  595. </dd>
  596. <dt><strong>set_matrix4x4</strong> (material, name, value)</dt><dd><p>Sets the <em>value</em> of the variable <em>name</em>.</p>
  597. </dd>
  598. <dt><strong>set_texture</strong> (material, sampler_name, texture_name)</dt><dd><p>Sets the <em>texture_resource</em> of the sampler <em>sampler_name</em>.</p>
  599. </dd>
  600. </dl>
  601. </section>
  602. <section id="math">
  603. <h2>Math<a class="headerlink" href="#math" title="Permalink to this headline">¶</a></h2>
  604. <section id="vector3">
  605. <h3>Vector3<a class="headerlink" href="#vector3" title="Permalink to this headline">¶</a></h3>
  606. <section id="constructors">
  607. <h4>Constructors<a class="headerlink" href="#constructors" title="Permalink to this headline">¶</a></h4>
  608. <dl class="simple">
  609. <dt><strong>Vector3</strong> (x, y, z)<span class="classifier">Vector3</span></dt><dd><p>Returns a new vector from individual elements.</p>
  610. </dd>
  611. </dl>
  612. </section>
  613. <section id="functions">
  614. <h4>Functions<a class="headerlink" href="#functions" title="Permalink to this headline">¶</a></h4>
  615. <dl class="simple">
  616. <dt><strong>x</strong> (v)<span class="classifier">float</span></dt><dd><p>Returns the x value of the vector.</p>
  617. </dd>
  618. <dt><strong>y</strong> (v)<span class="classifier">float</span></dt><dd><p>Returns the y value of the vector.</p>
  619. </dd>
  620. <dt><strong>z</strong> (v)<span class="classifier">float</span></dt><dd><p>Returns the z value of the vector.</p>
  621. </dd>
  622. <dt><strong>.x</strong><span class="classifier">float</span></dt><dd><p>Returns/assigns the x value of the vector.</p>
  623. </dd>
  624. <dt><strong>.y</strong><span class="classifier">float</span></dt><dd><p>Returns/assigns the y value of the vector.</p>
  625. </dd>
  626. <dt><strong>.z</strong><span class="classifier">float</span></dt><dd><p>Returns/assigns the z value of the vector.</p>
  627. </dd>
  628. <dt><strong>set_x</strong> (v, x)</dt><dd><p>Sets the value of the x value of the vector.</p>
  629. </dd>
  630. <dt><strong>set_y</strong> (v, y)</dt><dd><p>Sets the value of the y value of the vector.</p>
  631. </dd>
  632. <dt><strong>set_z</strong> (v, z)</dt><dd><p>Sets the value of the z value of the vector.</p>
  633. </dd>
  634. <dt><strong>elements</strong> (v)<span class="classifier">float, float, float</span></dt><dd><p>Returns the x, y and z elements of the vector.</p>
  635. </dd>
  636. <dt><strong>add</strong> (a, b)<span class="classifier">Vector3</span></dt><dd><p>Adds the vector <em>a</em> to <em>b</em> and returns the result.</p>
  637. </dd>
  638. <dt><strong>subtract</strong> (a, b)<span class="classifier">Vector3</span></dt><dd><p>Subtracts the vector <em>b</em> from <em>a</em> and returns the result.</p>
  639. </dd>
  640. <dt><strong>multiply</strong> (a, k)<span class="classifier">Vector3</span></dt><dd><p>Multiplies the vector <em>a</em> by the scalar <em>k</em> and returns the result.</p>
  641. </dd>
  642. <dt><strong>dot</strong> (a, b)<span class="classifier">float</span></dt><dd><p>Returns the dot product between the vectors <em>a</em> and <em>b</em>.</p>
  643. </dd>
  644. <dt><strong>cross</strong> (a, b)<span class="classifier">Vector3</span></dt><dd><p>Returns the cross product between the vectors <em>a</em> and <em>b</em>.</p>
  645. </dd>
  646. <dt><strong>equal</strong> (a, b)<span class="classifier">bool</span></dt><dd><p>Returns true whether the vectors <em>a</em> and <em>b</em> are equal.</p>
  647. </dd>
  648. <dt><strong>length</strong> (a)<span class="classifier">float</span></dt><dd><p>Returns the length of <em>a</em>.</p>
  649. </dd>
  650. <dt><strong>length_squared</strong> (a)<span class="classifier">float</span></dt><dd><p>Returns the squared length of <em>a</em>.</p>
  651. </dd>
  652. <dt><strong>set_length</strong> (a, len)</dt><dd><p>Sets the length of <em>a</em> to <em>len</em>.</p>
  653. </dd>
  654. <dt><strong>normalize</strong> (a)<span class="classifier">Vector3</span></dt><dd><p>Normalizes <em>a</em> and returns the result.</p>
  655. </dd>
  656. <dt><strong>distance</strong> (a, b)<span class="classifier">float</span></dt><dd><p>Returns the distance between the points <em>a</em> and <em>b</em>.</p>
  657. </dd>
  658. <dt><strong>distance_squared</strong> (a, b)<span class="classifier">float</span></dt><dd><p>Returns the squared distance between the points <em>a</em> and <em>b</em>.</p>
  659. </dd>
  660. <dt><strong>angle</strong> (a, b)<span class="classifier">float</span></dt><dd><p>Returns the angle between the vectors <em>a</em> and <em>b</em>.</p>
  661. </dd>
  662. <dt><strong>max</strong> (a, b)<span class="classifier">Vector3</span></dt><dd><p>Returns a vector that contains the largest value for each element from <em>a</em> and <em>b</em>.</p>
  663. </dd>
  664. <dt><strong>min</strong> (a, b)<span class="classifier">Vector3</span></dt><dd><p>Returns a vector that contains the smallest value for each element from <em>a</em> and <em>b</em>.</p>
  665. </dd>
  666. <dt><strong>lerp</strong> (a, b, t)<span class="classifier">Vector3</span></dt><dd><p>Returns the linearly interpolated vector between <em>a</em> and <em>b</em> at time <em>t</em> in [0, 1].</p>
  667. </dd>
  668. </dl>
  669. <div class="line-block">
  670. <div class="line"><strong>forward</strong> () : Vector3</div>
  671. <div class="line"><strong>backward</strong> () : Vector3</div>
  672. <div class="line"><strong>left</strong> () : Vector3</div>
  673. <div class="line"><strong>right</strong> () : Vector3</div>
  674. <div class="line"><strong>up</strong> () : Vector3</div>
  675. <div class="line"><strong>down</strong> () : Vector3</div>
  676. <div class="line-block">
  677. <div class="line">Returns the corresponding semantic axis.</div>
  678. </div>
  679. </div>
  680. <dl class="simple">
  681. <dt><strong>zero</strong> ()<span class="classifier">Vector3</span></dt><dd><p>Returns a vector with all values set to zero.</p>
  682. </dd>
  683. <dt><strong>to_string</strong> (v)<span class="classifier">string</span></dt><dd><p>Returns a string representing the vector <em>v</em>.</p>
  684. </dd>
  685. </dl>
  686. </section>
  687. </section>
  688. <section id="vector3box">
  689. <h3>Vector3Box<a class="headerlink" href="#vector3box" title="Permalink to this headline">¶</a></h3>
  690. <section id="id1">
  691. <h4>Constructors<a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h4>
  692. <dl class="simple">
  693. <dt><strong>Vector3Box</strong> ()<span class="classifier">Vector3Box</span></dt><dd><p>Returns a new Vector3Box initialized with the zero vector.</p>
  694. </dd>
  695. <dt><strong>Vector3Box</strong> (v)<span class="classifier">Vector3Box</span></dt><dd><p>Returns a new Vector3Box from the Vector3 <em>v</em>.</p>
  696. </dd>
  697. <dt><strong>Vector3Box</strong> (x, y, z)<span class="classifier">Vector3Box</span></dt><dd><p>Returns a new Vector3Box from individual elements.</p>
  698. </dd>
  699. </dl>
  700. </section>
  701. <section id="id2">
  702. <h4>Functions<a class="headerlink" href="#id2" title="Permalink to this headline">¶</a></h4>
  703. <dl class="simple">
  704. <dt><strong>store</strong> (v)</dt><dd><p>Stores the Vector3 <em>v</em> in the box.</p>
  705. </dd>
  706. <dt><strong>store</strong> (x, y, z)</dt><dd><p>Stores Vector3(x, y, z) in the box.</p>
  707. </dd>
  708. <dt><strong>unbox</strong> ()<span class="classifier">Vector3</span></dt><dd><p>Returns the stored vector from the box.</p>
  709. </dd>
  710. </dl>
  711. </section>
  712. </section>
  713. <section id="quaternion">
  714. <h3>Quaternion<a class="headerlink" href="#quaternion" title="Permalink to this headline">¶</a></h3>
  715. <section id="id3">
  716. <h4>Constructors<a class="headerlink" href="#id3" title="Permalink to this headline">¶</a></h4>
  717. <dl class="simple">
  718. <dt><strong>Quaternion</strong> (axis, angle)<span class="classifier">Quaternion</span></dt><dd><p>Returns a new quaternion from <em>axis</em> and <em>angle</em>.</p>
  719. </dd>
  720. <dt><strong>from_elements</strong> (x, y, z, w)<span class="classifier">Quaternion</span></dt><dd><p>Returns a new quaternion from individual elements.</p>
  721. </dd>
  722. <dt><strong>from_axis_angle</strong> (axis, angle)<span class="classifier">Quaternion</span></dt><dd><p>Returns a new quaternion from <em>axis</em> and <em>angle</em>.</p>
  723. </dd>
  724. </dl>
  725. </section>
  726. <section id="id4">
  727. <h4>Functions<a class="headerlink" href="#id4" title="Permalink to this headline">¶</a></h4>
  728. <dl class="simple">
  729. <dt><strong>negate</strong> (q)<span class="classifier">Quaternion</span></dt><dd><p>Negates the quaternion <em>q</em> and returns the result.</p>
  730. </dd>
  731. <dt><strong>identity</strong> ()<span class="classifier">Quaternion</span></dt><dd><p>Returns the identity quaternion.</p>
  732. </dd>
  733. <dt><strong>multiply</strong> (a, b)<span class="classifier">Quaternion</span></dt><dd><p>Multiplies the quaternions <em>a</em> and <em>b</em>. (i.e. rotates first by <em>a</em> then by <em>b</em>).</p>
  734. </dd>
  735. <dt><strong>multiply_by_scalar</strong> (a, k)<span class="classifier">Quaternion</span></dt><dd><p>Multiplies the quaternion <em>a</em> by the scalar <em>k</em>.</p>
  736. </dd>
  737. <dt><strong>dot</strong> (a, b)<span class="classifier">float</span></dt><dd><p>Returns the dot product between quaternions <em>a</em> and <em>b</em>.</p>
  738. </dd>
  739. <dt><strong>length</strong> (q)<span class="classifier">float</span></dt><dd><p>Returns the length of <em>q</em>.</p>
  740. </dd>
  741. <dt><strong>normalize</strong> (q)<span class="classifier">Quaternion</span></dt><dd><p>Normalizes the quaternion <em>q</em> and returns the result.</p>
  742. </dd>
  743. <dt><strong>conjugate</strong> (q)<span class="classifier">Quaternion</span></dt><dd><p>Returns the conjugate of quaternion <em>q</em>.</p>
  744. </dd>
  745. <dt><strong>inverse</strong> (q)<span class="classifier">Quaternion</span></dt><dd><p>Returns the inverse of quaternion <em>q</em>.</p>
  746. </dd>
  747. <dt><strong>power</strong> (q, exp)<span class="classifier">Quaternion</span></dt><dd><p>Returns the quaternion <em>q</em> raised to the power of <em>exp</em>.</p>
  748. </dd>
  749. <dt><strong>elements</strong> (q)<span class="classifier">float, float, float, float</span></dt><dd><p>Returns the x, y, z and w elements of the quaternion.</p>
  750. </dd>
  751. <dt><strong>look</strong> (dir, [up])<span class="classifier">Quaternion</span></dt><dd><p>Returns the quaternion describing the rotation needed to face towards <em>dir</em>.
  752. If <em>up</em> is not specified, Vector3.up() is used.</p>
  753. </dd>
  754. <dt><strong>right</strong> (q)<span class="classifier">Vector3</span></dt><dd><p>Returns the right axis of the rotation described by <em>q</em>.</p>
  755. </dd>
  756. <dt><strong>up</strong> (q)<span class="classifier">Vector3</span></dt><dd><p>Returns the up axis of the rotation described by <em>q</em>.</p>
  757. </dd>
  758. <dt><strong>forward</strong> (q)<span class="classifier">Vector3</span></dt><dd><p>Returns the forward axis of the rotation described by <em>q</em>.</p>
  759. </dd>
  760. <dt><strong>lerp</strong> (a, b, t)<span class="classifier">Quaternion</span></dt><dd><p>Returns the linearly interpolated quaternion between <em>a</em> and <em>b</em> at time <em>t</em> in [0, 1].
  761. It uses NLerp.</p>
  762. </dd>
  763. <dt><strong>to_string</strong> (q)<span class="classifier">string</span></dt><dd><p>Returns a string representing the quaternion <em>q</em>.</p>
  764. </dd>
  765. </dl>
  766. </section>
  767. </section>
  768. <section id="quaternionbox">
  769. <h3>QuaternionBox<a class="headerlink" href="#quaternionbox" title="Permalink to this headline">¶</a></h3>
  770. <section id="id5">
  771. <h4>Constructors<a class="headerlink" href="#id5" title="Permalink to this headline">¶</a></h4>
  772. <dl class="simple">
  773. <dt><strong>QuaternionBox</strong> ()<span class="classifier">QuaternionBox</span></dt><dd><p>Returns a new QuaternionBox initialized with the identity quaternion.</p>
  774. </dd>
  775. <dt><strong>QuaternionBox</strong> (q)<span class="classifier">QuaternionBox</span></dt><dd><p>Returns a new QuaternionBox from the Quaternion <em>q</em>.</p>
  776. </dd>
  777. <dt><strong>QuaternionBox</strong> (x, y, z, w)<span class="classifier">QuaternionBox</span></dt><dd><p>Returns a new QuaternionBox from individual elements.</p>
  778. </dd>
  779. </dl>
  780. </section>
  781. <section id="id6">
  782. <h4>Functions<a class="headerlink" href="#id6" title="Permalink to this headline">¶</a></h4>
  783. <dl class="simple">
  784. <dt><strong>store</strong> (q)</dt><dd><p>Stores the Quaternion <em>q</em> in the box.</p>
  785. </dd>
  786. <dt><strong>store</strong> (x, y, z, w)</dt><dd><p>Stores Quaternion(x, y, z, w) in the box.</p>
  787. </dd>
  788. <dt><strong>unbox</strong> ()<span class="classifier">Quaternion</span></dt><dd><p>Returns the stored quaternion from the box.</p>
  789. </dd>
  790. </dl>
  791. </section>
  792. </section>
  793. <section id="matrix4x4">
  794. <h3>Matrix4x4<a class="headerlink" href="#matrix4x4" title="Permalink to this headline">¶</a></h3>
  795. <section id="id7">
  796. <h4>Constructors<a class="headerlink" href="#id7" title="Permalink to this headline">¶</a></h4>
  797. <dl class="simple">
  798. <dt><strong>Matrix4x4</strong> (xx, xy, xz, xw, yx, yy, yz, yw, zx, zy, zz, zw, tx, ty, tz, tw)<span class="classifier">Matrix4x4</span></dt><dd><p>Returns a new matrix from individual elements.</p>
  799. </dd>
  800. <dt><strong>from_quaternion</strong> (q)<span class="classifier">Matrix4x4</span></dt><dd><p>Returns a new matrix from <em>q</em>.</p>
  801. </dd>
  802. <dt><strong>from_translation</strong> (t)<span class="classifier">Matrix4x4</span></dt><dd><p>Returns a new matrix from <em>t</em>.</p>
  803. </dd>
  804. <dt><strong>from_quaternion_translation</strong> (q, t)<span class="classifier">Matrix4x4</span></dt><dd><p>Returns a new matrix from <em>q</em> and <em>t</em>.</p>
  805. </dd>
  806. <dt><strong>from_axes</strong> (x, y, z, t)<span class="classifier">Matrix4x4</span></dt><dd><p>Returns a new matrix from <em>x</em>, <em>y</em>, <em>z</em> and <em>t</em>.</p>
  807. </dd>
  808. </dl>
  809. </section>
  810. <section id="id8">
  811. <h4>Functions<a class="headerlink" href="#id8" title="Permalink to this headline">¶</a></h4>
  812. <dl class="simple">
  813. <dt><strong>copy</strong> (m)<span class="classifier">Matrix4x4</span></dt><dd><p>Returns a copy of the matrix <em>m</em>.</p>
  814. </dd>
  815. <dt><strong>add</strong> (a, b)<span class="classifier">Matrix4x4</span></dt><dd><p>Adds the matrix <em>a</em> to <em>b</em> and returns the result.</p>
  816. </dd>
  817. <dt><strong>subtract</strong> (a, b)<span class="classifier">Matrix4x4</span></dt><dd><p>Subtracts the matrix <em>b</em> from <em>a</em> and returns the result.</p>
  818. </dd>
  819. <dt><strong>multiply</strong> (a, b)<span class="classifier">Matrix4x4</span></dt><dd><p>Multiplies the matrix <em>a</em> by <em>b</em> and returns the result. (i.e. transforms first by <em>a</em> then by <em>b</em>)</p>
  820. </dd>
  821. <dt><strong>equal</strong> (a, b)<span class="classifier">bool</span></dt><dd><p>Returns true whether the matrices <em>a</em> and <em>b</em> are equal.</p>
  822. </dd>
  823. <dt><strong>transpose</strong> (m)<span class="classifier">Matrix4x4</span></dt><dd><p>Transposes the matrix <em>m</em> and returns the result.</p>
  824. </dd>
  825. <dt><strong>invert</strong> (m)<span class="classifier">Matrix4x4</span></dt><dd><p>Inverts the matrix <em>m</em> and returns the result.</p>
  826. </dd>
  827. <dt><strong>x</strong> (m)<span class="classifier">Vector3</span></dt><dd><p>Returns the x axis of the matrix <em>m</em>.</p>
  828. </dd>
  829. <dt><strong>y</strong> (m)<span class="classifier">Vector3</span></dt><dd><p>Returns the y axis of the matrix <em>m</em>.</p>
  830. </dd>
  831. <dt><strong>z</strong> (m)<span class="classifier">Vector3</span></dt><dd><p>Returns the z axis of the matrix <em>m</em>.</p>
  832. </dd>
  833. <dt><strong>set_x</strong> (m, x)</dt><dd><p>Sets the x axis of the matrix <em>m</em>.</p>
  834. </dd>
  835. <dt><strong>set_y</strong> (m, y)</dt><dd><p>Sets the y axis of the matrix <em>m</em>.</p>
  836. </dd>
  837. <dt><strong>set_z</strong> (m, z)</dt><dd><p>Sets the z axis of the matrix <em>m</em>.</p>
  838. </dd>
  839. <dt><strong>translation</strong> (m)<span class="classifier">Vector3</span></dt><dd><p>Returns the translation portion of the matrix <em>m</em>.</p>
  840. </dd>
  841. <dt><strong>set_translation</strong> (m, t)</dt><dd><p>Sets the translation portion of the matrix <em>m</em>.</p>
  842. </dd>
  843. <dt><strong>rotation</strong> (m)<span class="classifier">Quaternion</span></dt><dd><p>Returns the rotation portion of the matrix <em>m</em>.</p>
  844. </dd>
  845. <dt><strong>set_rotation</strong> (m, r)</dt><dd><p>Sets the rotation portion of the matrix <em>m</em>.</p>
  846. </dd>
  847. <dt><strong>scale</strong> (m)<span class="classifier">Vector3</span></dt><dd><p>Returns the scale of the matrix <em>m</em>.</p>
  848. </dd>
  849. <dt><strong>set_scale</strong> (m, r)</dt><dd><p>Sets the scale of the matrix <em>m</em>.</p>
  850. </dd>
  851. <dt><strong>identity</strong> ()</dt><dd><p>Returns the identity matrix.</p>
  852. </dd>
  853. <dt><strong>transform</strong> (m, v)<span class="classifier">Vector3</span></dt><dd><p>Transforms the vector <em>v</em> by the matrix <em>m</em> and returns the result.</p>
  854. </dd>
  855. <dt><strong>to_string</strong> (m)<span class="classifier">string</span></dt><dd><p>Returns a string representing the matrix <em>m</em>.</p>
  856. </dd>
  857. </dl>
  858. </section>
  859. </section>
  860. <section id="matrix4x4box">
  861. <h3>Matrix4x4Box<a class="headerlink" href="#matrix4x4box" title="Permalink to this headline">¶</a></h3>
  862. <section id="id9">
  863. <h4>Constructors<a class="headerlink" href="#id9" title="Permalink to this headline">¶</a></h4>
  864. <dl class="simple">
  865. <dt><strong>Matrix4x4Box</strong> ()<span class="classifier">Matrix4x4Box</span></dt><dd><p>Returns a new Matrix4x4Box initialized with the identity matrix.</p>
  866. </dd>
  867. <dt><strong>Matrix4x4Box</strong> (m)<span class="classifier">Matrix4x4Box</span></dt><dd><p>Returns a new Matrix4x4Box from the Matrix4x4 <em>m</em>.</p>
  868. </dd>
  869. </dl>
  870. </section>
  871. <section id="id10">
  872. <h4>Functions<a class="headerlink" href="#id10" title="Permalink to this headline">¶</a></h4>
  873. <dl class="simple">
  874. <dt><strong>store</strong> (m)</dt><dd><p>Stores the Matrix4x4 <em>m</em> in the box.</p>
  875. </dd>
  876. <dt><strong>unbox</strong> ()<span class="classifier">Matrix4x4</span></dt><dd><p>Returns the stored matrix from the box.</p>
  877. </dd>
  878. </dl>
  879. </section>
  880. </section>
  881. <section id="color4">
  882. <h3>Color4<a class="headerlink" href="#color4" title="Permalink to this headline">¶</a></h3>
  883. <section id="id11">
  884. <h4>Constructors<a class="headerlink" href="#id11" title="Permalink to this headline">¶</a></h4>
  885. <dl class="simple">
  886. <dt><strong>Color4</strong> (r, g, b, a)<span class="classifier">Color4</span></dt><dd><p>Returns a new Color4 from individual elements.</p>
  887. </dd>
  888. </dl>
  889. </section>
  890. <section id="id12">
  891. <h4>Functions<a class="headerlink" href="#id12" title="Permalink to this headline">¶</a></h4>
  892. <dl class="simple">
  893. <dt><strong>lerp</strong> (a, b, t)<span class="classifier">Color4</span></dt><dd><p>Returns the linearly interpolated color between <em>a</em> and <em>b</em> at time <em>t</em> in [0, 1].</p>
  894. </dd>
  895. </dl>
  896. <div class="line-block">
  897. <div class="line"><strong>black</strong> () : Color4</div>
  898. <div class="line"><strong>white</strong> () : Color4</div>
  899. <div class="line"><strong>red</strong> () : Color4</div>
  900. <div class="line"><strong>green</strong> () : Color4</div>
  901. <div class="line"><strong>blue</strong> () : Color4</div>
  902. <div class="line"><strong>yellow</strong> () : Color4</div>
  903. <div class="line"><strong>orange</strong> () : Color4</div>
  904. <div class="line-block">
  905. <div class="line">Returns the corresponding mnemonic color.</div>
  906. </div>
  907. </div>
  908. <dl class="simple">
  909. <dt><strong>to_string</strong> (c)<span class="classifier">string</span></dt><dd><p>Returns a string representing the color <em>c</em>.</p>
  910. </dd>
  911. </dl>
  912. </section>
  913. </section>
  914. <section id="id13">
  915. <h3>Math<a class="headerlink" href="#id13" title="Permalink to this headline">¶</a></h3>
  916. <dl class="simple">
  917. <dt><strong>ray_plane_intersection</strong> (from, dir, point, normal)<span class="classifier">float</span></dt><dd><p>Returns the distance along ray (from, dir) to intersection point with plane defined by
  918. <em>point</em> and <em>normal</em> or -1.0 if no intersection.</p>
  919. </dd>
  920. <dt><strong>ray_disc_intersection</strong> (from, dir, center, radius, normal)<span class="classifier">float</span></dt><dd><p>Returns the distance along ray (from, dir) to intersection point with disc defined by
  921. <em>center</em>, <em>radius</em> and <em>normal</em> or -1.0 if no intersection.</p>
  922. </dd>
  923. <dt><strong>ray_sphere_intersection</strong> (from, dir, center, radius)<span class="classifier">float</span></dt><dd><p>Returns the distance along ray (from, dir) to intersection point with sphere defined by
  924. <em>center</em> and <em>radius</em> or -1.0 if no intersection.</p>
  925. </dd>
  926. <dt><strong>ray_obb_intersection</strong> (from, dir, tm, half_extents)<span class="classifier">float</span></dt><dd><p>Returns the distance along ray (from, dir) to intersection point with the oriented
  927. bounding box (tm, half_extents) or -1.0 if no intersection.</p>
  928. </dd>
  929. <dt><strong>ray_triangle_intersection</strong> (from, dir, v0, v1, v2)<span class="classifier">float</span></dt><dd><p>Returns the distance along ray (from, dir) to intersection point with the triangle
  930. (v0, v1, v2) or -1.0 if no intersection.</p>
  931. </dd>
  932. <dt><strong>obb_intersects_frustum</strong> (obb_tm, obb_half_extents, n0, d0, n1, d1, n2, d2, n3, d3, n4, d4, n4, d5)<span class="classifier">bool</span></dt><dd><p>Returns whether the oriented bounding box (obb_tm, obb_half_extents) intersects
  933. the frustum defined by the planes ((n0, d0), (n1, d1), …, (n5, d5)). The
  934. planes be given in BRTLNF order, where B = bottom plane, R = right plane etc.</p>
  935. </dd>
  936. <dt><strong>obb_vertices</strong> (obb_tm, obb_half_extents)<span class="classifier">v0, v1, v2, v3, v4, v5, v6, v7</span></dt><dd><p>Returns the vertices of the oriented bounding box (obb_tm, obb_half_extents).</p>
  937. </dd>
  938. <dt><strong>obb_merge</strong> (a_tm, a_half_extents, b_tm, b_half_extents, …)<span class="classifier">Matrix4x4, Vector3</span></dt><dd><p>Returns a new box which encloses both the box A (a_tm, a_half_extents) and B
  939. (b_tm, b_half_extents) and any number of boxes after B.
  940. Note that the returned OBB will have the same orientation as A and won’t
  941. necessarily be the smallest enclosing box.</p>
  942. </dd>
  943. </dl>
  944. </section>
  945. </section>
  946. <section id="physicsworld">
  947. <h2>PhysicsWorld<a class="headerlink" href="#physicsworld" title="Permalink to this headline">¶</a></h2>
  948. <dl class="simple">
  949. <dt><strong>gravity</strong> (pw)<span class="classifier">Vector3</span></dt><dd><p>Returns the gravity.</p>
  950. </dd>
  951. <dt><strong>set_gravity</strong> (pw, gravity)</dt><dd><p>Sets the gravity.</p>
  952. </dd>
  953. <dt><strong>cast_ray</strong> (pw, from, dir, length)<span class="classifier">hit, collision_pos, normal, time, UnitId, Actor</span></dt><dd><p>Casts a ray into the physics world and returns the closest actor it intersects with.
  954. If <em>hit</em> is true the following return values contain the <em>collision_pos</em> in
  955. world space, the <em>normal</em> of the surface that was hit, the time of impact
  956. in [0..1] and the <em>unit</em> and the <em>actor</em> that was hit.</p>
  957. </dd>
  958. <dt><strong>cast_ray_all</strong> (pw, from, dir, length)<span class="classifier">table</span></dt><dd><p>Casts a ray into the physics world and returns all the
  959. actors it intersects with as an array of <a class="reference internal" href="#raycasthit">RaycastHit</a> tables.</p>
  960. </dd>
  961. <dt><strong>cast_sphere</strong> (pw, from, radius, dir, length)<span class="classifier">hit, collision_pos, normal, time, UnitId, Actor</span></dt><dd><p>Casts a sphere into the physics world and returns the closest actor it intersects with.
  962. If <em>hit</em> is true the following return values contain the <em>collision_pos</em> in
  963. world space, the <em>normal</em> of the surface that was hit, the time of impact
  964. in [0..1] and the <em>unit</em> and the <em>actor</em> that was hit.</p>
  965. </dd>
  966. <dt><strong>cast_box</strong> (pw, from, half_extents, dir, length)<span class="classifier">hit, collision_pos, normal, time, UnitId, Actor</span></dt><dd><p>Casts a box into the physics world and returns the closest actor it intersects with.
  967. If <em>hit</em> is true the following return values contain the <em>collision_pos</em> in
  968. world space, the <em>normal</em> of the surface that was hit, the time of impact
  969. in [0..1] and the <em>unit</em> and the <em>actor</em> that was hit.</p>
  970. </dd>
  971. <dt><strong>enable_debug_drawing</strong> (pw, enable)</dt><dd><p>Sets whether to <em>enable</em> debug drawing.</p>
  972. </dd>
  973. </dl>
  974. <section id="raycasthit">
  975. <h3>RaycastHit<a class="headerlink" href="#raycasthit" title="Permalink to this headline">¶</a></h3>
  976. <p>RaycastHit is a lua table with 5 fields:</p>
  977. <ul class="simple">
  978. <li><p><code class="docutils literal notranslate"><span class="pre">[1]</span></code>: The collision position in world space.</p></li>
  979. <li><p><code class="docutils literal notranslate"><span class="pre">[2]</span></code>: The normal of the surface that was hit.</p></li>
  980. <li><p><code class="docutils literal notranslate"><span class="pre">[3]</span></code>: The time of impact in [0..1].</p></li>
  981. <li><p><code class="docutils literal notranslate"><span class="pre">[4]</span></code>: The unit that was hit.</p></li>
  982. <li><p><code class="docutils literal notranslate"><span class="pre">[5]</span></code>: The actor that was hit.</p></li>
  983. </ul>
  984. </section>
  985. <section id="actor">
  986. <h3>Actor<a class="headerlink" href="#actor" title="Permalink to this headline">¶</a></h3>
  987. <dl>
  988. <dt><strong>actor_destroy</strong> (pw, actor)</dt><dd><p>Destroys the <em>actor</em> instance.</p>
  989. </dd>
  990. <dt><strong>actor_instance</strong> (pw, unit)<span class="classifier">Id</span></dt><dd><p>Returns the ID of the actor owned by the <em>unit</em>, or <code class="docutils literal notranslate"><span class="pre">nil</span></code>.</p>
  991. </dd>
  992. <dt><strong>actor_world_position</strong> (pw, actor)<span class="classifier">Vector3</span></dt><dd><p>Returns the world position of the <em>actor</em>.</p>
  993. </dd>
  994. <dt><strong>actor_world_rotation</strong> (pw, actor)<span class="classifier">Quaternion</span></dt><dd><p>Returns the world rotation of the <em>actor</em>.</p>
  995. </dd>
  996. <dt><strong>actor_world_pose</strong> (pw, actor)<span class="classifier">Matrix4x4</span></dt><dd><p>Returns the world pose of the <em>actor</em>.</p>
  997. </dd>
  998. <dt><strong>actor_teleport_world_position</strong> (pw, actor, position)</dt><dd><p>Teleports the <em>actor</em> to the given world <em>position</em>.</p>
  999. </dd>
  1000. <dt><strong>actor_teleport_world_rotation</strong> (pw, actor, rotation)</dt><dd><p>Teleports the <em>actor</em> to the given world <em>rotation</em>.</p>
  1001. </dd>
  1002. <dt><strong>actor_teleport_world_pose</strong> (pw, actor, pose)</dt><dd><p>Teleports the <em>actor</em> to the given world <em>pose</em>.</p>
  1003. </dd>
  1004. <dt><strong>actor_center_of_mass</strong> (pw, actor)<span class="classifier">Vector3</span></dt><dd><p>Returns the center of mass of the <em>actor</em>.</p>
  1005. </dd>
  1006. <dt><strong>actor_enable_gravity</strong> (pw, actor)</dt><dd><p>Enables gravity for the <em>actor</em>.</p>
  1007. </dd>
  1008. <dt><strong>actor_disable_gravity</strong> (pw, actor)</dt><dd><p>Disables gravity for the <em>actor</em>.</p>
  1009. </dd>
  1010. <dt><strong>actor_enable_collision</strong> (pw, actor)</dt><dd><p>Enables collision detection for the <em>actor</em>.</p>
  1011. </dd>
  1012. <dt><strong>actor_disable_collision</strong> (pw, actor)</dt><dd><p>Disables collision detection for the <em>actor</em>.</p>
  1013. </dd>
  1014. <dt><strong>actor_set_collision_filter</strong> (pw, actor, name)</dt><dd><p>Sets the collision filter of the <em>actor</em>.</p>
  1015. </dd>
  1016. <dt><strong>actor_set_kinematic</strong> (pw, actor, kinematic)</dt><dd><p>Sets whether the <em>actor</em> is <em>kinematic</em> or not.</p>
  1017. <div class="admonition note">
  1018. <p class="admonition-title">Note</p>
  1019. <p>This call has no effect on static actors.</p>
  1020. </div>
  1021. </dd>
  1022. <dt><strong>actor_is_static</strong> (pw, actor)<span class="classifier">bool</span></dt><dd><p>Returns whether the <em>actor</em> is static.</p>
  1023. </dd>
  1024. <dt><strong>actor_is_dynamic</strong> (pw, actor) bool</dt><dd><p>Returns whether the <em>actor</em> is dynamic.</p>
  1025. </dd>
  1026. <dt><strong>actor_is_kinematic</strong> (pw, actor)<span class="classifier">bool</span></dt><dd><p>Returns whether the <em>actor</em> is kinematic (keyframed).</p>
  1027. </dd>
  1028. <dt><strong>actor_is_nonkinematic</strong> (pw, actor)<span class="classifier">bool</span></dt><dd><p>Returns whether the <em>actor</em> is nonkinematic (i.e. dynamic and not kinematic).</p>
  1029. </dd>
  1030. <dt><strong>actor_linear_damping</strong> (pw, actor)<span class="classifier">float</span></dt><dd><p>Returns the linear damping of the <em>actor</em>.</p>
  1031. </dd>
  1032. <dt><strong>actor_set_linear_damping</strong> (pw, actor, damping)</dt><dd><p>Sets the linear <em>damping</em> of the <em>actor</em>.</p>
  1033. </dd>
  1034. <dt><strong>actor_angular_damping</strong> (pw, actor)<span class="classifier">float</span></dt><dd><p>Returns the angular damping rate of the <em>actor</em>.</p>
  1035. </dd>
  1036. <dt><strong>actor_set_angular_damping</strong> (pw, actor, rate)</dt><dd><p>Sets the angular damping <em>rate</em> of the <em>actor</em>.</p>
  1037. </dd>
  1038. <dt><strong>actor_linear_velocity</strong> (pw, actor)<span class="classifier">Vector3</span></dt><dd><p>Returns the linear velocity of the <em>actor</em>.</p>
  1039. </dd>
  1040. <dt><strong>actor_set_linear_velocity</strong> (pw, actor, velocity)</dt><dd><p>Sets the linear <em>velocity</em> of the <em>actor</em>.</p>
  1041. <div class="admonition note">
  1042. <p class="admonition-title">Note</p>
  1043. <p>This call only affects nonkinematic actors.</p>
  1044. </div>
  1045. </dd>
  1046. <dt><strong>actor_angular_velocity</strong> (pw, actor)<span class="classifier">Vector3</span></dt><dd><p>Returns the angular velocity of the <em>actor</em>.</p>
  1047. </dd>
  1048. <dt><strong>actor_set_angular_velocity</strong> (pw, actor, velocity)</dt><dd><p>Sets the angular <em>velocity</em> of the <em>actor</em>.</p>
  1049. <div class="admonition note">
  1050. <p class="admonition-title">Note</p>
  1051. <p>This call only affects nonkinematic actors.</p>
  1052. </div>
  1053. </dd>
  1054. <dt><strong>actor_add_impulse</strong> (pw, actor, impulse)</dt><dd><p>Adds a linear <em>impulse</em> (acting along the center of mass) to the <em>actor</em>.</p>
  1055. <div class="admonition note">
  1056. <p class="admonition-title">Note</p>
  1057. <p>This call only affects nonkinematic actors.</p>
  1058. </div>
  1059. </dd>
  1060. <dt><strong>actor_add_impulse_at</strong> (pw, actor, impulse, position)</dt><dd><p>Adds a linear <em>impulse</em> (acting along the world position <em>pos</em>) to the <em>actor</em>.</p>
  1061. <div class="admonition note">
  1062. <p class="admonition-title">Note</p>
  1063. <p>This call only affects nonkinematic actors.</p>
  1064. </div>
  1065. </dd>
  1066. <dt><strong>actor_add_torque_impulse</strong> (pw, actor, impulse)</dt><dd><p>Adds a torque <em>impulse</em> to the <em>actor</em>.</p>
  1067. </dd>
  1068. <dt><strong>actor_push</strong> (pw, actor, velocity, mass)</dt><dd><p>Pushes the <em>actor</em> as if it was hit by a point object with the given <em>mass</em>
  1069. travelling at the given <em>velocity</em>.</p>
  1070. <div class="admonition note">
  1071. <p class="admonition-title">Note</p>
  1072. <p>This call only affects nonkinematic actors.</p>
  1073. </div>
  1074. </dd>
  1075. <dt><strong>actor_push_at</strong> (pw, actor, velocity, mass, position)</dt><dd><p>Like push() but applies the force at the world <em>position</em>.</p>
  1076. <div class="admonition note">
  1077. <p class="admonition-title">Note</p>
  1078. <p>This call only affects nonkinematic actors.</p>
  1079. </div>
  1080. </dd>
  1081. <dt><strong>actor_is_sleeping</strong> (pw, actor)<span class="classifier">bool</span></dt><dd><p>Returns whether the <em>actor</em> is sleeping.</p>
  1082. </dd>
  1083. <dt><strong>actor_wake_up</strong> (pw, actor)</dt><dd><p>Wakes the <em>actor</em> up.</p>
  1084. </dd>
  1085. <dt><strong>actor_debug_draw</strong> (pw, actor, debug_line [, color])</dt><dd><p>Adds the <em>actor</em>’s debug geometry to <em>lines</em>.</p>
  1086. </dd>
  1087. </dl>
  1088. </section>
  1089. <section id="mover">
  1090. <h3>Mover<a class="headerlink" href="#mover" title="Permalink to this headline">¶</a></h3>
  1091. <dl class="simple">
  1092. <dt><strong>mover_create</strong> (pw, unit, height, radius, max_slope_angle, collision_filter)<span class="classifier">Id</span></dt><dd><p>Creates a new mover instance for the <em>unit</em>.</p>
  1093. </dd>
  1094. <dt><strong>mover_destroy</strong> (pw, mover)</dt><dd><p>Destroys the <em>mover</em>.</p>
  1095. </dd>
  1096. <dt><strong>mover</strong> (pw, unit)<span class="classifier">Id</span></dt><dd><p>Returns the ID of the mover owned by the <em>unit</em>.</p>
  1097. </dd>
  1098. <dt><strong>mover_set_height</strong> (pw, mover, height)</dt><dd><p>Sets the <em>height</em> of the <em>mover</em> capsule.</p>
  1099. </dd>
  1100. <dt><strong>mover_radius</strong> (pw, mover)<span class="classifier">number</span></dt><dd><p>Returns the radius of the <em>mover</em> capsule.</p>
  1101. </dd>
  1102. <dt><strong>mover_set_radius</strong> (pw, mover, radius)</dt><dd><p>Sets the <em>radius</em> of the <em>mover</em> capsule.</p>
  1103. </dd>
  1104. <dt><strong>mover_max_slope_angle</strong> (pw, mover)<span class="classifier">number</span></dt><dd><p>Returns the max slope angle of the <em>mover</em>.</p>
  1105. </dd>
  1106. <dt><strong>mover_set_max_slope_angle</strong> (pw, mover, angle)</dt><dd><p>Sets the max slope <em>angle</em> of the <em>mover</em>.</p>
  1107. </dd>
  1108. <dt><strong>mover_set_collision_filter</strong> (pw, mover, filter)</dt><dd><p>Sets the collision <em>filter</em> of the <em>mover</em>.</p>
  1109. </dd>
  1110. <dt><strong>mover_position</strong> (pw, mover)<span class="classifier">Vector3</span></dt><dd><p>Returns the position of the <em>mover</em>.</p>
  1111. </dd>
  1112. <dt><strong>mover_set_position</strong> (pw, mover, position)</dt><dd><p>Teleports the <em>mover</em> to the specified <em>position</em>.</p>
  1113. </dd>
  1114. <dt><strong>mover_center</strong> (pw, mover)<span class="classifier">Vector3</span></dt><dd><p>Returns the center of the <em>mover</em> relative to the transform’s position.</p>
  1115. </dd>
  1116. <dt><strong>mover_set_center</strong> (pw, mover, center)</dt><dd><p>Sets the center of the <em>mover</em> relative to the transform’s position.</p>
  1117. </dd>
  1118. <dt><strong>mover_move</strong> (pw, mover, delta)</dt><dd><p>Attempts to move the <em>mover</em> by the specified <em>delta</em> vector.
  1119. The <em>mover</em> will slide against physical actors.</p>
  1120. </dd>
  1121. <dt><strong>mover_collides_sides</strong> (pw, mover)<span class="classifier">bool</span></dt><dd><p>Returns whether the <em>mover</em> collides sideways.</p>
  1122. </dd>
  1123. <dt><strong>mover_collides_up</strong> (pw, mover)<span class="classifier">bool</span></dt><dd><p>Returns whether the <em>mover</em> collides upwards.</p>
  1124. </dd>
  1125. <dt><strong>mover_collides_down</strong> (pw, mover)<span class="classifier">bool</span></dt><dd><p>Returns whether the <em>mover</em> collides downwards.</p>
  1126. </dd>
  1127. <dt><strong>mover_debug_draw</strong> (pw, mover, debug_line [, color])</dt><dd><p>Adds the <em>mover</em>’s debug geometry to <em>lines</em>.</p>
  1128. </dd>
  1129. </dl>
  1130. </section>
  1131. </section>
  1132. <section id="profiler">
  1133. <h2>Profiler<a class="headerlink" href="#profiler" title="Permalink to this headline">¶</a></h2>
  1134. <dl class="simple">
  1135. <dt><strong>enter_scope</strong> (name)</dt><dd><p>Starts a new profile scope with the given <em>name</em>.</p>
  1136. </dd>
  1137. <dt><strong>leave_scope</strong> ()</dt><dd><p>Ends the last profile scope.</p>
  1138. </dd>
  1139. <dt><strong>record</strong> (name, value)</dt><dd><p>Records <em>value</em> with the given <em>name</em>. Value can be either number or Vector3.</p>
  1140. </dd>
  1141. </dl>
  1142. </section>
  1143. <section id="renderworld">
  1144. <h2>RenderWorld<a class="headerlink" href="#renderworld" title="Permalink to this headline">¶</a></h2>
  1145. <dl class="simple">
  1146. <dt><strong>enable_debug_drawing</strong> (rw, enable)</dt><dd><p>Sets whether to <em>enable</em> debug drawing.</p>
  1147. </dd>
  1148. </dl>
  1149. <section id="mesh">
  1150. <h3>Mesh<a class="headerlink" href="#mesh" title="Permalink to this headline">¶</a></h3>
  1151. <dl class="simple">
  1152. <dt><strong>mesh_create</strong> (rw, unit, mesh_resource, geometry_name, material_resource, visible)<span class="classifier">Id</span></dt><dd><p>Creates a new mesh instance for <em>unit</em> and returns its id.</p>
  1153. </dd>
  1154. <dt><strong>mesh_destroy</strong> (rw, mesh)</dt><dd><p>Destroys the <em>mesh</em> instance.</p>
  1155. </dd>
  1156. <dt><strong>mesh_instance</strong> (rw, unit)<span class="classifier">Id</span></dt><dd><p>Returns the ID of the mesh owned by the <em>unit</em>, or <code class="docutils literal notranslate"><span class="pre">nil</span></code>.</p>
  1157. </dd>
  1158. <dt><strong>mesh_material</strong> (rw, mesh)<span class="classifier">Material</span></dt><dd><p>Returns the material of the <em>mesh</em>.</p>
  1159. </dd>
  1160. <dt><strong>mesh_set_material</strong> (rw, mesh, material)</dt><dd><p>Sets the <em>material</em> of the <em>mesh</em>.</p>
  1161. </dd>
  1162. <dt><strong>mesh_set_visible</strong> (rw, mesh, visible)</dt><dd><p>Sets whether the <em>mesh</em> is <em>visible</em>.</p>
  1163. </dd>
  1164. <dt><strong>mesh_set_cast_shadows</strong> (rw, mesh, cast_shadows)</dt><dd><p>Sets whether the <em>mesh</em> cast shadows.</p>
  1165. </dd>
  1166. <dt><strong>mesh_obb</strong> (rw, mesh)<span class="classifier">Matrix4x4, Vector3</span></dt><dd><p>Returns the Oriented-Bounding-Box of the <em>mesh</em> as (pose, half_extents).</p>
  1167. </dd>
  1168. <dt><strong>mesh_cast_ray</strong> (rw, mesh, from, dir)<span class="classifier">float</span></dt><dd><p>Returns the distance along ray (from, dir) to intersection point with the <em>mesh</em> or -1.0 if no intersection.</p>
  1169. </dd>
  1170. </dl>
  1171. </section>
  1172. <section id="sprite">
  1173. <h3>Sprite<a class="headerlink" href="#sprite" title="Permalink to this headline">¶</a></h3>
  1174. <dl class="simple">
  1175. <dt><strong>sprite_create</strong> (rw, unit, sprite_resource, material_resource, visible)<span class="classifier">Id</span></dt><dd><p>Creates a new sprite instance for the <em>unit</em> and returns its id.</p>
  1176. </dd>
  1177. <dt><strong>sprite_destroy</strong> (rw, sprite)</dt><dd><p>Destroys the <em>sprite</em> instance.</p>
  1178. </dd>
  1179. <dt><strong>sprite_instance</strong> (rw, unit)<span class="classifier">Id</span></dt><dd><p>Returns the ID of the sprite owned by the <em>unit</em>, or <code class="docutils literal notranslate"><span class="pre">nil</span></code>.</p>
  1180. </dd>
  1181. <dt><strong>sprite_material</strong> (rw, sprite)<span class="classifier">Material</span></dt><dd><p>Returns the material of the <em>sprite</em>.</p>
  1182. </dd>
  1183. <dt><strong>sprite_set_material</strong> (rw, sprite, material)</dt><dd><p>Sets the <em>material</em> of the <em>sprite</em>.</p>
  1184. </dd>
  1185. <dt><strong>sprite_set_frame</strong> (rw, sprite, index)</dt><dd><p>Sets the frame <em>index</em> of the <em>sprite</em>.
  1186. The <em>index</em> automatically wraps if it greater than the total number of
  1187. frames in the sprite.</p>
  1188. </dd>
  1189. <dt><strong>sprite_set_visible</strong> (rw, sprite, visible)</dt><dd><p>Sets whether the <em>sprite</em> is <em>visible</em>.</p>
  1190. </dd>
  1191. <dt><strong>sprite_flip_x</strong> (rw, sprite, flip)</dt><dd><p>Sets whether to flip the <em>sprite</em> on the x-axis.</p>
  1192. </dd>
  1193. <dt><strong>sprite_flip_y</strong> (rw, sprite, flip)</dt><dd><p>Sets whether to flip the <em>sprite</em> on the y-axis.</p>
  1194. </dd>
  1195. <dt><strong>sprite_set_layer</strong> (rw, sprite, layer)</dt><dd><p>Sets the rendering <em>layer</em> of the <em>sprite</em>.</p>
  1196. </dd>
  1197. <dt><strong>sprite_set_depth</strong> (rw, sprite, depth)</dt><dd><p>Sets the rendering <em>depth</em> of the <em>sprite</em>.</p>
  1198. </dd>
  1199. <dt><strong>sprite_obb</strong> (rw, sprite)<span class="classifier">Matrix4x4, Vector3</span></dt><dd><p>Returns the Oriented-Bounding-Box of the <em>sprite</em> as (pose, half_extents).</p>
  1200. </dd>
  1201. <dt><strong>sprite_cast_ray</strong> (rw, sprite, from, dir)<span class="classifier">float, int, int</span></dt><dd><p>Returns (t, layer, depth), where <em>t</em> is the distance along ray (from, dir) to
  1202. intersection point with the <em>sprite</em> or -1.0 if no intersection.</p>
  1203. </dd>
  1204. </dl>
  1205. </section>
  1206. <section id="light">
  1207. <h3>Light<a class="headerlink" href="#light" title="Permalink to this headline">¶</a></h3>
  1208. <dl class="simple">
  1209. <dt><strong>light_create</strong> (rw, unit, type, range, intensity, spot_angle, color)<span class="classifier">Id</span></dt><dd><p>Creates a new light for the <em>unit</em> and returns its id.
  1210. Type can be either <code class="docutils literal notranslate"><span class="pre">directional</span></code>, <code class="docutils literal notranslate"><span class="pre">omni</span></code> or <code class="docutils literal notranslate"><span class="pre">spot</span></code>.</p>
  1211. </dd>
  1212. <dt><strong>light_destroy</strong> (rw, light)</dt><dd><p>Destroys the <em>light</em> instance.</p>
  1213. </dd>
  1214. <dt><strong>light_instance</strong> (rw, unit)<span class="classifier">Id</span></dt><dd><p>Returns the ID of the light owned by the <em>unit</em>, or <code class="docutils literal notranslate"><span class="pre">nil</span></code>.</p>
  1215. </dd>
  1216. <dt><strong>light_type</strong> (rw, light)<span class="classifier">string</span></dt><dd><p>Returns the type of the <em>light</em>.
  1217. It can be either <code class="docutils literal notranslate"><span class="pre">directional</span></code>, <code class="docutils literal notranslate"><span class="pre">omni</span></code> or <code class="docutils literal notranslate"><span class="pre">spot</span></code>.</p>
  1218. </dd>
  1219. <dt><strong>light_color</strong> (rw, light)<span class="classifier">Color4</span></dt><dd><p>Returns the color of the <em>light</em>.</p>
  1220. </dd>
  1221. <dt><strong>light_range</strong> (rw, light)<span class="classifier">float</span></dt><dd><p>Returns the range of the <em>light</em>.</p>
  1222. </dd>
  1223. <dt><strong>light_intensity</strong> (rw, light)<span class="classifier">float</span></dt><dd><p>Returns the intensity of the <em>light</em>.</p>
  1224. </dd>
  1225. <dt><strong>light_spot_angle</strong> (rw, light)<span class="classifier">float</span></dt><dd><p>Returns the spot angle of the <em>light</em>.</p>
  1226. </dd>
  1227. <dt><strong>light_shadow_bias</strong> (rw, light)<span class="classifier">float</span></dt><dd><p>Returns the shadow bias of the <em>light</em>.</p>
  1228. </dd>
  1229. <dt><strong>light_set_type</strong> (rw, light, type)</dt><dd><p>Sets the <em>type</em> of the <em>light</em>.</p>
  1230. </dd>
  1231. <dt><strong>light_set_color</strong> (rw, light, color)</dt><dd><p>Sets the <em>color</em> of the <em>light</em>.</p>
  1232. </dd>
  1233. <dt><strong>light_set_range</strong> (rw, light, range)</dt><dd><p>Sets the <em>range</em> of the <em>light</em>.</p>
  1234. </dd>
  1235. <dt><strong>light_set_intensity</strong> (rw, light, intensity)</dt><dd><p>Sets the <em>intensity</em> of the <em>light</em>.</p>
  1236. </dd>
  1237. <dt><strong>light_set_spot_angle</strong> (rw, light, angle)</dt><dd><p>Sets the spot <em>angle</em> of the <em>light</em>.</p>
  1238. </dd>
  1239. <dt><strong>light_set_shadow_bias</strong> (rw, light, bias)</dt><dd><p>Sets the shadow <em>bias</em> of the <em>light</em>.</p>
  1240. </dd>
  1241. <dt><strong>light_set_cast_shadows</strong> (rw, light, cast_shadows)</dt><dd><p>Sets whether the <em>light</em> casts shadows.</p>
  1242. </dd>
  1243. <dt><strong>light_debug_draw</strong> (rw, light, debug_line)</dt><dd><p>Fills <em>debug_line</em> with debug lines from the <em>light</em>.</p>
  1244. </dd>
  1245. </dl>
  1246. </section>
  1247. <section id="fog">
  1248. <h3>Fog<a class="headerlink" href="#fog" title="Permalink to this headline">¶</a></h3>
  1249. <dl class="simple">
  1250. <dt><strong>fog_create</strong> (rw, unit)<span class="classifier">Id</span></dt><dd><p>Creates a new fog instance for the <em>unit</em> and returns its id.
  1251. Note that the fog component is limited to one instance per World. Every call
  1252. to this function will overwrite any previously created fog instance.</p>
  1253. </dd>
  1254. <dt><strong>fog_destroy</strong> (rw, fog)</dt><dd><p>Destroys the <em>fog</em> instance.</p>
  1255. </dd>
  1256. <dt><strong>fog_instance</strong> (rw, unit)<span class="classifier">Id</span></dt><dd><p>Returns the ID of the fog owned by the <em>unit</em>, or <code class="docutils literal notranslate"><span class="pre">nil</span></code>.</p>
  1257. </dd>
  1258. <dt><strong>fog_set_color</strong> (rw, fog, color)</dt><dd><p>Sets the <em>color</em> of the <em>fog</em>.</p>
  1259. </dd>
  1260. <dt><strong>fog_set_density</strong> (rw, fog, density)</dt><dd><p>Sets the <em>density</em> of the <em>fog</em>.</p>
  1261. </dd>
  1262. <dt><strong>fog_set_range_min</strong> (rw, fog, range)</dt><dd><p>Sets the minimum <em>range</em> of the <em>fog</em>.</p>
  1263. </dd>
  1264. <dt><strong>fog_set_range_max</strong> (rw, fog, range)</dt><dd><p>Sets the maximum <em>range</em> of the <em>fog</em>.</p>
  1265. </dd>
  1266. <dt><strong>fog_set_sun_blend</strong> (rw, fog, sun_blend)</dt><dd><p>Sets the sun <em>blend</em> of the <em>fog</em>.</p>
  1267. </dd>
  1268. <dt><strong>fog_set_enabled</strong> (rw, fog, enable)</dt><dd><p>Sets whether the <em>fog</em> is <em>enabled</em>.</p>
  1269. </dd>
  1270. </dl>
  1271. </section>
  1272. </section>
  1273. <section id="resourcepackage">
  1274. <h2>ResourcePackage<a class="headerlink" href="#resourcepackage" title="Permalink to this headline">¶</a></h2>
  1275. <dl>
  1276. <dt><strong>load</strong> (package)</dt><dd><p>Loads all the resources in the <em>package</em>.</p>
  1277. <div class="admonition note">
  1278. <p class="admonition-title">Note</p>
  1279. <p>The resources are not immediately available after the call is made,
  1280. instead, you have to poll for completion with has_loaded().</p>
  1281. </div>
  1282. </dd>
  1283. <dt><strong>unload</strong> (package)</dt><dd><p>Unloads all the resources in the <em>package</em>.</p>
  1284. </dd>
  1285. <dt><strong>flush</strong> (package)</dt><dd><p>Waits until the <em>package</em> has been loaded.</p>
  1286. </dd>
  1287. <dt><strong>has_loaded</strong> (package)<span class="classifier">bool</span></dt><dd><p>Returns whether the <em>package</em> has been loaded.</p>
  1288. </dd>
  1289. </dl>
  1290. </section>
  1291. <section id="scenegraph">
  1292. <h2>SceneGraph<a class="headerlink" href="#scenegraph" title="Permalink to this headline">¶</a></h2>
  1293. <dl class="simple">
  1294. <dt><strong>create</strong> (sg, unit, position, rotation, scale)<span class="classifier">Id</span></dt><dd><p>Creates the transform for the <em>unit</em> and returns its ID.</p>
  1295. </dd>
  1296. <dt><strong>destroy</strong> (sg, transform)</dt><dd><p>Destroys the <em>transform</em> instance.</p>
  1297. </dd>
  1298. <dt><strong>instance</strong> (sg, unit)<span class="classifier">Id</span></dt><dd><p>Returns the ID of the transform owned by the <em>unit</em>, or <code class="docutils literal notranslate"><span class="pre">nil</span></code>.</p>
  1299. </dd>
  1300. <dt><strong>owner</strong> (sg, transform)<span class="classifier">UnitId</span></dt><dd><p>Returns the unit that owns <em>transform</em>.</p>
  1301. </dd>
  1302. <dt><strong>local_position</strong> (sg, transform)<span class="classifier">Vector3</span></dt><dd><p>Returns the local position of the <em>transform</em>.</p>
  1303. </dd>
  1304. <dt><strong>local_rotation</strong> (sg, transform)<span class="classifier">Quaternion</span></dt><dd><p>Returns the local rotation of the <em>transform</em>.</p>
  1305. </dd>
  1306. <dt><strong>local_scale</strong> (sg, transform)<span class="classifier">Vector3</span></dt><dd><p>Returns the local scale of the <em>transform</em>.</p>
  1307. </dd>
  1308. <dt><strong>local_pose</strong> (sg, transform)<span class="classifier">Matrix4x4</span></dt><dd><p>Returns the local pose of the <em>transform</em>.</p>
  1309. </dd>
  1310. <dt><strong>world_position</strong> (sg, transform)<span class="classifier">Vector3</span></dt><dd><p>Returns the world position of the <em>transform</em>.</p>
  1311. </dd>
  1312. <dt><strong>world_rotation</strong> (sg, transform)<span class="classifier">Quaternion</span></dt><dd><p>Returns the world rotation of the <em>transform</em>.</p>
  1313. </dd>
  1314. <dt><strong>world_pose</strong> (sg, transform)<span class="classifier">Matrix4x4</span></dt><dd><p>Returns the world pose of the <em>transform</em>.</p>
  1315. </dd>
  1316. <dt><strong>set_local_position</strong> (sg, transform, position)</dt><dd><p>Sets the local <em>position</em> of the <em>transform</em>.</p>
  1317. </dd>
  1318. <dt><strong>set_local_rotation</strong> (sg, transform, rotation)</dt><dd><p>Sets the local <em>rotation</em> of the <em>transform</em>.</p>
  1319. </dd>
  1320. <dt><strong>set_local_scale</strong> (sg, transform, scale)</dt><dd><p>Sets the local <em>scale</em> of the <em>transform</em>.</p>
  1321. </dd>
  1322. <dt><strong>set_local_pose</strong> (sg, transform, pose)</dt><dd><p>Sets the local <em>pose</em> of the <em>transform</em>.</p>
  1323. </dd>
  1324. <dt><strong>link</strong> (sg, parent, child, child_local_position, child_local_rotation, child_local_scale)</dt><dd><p>Links <em>child</em> to <em>parent</em>. After linking the child will follow its
  1325. parent. Set child_local_* to modify the child position after it has been
  1326. linked to the parent, otherwise che child will be positioned at the
  1327. location of its parent.</p>
  1328. </dd>
  1329. <dt><strong>unlink</strong> (sg, child)</dt><dd><p>Unlinks <em>child</em> from its parent if it has any. After unlinking, the local
  1330. pose of the <em>child</em> is set to its previous world pose.</p>
  1331. </dd>
  1332. <dt><strong>parent</strong> (sg, child)<span class="classifier">Id</span></dt><dd><p>Returns the parent of the instance <em>child</em> or <code class="docutils literal notranslate"><span class="pre">nil</span></code>
  1333. if <em>child</em> has no parent.</p>
  1334. </dd>
  1335. <dt><strong>first_child</strong> (sg, parent)<span class="classifier">Id</span></dt><dd><p>Returns the first child of the instance <em>parent</em> or <code class="docutils literal notranslate"><span class="pre">nil</span></code>
  1336. if <em>parent</em> has no children.</p>
  1337. </dd>
  1338. <dt><strong>next_sibling</strong> (sg, child)<span class="classifier">Id</span></dt><dd><p>Returns the next sibling of the instance <em>child</em> or <code class="docutils literal notranslate"><span class="pre">nil</span></code>
  1339. if <em>child</em> has no sibling.</p>
  1340. </dd>
  1341. </dl>
  1342. </section>
  1343. <section id="soundworld">
  1344. <h2>SoundWorld<a class="headerlink" href="#soundworld" title="Permalink to this headline">¶</a></h2>
  1345. <dl class="simple">
  1346. <dt><strong>stop_all</strong> (sound_world)</dt><dd><p>Stops all the sounds in the world.</p>
  1347. </dd>
  1348. <dt><strong>pause_all</strong> (sound_world)</dt><dd><p>Pauses all the sounds in the world</p>
  1349. </dd>
  1350. <dt><strong>resume_all</strong> (sound_world)</dt><dd><p>Resumes all previously paused sounds in the world.</p>
  1351. </dd>
  1352. <dt><strong>is_playing</strong> (sound_world, id)<span class="classifier">bool</span></dt><dd><p>Returns whether the sound <em>id</em> is playing.</p>
  1353. </dd>
  1354. <dt><strong>set_group_volume</strong> (sound_world, group, volume)</dt><dd><p>Sets the <em>volume</em> of the sound <em>group</em>. The volume of the sounds within
  1355. <em>group</em> is multiplied by the group’s volume.</p>
  1356. </dd>
  1357. </dl>
  1358. </section>
  1359. <section id="unitmanager">
  1360. <h2>UnitManager<a class="headerlink" href="#unitmanager" title="Permalink to this headline">¶</a></h2>
  1361. <dl class="simple">
  1362. <dt><strong>create</strong> ([world])<span class="classifier">UnitId</span></dt><dd><p>Creates a new empty unit. If <em>world</em> is specified, the unit will be owned by
  1363. that world.</p>
  1364. </dd>
  1365. <dt><strong>destroy</strong> (unit)</dt><dd><p>Destroys the given <em>unit</em>.</p>
  1366. </dd>
  1367. <dt><strong>alive</strong> (unit)<span class="classifier">bool</span></dt><dd><p>Returns whether the unit is alive.</p>
  1368. </dd>
  1369. </dl>
  1370. </section>
  1371. <section id="window">
  1372. <h2>Window<a class="headerlink" href="#window" title="Permalink to this headline">¶</a></h2>
  1373. <dl class="simple">
  1374. <dt><strong>show</strong> ()</dt><dd><p>Shows the window.</p>
  1375. </dd>
  1376. <dt><strong>hide</strong> ()</dt><dd><p>Hides the window.</p>
  1377. </dd>
  1378. <dt><strong>resize</strong> (width, height)</dt><dd><p>Resizes the window to <em>width</em> and <em>height</em>.</p>
  1379. </dd>
  1380. <dt><strong>move</strong> (x, y)</dt><dd><p>Moves the window to <em>x</em> and <em>y</em>.</p>
  1381. </dd>
  1382. <dt><strong>minimize</strong> ()</dt><dd><p>Minimizes the window.</p>
  1383. </dd>
  1384. <dt><strong>maximize</strong> ()</dt><dd><p>Maximizes the window.</p>
  1385. </dd>
  1386. <dt><strong>restore</strong> ()</dt><dd><p>Restores the window.</p>
  1387. </dd>
  1388. <dt><strong>title</strong> ()<span class="classifier">string</span></dt><dd><p>Returns the title of the window.</p>
  1389. </dd>
  1390. <dt><strong>set_title</strong> (title)</dt><dd><p>Sets the title of the window.</p>
  1391. </dd>
  1392. <dt><strong>show_cursor</strong> (show)</dt><dd><p>Sets whether to <em>show</em> the cursor.</p>
  1393. </dd>
  1394. <dt><strong>set_fullscreen</strong> (fullscreen)</dt><dd><p>Sets whether the window is <em>fullscreen</em>.</p>
  1395. </dd>
  1396. <dt><strong>set_cursor</strong> (cursor)</dt><dd><p>Sets the mouse <em>cursor</em> on this window. Cursor can be any of <code class="docutils literal notranslate"><span class="pre">arrow</span></code>,
  1397. <code class="docutils literal notranslate"><span class="pre">hand</span></code>, <code class="docutils literal notranslate"><span class="pre">text_input</span></code>, <code class="docutils literal notranslate"><span class="pre">corner_top_left</span></code>, <code class="docutils literal notranslate"><span class="pre">corner_top_right</span></code>,
  1398. <code class="docutils literal notranslate"><span class="pre">corner_bottom_left</span></code>, <code class="docutils literal notranslate"><span class="pre">corner_bottom_right</span></code>, <code class="docutils literal notranslate"><span class="pre">size_horizontal</span></code>,
  1399. <code class="docutils literal notranslate"><span class="pre">size_vertical</span></code> or <code class="docutils literal notranslate"><span class="pre">wait</span></code>.</p>
  1400. </dd>
  1401. <dt><strong>set_cursor_mode</strong> (mode)</dt><dd><p>Sets the mouse cursor <em>mode</em> on this window. Mode can be either <code class="docutils literal notranslate"><span class="pre">normal</span></code>
  1402. or <code class="docutils literal notranslate"><span class="pre">disabled</span></code>. Setting the mode to <code class="docutils literal notranslate"><span class="pre">disabled</span></code> hides the cursor and
  1403. automatically re-centers it every time it is moved.</p>
  1404. </dd>
  1405. </dl>
  1406. </section>
  1407. <section id="world">
  1408. <h2>World<a class="headerlink" href="#world" title="Permalink to this headline">¶</a></h2>
  1409. <dl class="simple">
  1410. <dt><strong>spawn_unit</strong> (world, name, [position, rotation, scale])<span class="classifier">UnitId</span></dt><dd><p>Spawns a new instance of the unit <em>name</em> at the given <em>position</em>, <em>rotation</em> and <em>scale</em>.</p>
  1411. </dd>
  1412. <dt><strong>spawn_empty_unit</strong> (world)<span class="classifier">UnitId</span></dt><dd><p>Spawns a new empty unit and returns its id.</p>
  1413. </dd>
  1414. <dt><strong>destroy_unit</strong> (world, unit)</dt><dd><p>Destroys the given <em>unit</em>.</p>
  1415. </dd>
  1416. <dt><strong>num_units</strong> (world)<span class="classifier">int</span></dt><dd><p>Returns the number of units in the <em>world</em>.</p>
  1417. </dd>
  1418. <dt><strong>units</strong> (world)<span class="classifier">table</span></dt><dd><p>Returns all the the units in the world in a table.</p>
  1419. </dd>
  1420. <dt><strong>unit_by_name</strong> (world, name)<span class="classifier">UnitId</span></dt><dd><p>Returns the unit with the given Level Editor <em>name</em> or <code class="docutils literal notranslate"><span class="pre">nil</span></code> if no such unit is found.
  1421. If there are multiple units with the same name, a random one will be returned.</p>
  1422. </dd>
  1423. <dt><strong>update_animations</strong> (world, dt)</dt><dd><p>Update all animations with <em>dt</em>.</p>
  1424. </dd>
  1425. <dt><strong>update_scene</strong> (world, dt)</dt><dd><p>Updates the scene with <em>dt</em>.</p>
  1426. </dd>
  1427. <dt><strong>update</strong> (world, dt)</dt><dd><p>Updates the world with <em>dt</em>.</p>
  1428. </dd>
  1429. <dt><strong>create_debug_line</strong> (world, depth_test)<span class="classifier">DebugLine</span></dt><dd><p>Creates a new DebugLine. <em>depth_test</em> controls whether to
  1430. enable depth test when rendering the lines.</p>
  1431. </dd>
  1432. <dt><strong>destroy_debug_line</strong> (world, line)</dt><dd><p>Destroys the debug <em>line</em>.</p>
  1433. </dd>
  1434. <dt><strong>create_screen_gui</strong> (world)<span class="classifier">Gui</span></dt><dd><p>Creates a new Gui for 2D drawing.</p>
  1435. </dd>
  1436. <dt><strong>create_world_gui</strong> (world)<span class="classifier">Gui</span></dt><dd><p>Creates a new Gui for 3D drawing.</p>
  1437. </dd>
  1438. <dt><strong>destroy_gui</strong> (world, gui)</dt><dd><p>Destroys the <em>gui</em>.</p>
  1439. </dd>
  1440. <dt><strong>scene_graph</strong> (world)<span class="classifier">SceneGraph</span></dt><dd><p>Returns the scene graph.</p>
  1441. </dd>
  1442. <dt><strong>render_world</strong> (world)<span class="classifier">RenderWorld</span></dt><dd><p>Returns the render sub-world.</p>
  1443. </dd>
  1444. <dt><strong>physics_world</strong> (world)<span class="classifier">PhysicsWorld</span></dt><dd><p>Returns the physics sub-world.</p>
  1445. </dd>
  1446. <dt><strong>sound_world</strong> (world)<span class="classifier">SoundWorld</span></dt><dd><p>Returns the sound sub-world.</p>
  1447. </dd>
  1448. <dt><strong>animation_state_machine</strong> (world)<span class="classifier">AnimationStateMachine</span></dt><dd><p>Returns the animation state machine.</p>
  1449. </dd>
  1450. </dl>
  1451. <section id="camera">
  1452. <h3>Camera<a class="headerlink" href="#camera" title="Permalink to this headline">¶</a></h3>
  1453. <dl class="simple">
  1454. <dt><strong>camera_create</strong> (world, unit, projection, fov, far_range, near_range)<span class="classifier">Id</span></dt><dd><p>Creates a new camera for <em>unit</em> and returns its id.
  1455. Projection can be either <code class="docutils literal notranslate"><span class="pre">orthographic</span></code> or <code class="docutils literal notranslate"><span class="pre">perspective</span></code>.</p>
  1456. </dd>
  1457. <dt><strong>camera_destroy</strong> (world, camera)</dt><dd><p>Destroys the <em>camera</em> instance.</p>
  1458. </dd>
  1459. <dt><strong>camera_instance</strong> (world, unit)<span class="classifier">Id</span></dt><dd><p>Returns the ID of the camera owned by the <em>unit</em>, or <code class="docutils literal notranslate"><span class="pre">nil</span></code>.</p>
  1460. </dd>
  1461. <dt><strong>camera_set_projection_type</strong> (world, camera, projection)</dt><dd><p>Sets the projection type of the <em>camera</em>.
  1462. Projection can be either <code class="docutils literal notranslate"><span class="pre">orthographic</span></code> or <code class="docutils literal notranslate"><span class="pre">perspective</span></code>.</p>
  1463. </dd>
  1464. <dt><strong>camera_projection_type</strong> (world, camera)<span class="classifier">string</span></dt><dd><p>Returns the projection type of the <em>camera</em>.
  1465. It can be either <code class="docutils literal notranslate"><span class="pre">orthographic</span></code> or <code class="docutils literal notranslate"><span class="pre">perspective</span></code>.</p>
  1466. </dd>
  1467. <dt><strong>camera_fov</strong> (world, camera)<span class="classifier">float</span></dt><dd><p>Returns the field-of-view of the <em>camera</em> in degrees.</p>
  1468. </dd>
  1469. <dt><strong>camera_set_fov</strong> (world, camera, fov)</dt><dd><p>Sets the field-of-view of the <em>camera</em> in degrees.</p>
  1470. </dd>
  1471. <dt><strong>camera_near_clip_distance</strong> (world, camera)<span class="classifier">float</span></dt><dd><p>Returns the near clip distance of the <em>camera</em>.</p>
  1472. </dd>
  1473. <dt><strong>camera_set_near_clip_distance</strong> (world, camera, near)</dt><dd><p>Sets the near clip distance of the <em>camera</em>.</p>
  1474. </dd>
  1475. <dt><strong>camera_far_clip_distance</strong> (world, camera)<span class="classifier">float</span></dt><dd><p>Returns the far clip distance of the <em>camera</em>.</p>
  1476. </dd>
  1477. <dt><strong>camera_set_far_clip_distance</strong> (world, camera, far)</dt><dd><p>Sets the far clip distance of the <em>camera</em>.</p>
  1478. </dd>
  1479. <dt><strong>camera_set_orthographic_size</strong> (world, camera, half_size)</dt><dd><p>Sets the vertical <em>half_size</em> of the orthographic view volume.
  1480. The horizontal size is proportional to the viewport’s aspect ratio.</p>
  1481. </dd>
  1482. <dt><strong>camera_screen_to_world</strong> (world, camera, pos)<span class="classifier">Vector3</span></dt><dd><p>Returns <em>pos</em> from screen-space to world-space coordinates.</p>
  1483. </dd>
  1484. <dt><strong>camera_world_to_screen</strong> (world, camera, pos)<span class="classifier">Vector3</span></dt><dd><p>Returns <em>pos</em> from world-space to screen-space coordinates.</p>
  1485. </dd>
  1486. </dl>
  1487. </section>
  1488. <section id="sound">
  1489. <h3>Sound<a class="headerlink" href="#sound" title="Permalink to this headline">¶</a></h3>
  1490. <dl class="simple">
  1491. <dt><strong>play_sound</strong> (world, name, [loop = false, volume = 1.0, range = 70.0, position = nil, group = nil])<span class="classifier">SoundInstanceId</span></dt><dd><p>Plays the sound with the given <em>name</em>. If the listener is further away than
  1492. <em>range</em> the sound will not be heard. If <em>position</em> is not specified the
  1493. sound will be played as a 2d-sound (i.e. no attenuation nor spatialization).
  1494. <em>group</em> is a string that identifies the sound’s group, see <code class="docutils literal notranslate"><span class="pre">SoundWorld.set_group_volume()</span></code>.</p>
  1495. </dd>
  1496. <dt><strong>stop_sound</strong> (world, id)</dt><dd><p>Stops the sound with the given <em>id</em>.</p>
  1497. </dd>
  1498. <dt><strong>link_sound</strong> (world, id, unit, node)</dt><dd><p>Links the sound <em>id</em> to the <em>node</em> of the given <em>unit</em>.
  1499. After this call, the sound <em>id</em> will follow the unit <em>unit</em>.</p>
  1500. </dd>
  1501. <dt><strong>set_listener_pose</strong> (world, pose)</dt><dd><p>Sets the <em>pose</em> of the listener.</p>
  1502. </dd>
  1503. <dt><strong>set_sound_position</strong> (world, id, position)</dt><dd><p>Sets the <em>position</em> of the sound <em>id</em>.</p>
  1504. </dd>
  1505. <dt><strong>set_sound_range</strong> (world, id, range)</dt><dd><p>Sets the <em>range</em> of the sound <em>id</em>.</p>
  1506. </dd>
  1507. <dt><strong>set_sound_volume</strong> (world, id, volume)</dt><dd><p>Sets the <em>volume</em> of the sound <em>id</em>.</p>
  1508. </dd>
  1509. </dl>
  1510. </section>
  1511. <section id="level">
  1512. <h3>Level<a class="headerlink" href="#level" title="Permalink to this headline">¶</a></h3>
  1513. <dl class="simple">
  1514. <dt><strong>load_level</strong> (world, name, [pos, rot])<span class="classifier">Level</span></dt><dd><p>Loads the level <em>name</em> into the world at the given <em>position</em> and <em>rotation</em>.</p>
  1515. </dd>
  1516. <dt><strong>destroy_level</strong> (world, level)</dt><dd><p>Destroys a level previously loaded by load_level(). Only units directly
  1517. spawned by the level are unspawned.</p>
  1518. </dd>
  1519. </dl>
  1520. </section>
  1521. </section>
  1522. </section>
  1523. </div>
  1524. </div>
  1525. <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
  1526. <a href="reference/command_line.html" class="btn btn-neutral float-left" title="Command line" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
  1527. <a href="glossary.html" class="btn btn-neutral float-right" title="Glossary" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
  1528. </div>
  1529. <hr/>
  1530. <div role="contentinfo">
  1531. <p>&#169; <a href="copyright.html">Copyright</a> Except where otherwise noted, content on this page is licensed under a CC-BY-SA 4.0 Int. License.
  1532. <span class="lastupdated">Last updated on Jan 19, 2026.
  1533. </span></p>
  1534. </div>
  1535. Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
  1536. <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
  1537. provided by <a href="https://readthedocs.org">Read the Docs</a>.
  1538. </footer>
  1539. </div>
  1540. </div>
  1541. </section>
  1542. </div>
  1543. <script>
  1544. jQuery(function () {
  1545. SphinxRtdTheme.Navigation.enable(true);
  1546. });
  1547. </script>
  1548. <!-- Theme Analytics -->
  1549. <script async src="https://www.googletagmanager.com/gtag/js?id=G-XNVGCMNDZH"></script>
  1550. <script>
  1551. window.dataLayer = window.dataLayer || [];
  1552. function gtag(){dataLayer.push(arguments);}
  1553. gtag('js', new Date());
  1554. gtag('config', 'G-XNVGCMNDZH', {
  1555. 'anonymize_ip': true,
  1556. });
  1557. </script>
  1558. </body>
  1559. </html>