lua_api.html 109 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577
  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="level_editor/index.html">The Level Editor</a></li>
  57. <li class="toctree-l1"><a class="reference internal" href="importing_resources/index.html">Importing Resources</a></li>
  58. <li class="toctree-l1"><a class="reference internal" href="gameplay/index.html">Writing Gameplay</a></li>
  59. <li class="toctree-l1"><a class="reference internal" href="deploying/index.html">Deploying</a></li>
  60. <li class="toctree-l1"><a class="reference internal" href="reference/index.html">Reference</a></li>
  61. <li class="toctree-l1 current"><a class="current reference internal" href="#">Lua API reference</a><ul>
  62. <li class="toctree-l2"><a class="reference internal" href="#animationstatemachine">AnimationStateMachine</a></li>
  63. <li class="toctree-l2"><a class="reference internal" href="#debugline">DebugLine</a></li>
  64. <li class="toctree-l2"><a class="reference internal" href="#device">Device</a></li>
  65. <li class="toctree-l2"><a class="reference internal" href="#display">Display</a><ul>
  66. <li class="toctree-l3"><a class="reference internal" href="#displaymode">DisplayMode</a></li>
  67. </ul>
  68. </li>
  69. <li class="toctree-l2"><a class="reference internal" href="#gui">Gui</a></li>
  70. <li class="toctree-l2"><a class="reference internal" href="#input">Input</a><ul>
  71. <li class="toctree-l3"><a class="reference internal" href="#inputevent">InputEvent</a></li>
  72. <li class="toctree-l3"><a class="reference internal" href="#inputeventtype">InputEventType</a></li>
  73. <li class="toctree-l3"><a class="reference internal" href="#keyboard">Keyboard</a><ul>
  74. <li class="toctree-l4"><a class="reference internal" href="#keyboard-button-names">Keyboard Button Names</a></li>
  75. <li class="toctree-l4"><a class="reference internal" href="#keyboard-axis-names">Keyboard Axis Names</a></li>
  76. </ul>
  77. </li>
  78. <li class="toctree-l3"><a class="reference internal" href="#mouse">Mouse</a><ul>
  79. <li class="toctree-l4"><a class="reference internal" href="#mouse-button-names">Mouse Button Names</a></li>
  80. <li class="toctree-l4"><a class="reference internal" href="#mouse-axis-names">Mouse Axis Names</a></li>
  81. </ul>
  82. </li>
  83. <li class="toctree-l3"><a class="reference internal" href="#touch">Touch</a></li>
  84. <li class="toctree-l3"><a class="reference internal" href="#pad1-pad2-pad3-pad4">Pad1, Pad2, Pad3, Pad4</a><ul>
  85. <li class="toctree-l4"><a class="reference internal" href="#pad-button-names">Pad Button Names</a></li>
  86. <li class="toctree-l4"><a class="reference internal" href="#pad-axis-names">Pad Axis Names</a></li>
  87. </ul>
  88. </li>
  89. </ul>
  90. </li>
  91. <li class="toctree-l2"><a class="reference internal" href="#material">Material</a></li>
  92. <li class="toctree-l2"><a class="reference internal" href="#math">Math</a><ul>
  93. <li class="toctree-l3"><a class="reference internal" href="#vector3">Vector3</a><ul>
  94. <li class="toctree-l4"><a class="reference internal" href="#constructors">Constructors</a></li>
  95. <li class="toctree-l4"><a class="reference internal" href="#functions">Functions</a></li>
  96. </ul>
  97. </li>
  98. <li class="toctree-l3"><a class="reference internal" href="#vector3box">Vector3Box</a><ul>
  99. <li class="toctree-l4"><a class="reference internal" href="#id1">Constructors</a></li>
  100. <li class="toctree-l4"><a class="reference internal" href="#id2">Functions</a></li>
  101. </ul>
  102. </li>
  103. <li class="toctree-l3"><a class="reference internal" href="#quaternion">Quaternion</a><ul>
  104. <li class="toctree-l4"><a class="reference internal" href="#id3">Constructors</a></li>
  105. <li class="toctree-l4"><a class="reference internal" href="#id4">Functions</a></li>
  106. </ul>
  107. </li>
  108. <li class="toctree-l3"><a class="reference internal" href="#quaternionbox">QuaternionBox</a><ul>
  109. <li class="toctree-l4"><a class="reference internal" href="#id5">Constructors</a></li>
  110. <li class="toctree-l4"><a class="reference internal" href="#id6">Functions</a></li>
  111. </ul>
  112. </li>
  113. <li class="toctree-l3"><a class="reference internal" href="#matrix4x4">Matrix4x4</a><ul>
  114. <li class="toctree-l4"><a class="reference internal" href="#id7">Constructors</a></li>
  115. <li class="toctree-l4"><a class="reference internal" href="#id8">Functions</a></li>
  116. </ul>
  117. </li>
  118. <li class="toctree-l3"><a class="reference internal" href="#matrix4x4box">Matrix4x4Box</a><ul>
  119. <li class="toctree-l4"><a class="reference internal" href="#id9">Constructors</a></li>
  120. <li class="toctree-l4"><a class="reference internal" href="#id10">Functions</a></li>
  121. </ul>
  122. </li>
  123. <li class="toctree-l3"><a class="reference internal" href="#color4">Color4</a><ul>
  124. <li class="toctree-l4"><a class="reference internal" href="#id11">Constructors</a></li>
  125. <li class="toctree-l4"><a class="reference internal" href="#id12">Functions</a></li>
  126. </ul>
  127. </li>
  128. <li class="toctree-l3"><a class="reference internal" href="#id13">Math</a></li>
  129. </ul>
  130. </li>
  131. <li class="toctree-l2"><a class="reference internal" href="#physicsworld">PhysicsWorld</a><ul>
  132. <li class="toctree-l3"><a class="reference internal" href="#raycasthit">RaycastHit</a></li>
  133. <li class="toctree-l3"><a class="reference internal" href="#actor">Actor</a></li>
  134. <li class="toctree-l3"><a class="reference internal" href="#mover">Mover</a></li>
  135. </ul>
  136. </li>
  137. <li class="toctree-l2"><a class="reference internal" href="#profiler">Profiler</a></li>
  138. <li class="toctree-l2"><a class="reference internal" href="#renderworld">RenderWorld</a><ul>
  139. <li class="toctree-l3"><a class="reference internal" href="#mesh">Mesh</a></li>
  140. <li class="toctree-l3"><a class="reference internal" href="#sprite">Sprite</a></li>
  141. <li class="toctree-l3"><a class="reference internal" href="#light">Light</a></li>
  142. <li class="toctree-l3"><a class="reference internal" href="#fog">Fog</a></li>
  143. </ul>
  144. </li>
  145. <li class="toctree-l2"><a class="reference internal" href="#resourcepackage">ResourcePackage</a></li>
  146. <li class="toctree-l2"><a class="reference internal" href="#scenegraph">SceneGraph</a></li>
  147. <li class="toctree-l2"><a class="reference internal" href="#soundworld">SoundWorld</a></li>
  148. <li class="toctree-l2"><a class="reference internal" href="#unitmanager">UnitManager</a></li>
  149. <li class="toctree-l2"><a class="reference internal" href="#window">Window</a></li>
  150. <li class="toctree-l2"><a class="reference internal" href="#world">World</a><ul>
  151. <li class="toctree-l3"><a class="reference internal" href="#camera">Camera</a></li>
  152. <li class="toctree-l3"><a class="reference internal" href="#sound">Sound</a></li>
  153. <li class="toctree-l3"><a class="reference internal" href="#level">Level</a></li>
  154. </ul>
  155. </li>
  156. </ul>
  157. </li>
  158. <li class="toctree-l1"><a class="reference internal" href="glossary.html">Glossary</a></li>
  159. <li class="toctree-l1"><a class="reference internal" href="copyright.html">License</a></li>
  160. <li class="toctree-l1"><a class="reference internal" href="hackers/index.html">Hackers</a></li>
  161. </ul>
  162. </div>
  163. </div>
  164. </nav>
  165. <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
  166. <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
  167. <a href="index.html">Crown 0.60.0 Manual</a>
  168. </nav>
  169. <div class="wy-nav-content">
  170. <div class="rst-content">
  171. <div role="navigation" aria-label="Page navigation">
  172. <ul class="wy-breadcrumbs">
  173. <li><a href="index.html" class="icon icon-home"></a> &raquo;</li>
  174. <li>Lua API reference</li>
  175. <li class="wy-breadcrumbs-aside">
  176. <a href="_sources/lua_api.rst.txt" rel="nofollow"> View page source</a>
  177. </li>
  178. </ul>
  179. <hr/>
  180. </div>
  181. <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
  182. <div itemprop="articleBody">
  183. <section id="lua-api-reference">
  184. <h1>Lua API reference<a class="headerlink" href="#lua-api-reference" title="Permalink to this headline">¶</a></h1>
  185. <section id="animationstatemachine">
  186. <h2>AnimationStateMachine<a class="headerlink" href="#animationstatemachine" title="Permalink to this headline">¶</a></h2>
  187. <dl class="simple">
  188. <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>
  189. </dd>
  190. <dt><strong>destroy</strong> (asm, state_machine)</dt><dd><p>Destroys the <em>state_machine</em> instance.</p>
  191. </dd>
  192. <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>
  193. </dd>
  194. <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
  195. the variable does not exist.</p>
  196. </dd>
  197. <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>
  198. </dd>
  199. <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>
  200. </dd>
  201. <dt><strong>trigger</strong> (asm, state_machine, event)</dt><dd><p>Triggers the <em>event</em> in the <em>state_machine</em>.</p>
  202. </dd>
  203. <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>
  204. </dd>
  205. </dl>
  206. </section>
  207. <section id="debugline">
  208. <h2>DebugLine<a class="headerlink" href="#debugline" title="Permalink to this headline">¶</a></h2>
  209. <dl class="simple">
  210. <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>
  211. </dd>
  212. <dt><strong>add_axes</strong> (debug_line, tm, length)</dt><dd><p>Adds lines for each axis with the given <em>length</em>.</p>
  213. </dd>
  214. <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>
  215. </dd>
  216. <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>
  217. </dd>
  218. <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>
  219. </dd>
  220. <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>
  221. </dd>
  222. <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
  223. the box. <em>half_extents</em> describes the size of the box along the axis.</p>
  224. </dd>
  225. <dt><strong>add_frustum</strong> (debug_line, mvp, color)</dt><dd><p>Adds a frustum defined by <em>mvp</em>.</p>
  226. </dd>
  227. <dt><strong>reset</strong> (debug_line)</dt><dd><p>Resets all the lines.</p>
  228. </dd>
  229. <dt><strong>submit</strong> (debug_line)</dt><dd><p>Submits the lines to renderer for drawing.</p>
  230. </dd>
  231. </dl>
  232. </section>
  233. <section id="device">
  234. <h2>Device<a class="headerlink" href="#device" title="Permalink to this headline">¶</a></h2>
  235. <dl>
  236. <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>
  237. </dd>
  238. <dt><strong>platform</strong> ()<span class="classifier">string</span></dt><dd><p>Returns a string identifying what platform the engine is running on.
  239. 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>
  240. </dd>
  241. <dt><strong>architecture</strong> ()<span class="classifier">string</span></dt><dd><p>Returns a string identifying what architecture the engine is running on.
  242. 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>
  243. </dd>
  244. <dt><strong>version</strong> ()<span class="classifier">string</span></dt><dd><p>Returns a string identifying the engine version.
  245. The form is “major.minor.micro”.</p>
  246. </dd>
  247. <dt><strong>build</strong> ()<span class="classifier">string</span></dt><dd><p>Returns a string identifying the engine build.
  248. 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>
  249. </dd>
  250. <dt><strong>quit</strong> ([exit_code])</dt><dd><p>Quits the application. On platforms that support it, <em>exit_code</em> is
  251. returned to the system after the application exits.</p>
  252. </dd>
  253. <dt><strong>resolution</strong> ()<span class="classifier">float, float</span></dt><dd><p>Returns the main window resolution (width, height).</p>
  254. </dd>
  255. <dt><strong>create_world</strong> ()<span class="classifier">World</span></dt><dd><p>Creates a new world.</p>
  256. </dd>
  257. <dt><strong>destroy_world</strong> (world)</dt><dd><p>Destroys the given <em>world</em>.</p>
  258. </dd>
  259. <dt><strong>render</strong> (world, camera)</dt><dd><p>Renders <em>world</em> using <em>camera</em>.</p>
  260. </dd>
  261. <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>
  262. </dd>
  263. <dt><strong>destroy_resource_package</strong> (package)</dt><dd><p>Destroy a previously created resource <em>package</em>.</p>
  264. <div class="admonition note">
  265. <p class="admonition-title">Note</p>
  266. <p>To unload the resources loaded by the package, you have to call
  267. ResourcePackage.unload() first.</p>
  268. </div>
  269. </dd>
  270. <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.
  271. 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>
  272. <div class="admonition note">
  273. <p class="admonition-title">Note</p>
  274. <p>Only available in debug and development builds.</p>
  275. </div>
  276. </dd>
  277. <dt><strong>console_send</strong> (table)</dt><dd><p>Sends the given lua <em>table</em> to clients connected to the engine.
  278. 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>
  279. </dd>
  280. <dt><strong>can_get</strong> (type, name)<span class="classifier">bool</span></dt><dd><p>Returns whether the resource (type, name) is loaded.
  281. When resource autoload is enabled it always returns true.</p>
  282. </dd>
  283. <dt><strong>enable_resource_autoload</strong> (enable)</dt><dd><p>Sets whether resources should be automatically loaded when accessed.</p>
  284. </dd>
  285. <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>
  286. </dd>
  287. <dt><strong>set_temp_count</strong> (nv, nq, nm)</dt><dd><p>Sets the number of temporary objects used by Lua.</p>
  288. </dd>
  289. <dt><strong>guid</strong> ()<span class="classifier">string</span></dt><dd><p>Returns a new GUID.</p>
  290. </dd>
  291. <dt><strong>set_timestep_policy</strong> (policy)</dt><dd><p>Sets the timestep policy:</p>
  292. <ul class="simple">
  293. <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>
  294. <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>
  295. </ul>
  296. </dd>
  297. <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
  298. allowed deviation in percent from the previous average. Given a delta time series DTs, and
  299. a previous average AVGp:</p>
  300. <ul class="simple">
  301. <li><p>DTs = [ .33; .30; .32; .33; .24; .33; .25; .35; .33; .42 ]</p></li>
  302. <li><p>AVGp = 0.33</p></li>
  303. </ul>
  304. <p>A call to set_smoothing(10, 2, 0.1) would compute the new average like so:</p>
  305. <ol class="arabic simple">
  306. <li><p>Remove the 2 minimum and maximum values in DTs;</p></li>
  307. <li><p>Compute the average for the remaining 6 values in DTs: AVG = 0.323.</p></li>
  308. <li><p>Smooth the newly computed average: AVG = lerp(AVGp, AVG, 0.1) = 0.329.</p></li>
  309. </ol>
  310. </dd>
  311. </dl>
  312. </section>
  313. <section id="display">
  314. <h2>Display<a class="headerlink" href="#display" title="Permalink to this headline">¶</a></h2>
  315. <dl class="simple">
  316. <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>
  317. </dd>
  318. <dt><strong>set_mode</strong> (id)</dt><dd><p>Sets the display mode <em>id</em>.
  319. The initial display mode is automatically reset when the program terminates.</p>
  320. </dd>
  321. </dl>
  322. <section id="displaymode">
  323. <h3>DisplayMode<a class="headerlink" href="#displaymode" title="Permalink to this headline">¶</a></h3>
  324. <p>DisplayMode is a lua table with 3 fields:</p>
  325. <ul class="simple">
  326. <li><p><code class="docutils literal notranslate"><span class="pre">id</span></code>: The id of the display mode.</p></li>
  327. <li><p><code class="docutils literal notranslate"><span class="pre">width</span></code>: The width of the display mode.</p></li>
  328. <li><p><code class="docutils literal notranslate"><span class="pre">height</span></code>: The height of the display mode.</p></li>
  329. </ul>
  330. </section>
  331. </section>
  332. <section id="gui">
  333. <h2>Gui<a class="headerlink" href="#gui" title="Permalink to this headline">¶</a></h2>
  334. <dl class="simple">
  335. <dt><strong>move</strong> (gui, pos)</dt><dd><p>Moves the Gui to <em>pos</em>.</p>
  336. </dd>
  337. <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>.
  338. Objects with a lower depth are drawn in front. If depth is omitted its value
  339. is set to 0.</p>
  340. </dd>
  341. <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>
  342. </dd>
  343. <dt><strong>rect</strong> (gui, pos, size [, color])</dt><dd><p>Draws a rectangle.
  344. If pos is a Vector3, the z element specifies the drawing depth. Objects with
  345. a lower depth are drawn in front. If pos is a Vector2, the z elements is set
  346. to 0.</p>
  347. </dd>
  348. <dt><strong>rect_3d</strong> (gui, local_pose, pos, size [, color, depth])</dt><dd><p>Draws a 3D rectangle.</p>
  349. </dd>
  350. <dt><strong>image</strong> (gui, pos, size, material_resource [, color])</dt><dd><p>Draws an image.
  351. If pos is a Vector3, the z element specifies the drawing depth. Objects with
  352. a lower depth are drawn in front. If pos is a Vector2, the z elements is set
  353. to 0.</p>
  354. </dd>
  355. <dt><strong>image_3d</strong> (gui, local_pose, pos, size, material_resource [, color, depth])</dt><dd><p>Draws a 3D image.</p>
  356. </dd>
  357. <dt><strong>image_uv</strong> (gui, pos, size, uv0, uv1, material_resource [, color])</dt><dd><p>Draws an image with explicit UV coordinates.
  358. If pos is a Vector3, the z element specifies the drawing depth. Objects with
  359. a lower depth are drawn in front. If pos is a Vector2, the z elements is set
  360. to 0.</p>
  361. </dd>
  362. <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>
  363. </dd>
  364. <dt><strong>text</strong> (gui, pos, font_size, str, font_resource [, material_resource , color])</dt><dd><p>Draws text.
  365. If pos is a Vector3, the z element specifies the drawing depth. Objects with
  366. a lower depth are drawn in front. If pos is a Vector2, the z elements is set
  367. to 0.</p>
  368. </dd>
  369. <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
  370. <em>font_size</em>.</p>
  371. </dd>
  372. <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>
  373. </dd>
  374. <dt><strong>material</strong> (material_resource)<span class="classifier">Material</span></dt><dd><p>Returns the material <em>material_resource</em>.</p>
  375. </dd>
  376. </dl>
  377. </section>
  378. <section id="input">
  379. <h2>Input<a class="headerlink" href="#input" title="Permalink to this headline">¶</a></h2>
  380. <dl class="simple">
  381. <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>
  382. </dd>
  383. </dl>
  384. <section id="inputevent">
  385. <h3>InputEvent<a class="headerlink" href="#inputevent" title="Permalink to this headline">¶</a></h3>
  386. <p>InputEvent is a lua table with 4 fields:</p>
  387. <ul class="simple">
  388. <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>
  389. <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>
  390. <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>
  391. <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>
  392. </ul>
  393. </section>
  394. <section id="inputeventtype">
  395. <h3>InputEventType<a class="headerlink" href="#inputeventtype" title="Permalink to this headline">¶</a></h3>
  396. <ul class="simple">
  397. <li><p><code class="docutils literal notranslate"><span class="pre">BUTTON_PRESSED</span></code>: A button has been pressed.</p></li>
  398. <li><p><code class="docutils literal notranslate"><span class="pre">BUTTON_RELEASED</span></code>: A button has been released.</p></li>
  399. <li><p><code class="docutils literal notranslate"><span class="pre">AXIS_CHANGED</span></code>: An axis changed its value.</p></li>
  400. </ul>
  401. </section>
  402. <section id="keyboard">
  403. <h3>Keyboard<a class="headerlink" href="#keyboard" title="Permalink to this headline">¶</a></h3>
  404. <dl class="simple">
  405. <dt><strong>name</strong> ()<span class="classifier">string</span></dt><dd><p>Returns the name of keyboard.</p>
  406. </dd>
  407. <dt><strong>connected</strong> ()<span class="classifier">bool</span></dt><dd><p>Returns whether the keyboard is connected and functioning.</p>
  408. </dd>
  409. <dt><strong>num_buttons</strong> ()<span class="classifier">int</span></dt><dd><p>Returns the number of buttons of the keyboard.</p>
  410. </dd>
  411. <dt><strong>num_axes</strong> ()<span class="classifier">int</span></dt><dd><p>Returns the number of axes of the keyboard.</p>
  412. </dd>
  413. <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>
  414. </dd>
  415. <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>
  416. </dd>
  417. <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
  418. or <code class="docutils literal notranslate"><span class="pre">nil</span></code> if no buttons were pressed at all.</p>
  419. </dd>
  420. <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
  421. or <code class="docutils literal notranslate"><span class="pre">nil</span></code> if no buttons were released at all.</p>
  422. </dd>
  423. <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>
  424. </dd>
  425. <dt><strong>button_name</strong> (id)<span class="classifier">string</span></dt><dd><p>Returns the name of the button <em>id</em>.</p>
  426. </dd>
  427. <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>
  428. </dd>
  429. </dl>
  430. <section id="keyboard-button-names">
  431. <h4>Keyboard Button Names<a class="headerlink" href="#keyboard-button-names" title="Permalink to this headline">¶</a></h4>
  432. <ul class="simple">
  433. <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>
  434. <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>
  435. <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>
  436. <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>
  437. <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>
  438. <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>
  439. <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>
  440. </ul>
  441. </section>
  442. <section id="keyboard-axis-names">
  443. <h4>Keyboard Axis Names<a class="headerlink" href="#keyboard-axis-names" title="Permalink to this headline">¶</a></h4>
  444. <p>None.</p>
  445. </section>
  446. </section>
  447. <section id="mouse">
  448. <h3>Mouse<a class="headerlink" href="#mouse" title="Permalink to this headline">¶</a></h3>
  449. <dl class="simple">
  450. <dt><strong>name</strong> ()<span class="classifier">string</span></dt><dd><p>Returns the name of the mouse.</p>
  451. </dd>
  452. <dt><strong>connected</strong> ()<span class="classifier">bool</span></dt><dd><p>Returns whether the mouse is connected and functioning.</p>
  453. </dd>
  454. <dt><strong>num_buttons</strong> ()<span class="classifier">int</span></dt><dd><p>Returns the number of buttons of the mouse.</p>
  455. </dd>
  456. <dt><strong>num_axes</strong> ()<span class="classifier">int</span></dt><dd><p>Returns the number of axes of the mouse.</p>
  457. </dd>
  458. <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>
  459. </dd>
  460. <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>
  461. </dd>
  462. <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
  463. or <code class="docutils literal notranslate"><span class="pre">nil</span></code> if no buttons were pressed at all.</p>
  464. </dd>
  465. <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
  466. or <code class="docutils literal notranslate"><span class="pre">nil</span></code> if no buttons were released at all.</p>
  467. </dd>
  468. <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>
  469. </dd>
  470. <dt><strong>axis</strong> (id)<span class="classifier">Vector3</span></dt><dd><p>Returns the value of the axis <em>id</em>.</p>
  471. </dd>
  472. <dt><strong>button_name</strong> (id)<span class="classifier">string</span></dt><dd><p>Returns the name of the button <em>id</em>.</p>
  473. </dd>
  474. <dt><strong>axis_name</strong> (id)<span class="classifier">string</span></dt><dd><p>Returns the name of the axis <em>id</em>.</p>
  475. </dd>
  476. <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>
  477. </dd>
  478. <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>
  479. </dd>
  480. </dl>
  481. <section id="mouse-button-names">
  482. <h4>Mouse Button Names<a class="headerlink" href="#mouse-button-names" title="Permalink to this headline">¶</a></h4>
  483. <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>
  484. </section>
  485. <section id="mouse-axis-names">
  486. <h4>Mouse Axis Names<a class="headerlink" href="#mouse-axis-names" title="Permalink to this headline">¶</a></h4>
  487. <ul class="simple">
  488. <li><p><code class="docutils literal notranslate"><span class="pre">cursor</span></code>: Returns the cursor position (x, y) in screen coordinates.</p></li>
  489. <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>
  490. <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>
  491. </ul>
  492. </section>
  493. </section>
  494. <section id="touch">
  495. <h3>Touch<a class="headerlink" href="#touch" title="Permalink to this headline">¶</a></h3>
  496. <dl class="simple">
  497. <dt><strong>name</strong> ()<span class="classifier">string</span></dt><dd><p>Returns the name of the touch.</p>
  498. </dd>
  499. <dt><strong>connected</strong> ()<span class="classifier">bool</span></dt><dd><p>Returns whether the touch is connected and functioning.</p>
  500. </dd>
  501. <dt><strong>num_buttons</strong> ()<span class="classifier">int</span></dt><dd><p>Returns the number of buttons of the touch.</p>
  502. </dd>
  503. <dt><strong>num_axes</strong> ()<span class="classifier">int</span></dt><dd><p>Returns the number of axes of the touch.</p>
  504. </dd>
  505. <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>
  506. </dd>
  507. <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>
  508. </dd>
  509. <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
  510. or <code class="docutils literal notranslate"><span class="pre">nil</span></code> if no buttons were pressed at all.</p>
  511. </dd>
  512. <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
  513. or <code class="docutils literal notranslate"><span class="pre">nil</span></code> if no buttons were released at all.</p>
  514. </dd>
  515. <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>
  516. </dd>
  517. <dt><strong>axis</strong> (id)<span class="classifier">Vector3</span></dt><dd><p>Returns the value of the axis <em>id</em>.</p>
  518. </dd>
  519. <dt><strong>button_name</strong> (id)<span class="classifier">string</span></dt><dd><p>Returns the name of the button <em>id</em>.</p>
  520. </dd>
  521. <dt><strong>axis_name</strong> (id)<span class="classifier">string</span></dt><dd><p>Returns the name of the axis <em>id</em>.</p>
  522. </dd>
  523. <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>
  524. </dd>
  525. <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>
  526. </dd>
  527. </dl>
  528. </section>
  529. <section id="pad1-pad2-pad3-pad4">
  530. <h3>Pad1, Pad2, Pad3, Pad4<a class="headerlink" href="#pad1-pad2-pad3-pad4" title="Permalink to this headline">¶</a></h3>
  531. <dl class="simple">
  532. <dt><strong>name</strong> ()<span class="classifier">string</span></dt><dd><p>Returns the name of the pad.</p>
  533. </dd>
  534. <dt><strong>connected</strong> ()<span class="classifier">bool</span></dt><dd><p>Returns whether the pad is connected and functioning.</p>
  535. </dd>
  536. <dt><strong>num_buttons</strong> ()<span class="classifier">int</span></dt><dd><p>Returns the number of buttons of the pad.</p>
  537. </dd>
  538. <dt><strong>num_axes</strong> ()<span class="classifier">int</span></dt><dd><p>Returns the number of axes of the pad.</p>
  539. </dd>
  540. <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>
  541. </dd>
  542. <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>
  543. </dd>
  544. <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
  545. or <code class="docutils literal notranslate"><span class="pre">nil</span></code> if no buttons were pressed at all.</p>
  546. </dd>
  547. <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
  548. or <code class="docutils literal notranslate"><span class="pre">nil</span></code> if no buttons were released at all.</p>
  549. </dd>
  550. <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>
  551. </dd>
  552. <dt><strong>axis</strong> (id)<span class="classifier">Vector3</span></dt><dd><p>Returns the value of the axis <em>id</em>.</p>
  553. </dd>
  554. <dt><strong>button_name</strong> (id)<span class="classifier">string</span></dt><dd><p>Returns the name of the button <em>id</em>.</p>
  555. </dd>
  556. <dt><strong>axis_name</strong> (id)<span class="classifier">string</span></dt><dd><p>Returns the name of the axis <em>id</em>.</p>
  557. </dd>
  558. <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>
  559. </dd>
  560. <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>
  561. </dd>
  562. <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>
  563. </dd>
  564. <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>
  565. </dd>
  566. </dl>
  567. <section id="pad-button-names">
  568. <h4>Pad Button Names<a class="headerlink" href="#pad-button-names" title="Permalink to this headline">¶</a></h4>
  569. <ul class="simple">
  570. <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>
  571. <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>
  572. <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>
  573. <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>
  574. <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>
  575. </ul>
  576. </section>
  577. <section id="pad-axis-names">
  578. <h4>Pad Axis Names<a class="headerlink" href="#pad-axis-names" title="Permalink to this headline">¶</a></h4>
  579. <ul class="simple">
  580. <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>
  581. <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>
  582. </ul>
  583. </section>
  584. </section>
  585. </section>
  586. <section id="material">
  587. <h2>Material<a class="headerlink" href="#material" title="Permalink to this headline">¶</a></h2>
  588. <dl class="simple">
  589. <dt><strong>set_float</strong> (material, name, value)</dt><dd><p>Sets the <em>value</em> of the variable <em>name</em>.</p>
  590. </dd>
  591. <dt><strong>set_vector2</strong> (material, name, value)</dt><dd><p>Sets the <em>value</em> of the variable <em>name</em>.</p>
  592. </dd>
  593. <dt><strong>set_vector3</strong> (material, name, value)</dt><dd><p>Sets the <em>value</em> of the variable <em>name</em>.</p>
  594. </dd>
  595. <dt><strong>set_vector4</strong> (material, name, value)</dt><dd><p>Sets the <em>value</em> of the variable <em>name</em>.</p>
  596. </dd>
  597. <dt><strong>set_matrix4x4</strong> (material, name, value)</dt><dd><p>Sets the <em>value</em> of the variable <em>name</em>.</p>
  598. </dd>
  599. <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>
  600. </dd>
  601. </dl>
  602. </section>
  603. <section id="math">
  604. <h2>Math<a class="headerlink" href="#math" title="Permalink to this headline">¶</a></h2>
  605. <section id="vector3">
  606. <h3>Vector3<a class="headerlink" href="#vector3" title="Permalink to this headline">¶</a></h3>
  607. <section id="constructors">
  608. <h4>Constructors<a class="headerlink" href="#constructors" title="Permalink to this headline">¶</a></h4>
  609. <dl class="simple">
  610. <dt><strong>Vector3</strong> (x, y, z)<span class="classifier">Vector3</span></dt><dd><p>Returns a new vector from individual elements.</p>
  611. </dd>
  612. </dl>
  613. </section>
  614. <section id="functions">
  615. <h4>Functions<a class="headerlink" href="#functions" title="Permalink to this headline">¶</a></h4>
  616. <dl class="simple">
  617. <dt><strong>x</strong> (v)<span class="classifier">float</span></dt><dd><p>Returns the x value of the vector.</p>
  618. </dd>
  619. <dt><strong>y</strong> (v)<span class="classifier">float</span></dt><dd><p>Returns the y value of the vector.</p>
  620. </dd>
  621. <dt><strong>z</strong> (v)<span class="classifier">float</span></dt><dd><p>Returns the z value of the vector.</p>
  622. </dd>
  623. <dt><strong>.x</strong><span class="classifier">float</span></dt><dd><p>Returns/assigns the x value of the vector.</p>
  624. </dd>
  625. <dt><strong>.y</strong><span class="classifier">float</span></dt><dd><p>Returns/assigns the y value of the vector.</p>
  626. </dd>
  627. <dt><strong>.z</strong><span class="classifier">float</span></dt><dd><p>Returns/assigns the z value of the vector.</p>
  628. </dd>
  629. <dt><strong>set_x</strong> (v, x)</dt><dd><p>Sets the value of the x value of the vector.</p>
  630. </dd>
  631. <dt><strong>set_y</strong> (v, y)</dt><dd><p>Sets the value of the y value of the vector.</p>
  632. </dd>
  633. <dt><strong>set_z</strong> (v, z)</dt><dd><p>Sets the value of the z value of the vector.</p>
  634. </dd>
  635. <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>
  636. </dd>
  637. <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>
  638. </dd>
  639. <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>
  640. </dd>
  641. <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>
  642. </dd>
  643. <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>
  644. </dd>
  645. <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>
  646. </dd>
  647. <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>
  648. </dd>
  649. <dt><strong>length</strong> (a)<span class="classifier">float</span></dt><dd><p>Returns the length of <em>a</em>.</p>
  650. </dd>
  651. <dt><strong>length_squared</strong> (a)<span class="classifier">float</span></dt><dd><p>Returns the squared length of <em>a</em>.</p>
  652. </dd>
  653. <dt><strong>set_length</strong> (a, len)</dt><dd><p>Sets the length of <em>a</em> to <em>len</em>.</p>
  654. </dd>
  655. <dt><strong>normalize</strong> (a)<span class="classifier">Vector3</span></dt><dd><p>Normalizes <em>a</em> and returns the result.</p>
  656. </dd>
  657. <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>
  658. </dd>
  659. <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>
  660. </dd>
  661. <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>
  662. </dd>
  663. <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>
  664. </dd>
  665. <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>
  666. </dd>
  667. <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>
  668. </dd>
  669. </dl>
  670. <div class="line-block">
  671. <div class="line"><strong>forward</strong> () : Vector3</div>
  672. <div class="line"><strong>backward</strong> () : Vector3</div>
  673. <div class="line"><strong>left</strong> () : Vector3</div>
  674. <div class="line"><strong>right</strong> () : Vector3</div>
  675. <div class="line"><strong>up</strong> () : Vector3</div>
  676. <div class="line"><strong>down</strong> () : Vector3</div>
  677. <div class="line-block">
  678. <div class="line">Returns the corresponding semantic axis.</div>
  679. </div>
  680. </div>
  681. <dl class="simple">
  682. <dt><strong>zero</strong> ()<span class="classifier">Vector3</span></dt><dd><p>Returns a vector with all values set to zero.</p>
  683. </dd>
  684. <dt><strong>to_string</strong> (v)<span class="classifier">string</span></dt><dd><p>Returns a string representing the vector <em>v</em>.</p>
  685. </dd>
  686. </dl>
  687. </section>
  688. </section>
  689. <section id="vector3box">
  690. <h3>Vector3Box<a class="headerlink" href="#vector3box" title="Permalink to this headline">¶</a></h3>
  691. <section id="id1">
  692. <h4>Constructors<a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h4>
  693. <dl class="simple">
  694. <dt><strong>Vector3Box</strong> ()<span class="classifier">Vector3Box</span></dt><dd><p>Returns a new Vector3Box initialized with the zero vector.</p>
  695. </dd>
  696. <dt><strong>Vector3Box</strong> (v)<span class="classifier">Vector3Box</span></dt><dd><p>Returns a new Vector3Box from the Vector3 <em>v</em>.</p>
  697. </dd>
  698. <dt><strong>Vector3Box</strong> (x, y, z)<span class="classifier">Vector3Box</span></dt><dd><p>Returns a new Vector3Box from individual elements.</p>
  699. </dd>
  700. </dl>
  701. </section>
  702. <section id="id2">
  703. <h4>Functions<a class="headerlink" href="#id2" title="Permalink to this headline">¶</a></h4>
  704. <dl class="simple">
  705. <dt><strong>store</strong> (v)</dt><dd><p>Stores the Vector3 <em>v</em> in the box.</p>
  706. </dd>
  707. <dt><strong>store</strong> (x, y, z)</dt><dd><p>Stores Vector3(x, y, z) in the box.</p>
  708. </dd>
  709. <dt><strong>unbox</strong> ()<span class="classifier">Vector3</span></dt><dd><p>Returns the stored vector from the box.</p>
  710. </dd>
  711. </dl>
  712. </section>
  713. </section>
  714. <section id="quaternion">
  715. <h3>Quaternion<a class="headerlink" href="#quaternion" title="Permalink to this headline">¶</a></h3>
  716. <section id="id3">
  717. <h4>Constructors<a class="headerlink" href="#id3" title="Permalink to this headline">¶</a></h4>
  718. <dl class="simple">
  719. <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>
  720. </dd>
  721. <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>
  722. </dd>
  723. <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>
  724. </dd>
  725. </dl>
  726. </section>
  727. <section id="id4">
  728. <h4>Functions<a class="headerlink" href="#id4" title="Permalink to this headline">¶</a></h4>
  729. <dl class="simple">
  730. <dt><strong>negate</strong> (q)<span class="classifier">Quaternion</span></dt><dd><p>Negates the quaternion <em>q</em> and returns the result.</p>
  731. </dd>
  732. <dt><strong>identity</strong> ()<span class="classifier">Quaternion</span></dt><dd><p>Returns the identity quaternion.</p>
  733. </dd>
  734. <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>
  735. </dd>
  736. <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>
  737. </dd>
  738. <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>
  739. </dd>
  740. <dt><strong>length</strong> (q)<span class="classifier">float</span></dt><dd><p>Returns the length of <em>q</em>.</p>
  741. </dd>
  742. <dt><strong>normalize</strong> (q)<span class="classifier">Quaternion</span></dt><dd><p>Normalizes the quaternion <em>q</em> and returns the result.</p>
  743. </dd>
  744. <dt><strong>conjugate</strong> (q)<span class="classifier">Quaternion</span></dt><dd><p>Returns the conjugate of quaternion <em>q</em>.</p>
  745. </dd>
  746. <dt><strong>inverse</strong> (q)<span class="classifier">Quaternion</span></dt><dd><p>Returns the inverse of quaternion <em>q</em>.</p>
  747. </dd>
  748. <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>
  749. </dd>
  750. <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>
  751. </dd>
  752. <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>.
  753. If <em>up</em> is not specified, Vector3.up() is used.</p>
  754. </dd>
  755. <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>
  756. </dd>
  757. <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>
  758. </dd>
  759. <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>
  760. </dd>
  761. <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].
  762. It uses NLerp.</p>
  763. </dd>
  764. <dt><strong>to_string</strong> (q)<span class="classifier">string</span></dt><dd><p>Returns a string representing the quaternion <em>q</em>.</p>
  765. </dd>
  766. </dl>
  767. </section>
  768. </section>
  769. <section id="quaternionbox">
  770. <h3>QuaternionBox<a class="headerlink" href="#quaternionbox" title="Permalink to this headline">¶</a></h3>
  771. <section id="id5">
  772. <h4>Constructors<a class="headerlink" href="#id5" title="Permalink to this headline">¶</a></h4>
  773. <dl class="simple">
  774. <dt><strong>QuaternionBox</strong> ()<span class="classifier">QuaternionBox</span></dt><dd><p>Returns a new QuaternionBox initialized with the identity quaternion.</p>
  775. </dd>
  776. <dt><strong>QuaternionBox</strong> (q)<span class="classifier">QuaternionBox</span></dt><dd><p>Returns a new QuaternionBox from the Quaternion <em>q</em>.</p>
  777. </dd>
  778. <dt><strong>QuaternionBox</strong> (x, y, z, w)<span class="classifier">QuaternionBox</span></dt><dd><p>Returns a new QuaternionBox from individual elements.</p>
  779. </dd>
  780. </dl>
  781. </section>
  782. <section id="id6">
  783. <h4>Functions<a class="headerlink" href="#id6" title="Permalink to this headline">¶</a></h4>
  784. <dl class="simple">
  785. <dt><strong>store</strong> (q)</dt><dd><p>Stores the Quaternion <em>q</em> in the box.</p>
  786. </dd>
  787. <dt><strong>store</strong> (x, y, z, w)</dt><dd><p>Stores Quaternion(x, y, z, w) in the box.</p>
  788. </dd>
  789. <dt><strong>unbox</strong> ()<span class="classifier">Quaternion</span></dt><dd><p>Returns the stored quaternion from the box.</p>
  790. </dd>
  791. </dl>
  792. </section>
  793. </section>
  794. <section id="matrix4x4">
  795. <h3>Matrix4x4<a class="headerlink" href="#matrix4x4" title="Permalink to this headline">¶</a></h3>
  796. <section id="id7">
  797. <h4>Constructors<a class="headerlink" href="#id7" title="Permalink to this headline">¶</a></h4>
  798. <dl class="simple">
  799. <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>
  800. </dd>
  801. <dt><strong>from_quaternion</strong> (q)<span class="classifier">Matrix4x4</span></dt><dd><p>Returns a new matrix from <em>q</em>.</p>
  802. </dd>
  803. <dt><strong>from_translation</strong> (t)<span class="classifier">Matrix4x4</span></dt><dd><p>Returns a new matrix from <em>t</em>.</p>
  804. </dd>
  805. <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>
  806. </dd>
  807. <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>
  808. </dd>
  809. </dl>
  810. </section>
  811. <section id="id8">
  812. <h4>Functions<a class="headerlink" href="#id8" title="Permalink to this headline">¶</a></h4>
  813. <dl class="simple">
  814. <dt><strong>copy</strong> (m)<span class="classifier">Matrix4x4</span></dt><dd><p>Returns a copy of the matrix <em>m</em>.</p>
  815. </dd>
  816. <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>
  817. </dd>
  818. <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>
  819. </dd>
  820. <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>
  821. </dd>
  822. <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>
  823. </dd>
  824. <dt><strong>transpose</strong> (m)<span class="classifier">Matrix4x4</span></dt><dd><p>Transposes the matrix <em>m</em> and returns the result.</p>
  825. </dd>
  826. <dt><strong>invert</strong> (m)<span class="classifier">Matrix4x4</span></dt><dd><p>Inverts the matrix <em>m</em> and returns the result.</p>
  827. </dd>
  828. <dt><strong>x</strong> (m)<span class="classifier">Vector3</span></dt><dd><p>Returns the x axis of the matrix <em>m</em>.</p>
  829. </dd>
  830. <dt><strong>y</strong> (m)<span class="classifier">Vector3</span></dt><dd><p>Returns the y axis of the matrix <em>m</em>.</p>
  831. </dd>
  832. <dt><strong>z</strong> (m)<span class="classifier">Vector3</span></dt><dd><p>Returns the z axis of the matrix <em>m</em>.</p>
  833. </dd>
  834. <dt><strong>set_x</strong> (m, x)</dt><dd><p>Sets the x axis of the matrix <em>m</em>.</p>
  835. </dd>
  836. <dt><strong>set_y</strong> (m, y)</dt><dd><p>Sets the y axis of the matrix <em>m</em>.</p>
  837. </dd>
  838. <dt><strong>set_z</strong> (m, z)</dt><dd><p>Sets the z axis of the matrix <em>m</em>.</p>
  839. </dd>
  840. <dt><strong>translation</strong> (m)<span class="classifier">Vector3</span></dt><dd><p>Returns the translation portion of the matrix <em>m</em>.</p>
  841. </dd>
  842. <dt><strong>set_translation</strong> (m, t)</dt><dd><p>Sets the translation portion of the matrix <em>m</em>.</p>
  843. </dd>
  844. <dt><strong>rotation</strong> (m)<span class="classifier">Quaternion</span></dt><dd><p>Returns the rotation portion of the matrix <em>m</em>.</p>
  845. </dd>
  846. <dt><strong>set_rotation</strong> (m, r)</dt><dd><p>Sets the rotation portion of the matrix <em>m</em>.</p>
  847. </dd>
  848. <dt><strong>scale</strong> (m)<span class="classifier">Vector3</span></dt><dd><p>Returns the scale of the matrix <em>m</em>.</p>
  849. </dd>
  850. <dt><strong>set_scale</strong> (m, r)</dt><dd><p>Sets the scale of the matrix <em>m</em>.</p>
  851. </dd>
  852. <dt><strong>identity</strong> ()</dt><dd><p>Returns the identity matrix.</p>
  853. </dd>
  854. <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>
  855. </dd>
  856. <dt><strong>to_string</strong> (m)<span class="classifier">string</span></dt><dd><p>Returns a string representing the matrix <em>m</em>.</p>
  857. </dd>
  858. </dl>
  859. </section>
  860. </section>
  861. <section id="matrix4x4box">
  862. <h3>Matrix4x4Box<a class="headerlink" href="#matrix4x4box" title="Permalink to this headline">¶</a></h3>
  863. <section id="id9">
  864. <h4>Constructors<a class="headerlink" href="#id9" title="Permalink to this headline">¶</a></h4>
  865. <dl class="simple">
  866. <dt><strong>Matrix4x4Box</strong> ()<span class="classifier">Matrix4x4Box</span></dt><dd><p>Returns a new Matrix4x4Box initialized with the identity matrix.</p>
  867. </dd>
  868. <dt><strong>Matrix4x4Box</strong> (m)<span class="classifier">Matrix4x4Box</span></dt><dd><p>Returns a new Matrix4x4Box from the Matrix4x4 <em>m</em>.</p>
  869. </dd>
  870. </dl>
  871. </section>
  872. <section id="id10">
  873. <h4>Functions<a class="headerlink" href="#id10" title="Permalink to this headline">¶</a></h4>
  874. <dl class="simple">
  875. <dt><strong>store</strong> (m)</dt><dd><p>Stores the Matrix4x4 <em>m</em> in the box.</p>
  876. </dd>
  877. <dt><strong>unbox</strong> ()<span class="classifier">Matrix4x4</span></dt><dd><p>Returns the stored matrix from the box.</p>
  878. </dd>
  879. </dl>
  880. </section>
  881. </section>
  882. <section id="color4">
  883. <h3>Color4<a class="headerlink" href="#color4" title="Permalink to this headline">¶</a></h3>
  884. <section id="id11">
  885. <h4>Constructors<a class="headerlink" href="#id11" title="Permalink to this headline">¶</a></h4>
  886. <dl class="simple">
  887. <dt><strong>Color4</strong> (r, g, b, a)<span class="classifier">Color4</span></dt><dd><p>Returns a new Color4 from individual elements.</p>
  888. </dd>
  889. </dl>
  890. </section>
  891. <section id="id12">
  892. <h4>Functions<a class="headerlink" href="#id12" title="Permalink to this headline">¶</a></h4>
  893. <dl class="simple">
  894. <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>
  895. </dd>
  896. </dl>
  897. <div class="line-block">
  898. <div class="line"><strong>black</strong> () : Color4</div>
  899. <div class="line"><strong>white</strong> () : Color4</div>
  900. <div class="line"><strong>red</strong> () : Color4</div>
  901. <div class="line"><strong>green</strong> () : Color4</div>
  902. <div class="line"><strong>blue</strong> () : Color4</div>
  903. <div class="line"><strong>yellow</strong> () : Color4</div>
  904. <div class="line"><strong>orange</strong> () : Color4</div>
  905. <div class="line-block">
  906. <div class="line">Returns the corresponding mnemonic color.</div>
  907. </div>
  908. </div>
  909. <dl class="simple">
  910. <dt><strong>to_string</strong> (c)<span class="classifier">string</span></dt><dd><p>Returns a string representing the color <em>c</em>.</p>
  911. </dd>
  912. </dl>
  913. </section>
  914. </section>
  915. <section id="id13">
  916. <h3>Math<a class="headerlink" href="#id13" title="Permalink to this headline">¶</a></h3>
  917. <dl class="simple">
  918. <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
  919. <em>point</em> and <em>normal</em> or -1.0 if no intersection.</p>
  920. </dd>
  921. <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
  922. <em>center</em>, <em>radius</em> and <em>normal</em> or -1.0 if no intersection.</p>
  923. </dd>
  924. <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
  925. <em>center</em> and <em>radius</em> or -1.0 if no intersection.</p>
  926. </dd>
  927. <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
  928. bounding box (tm, half_extents) or -1.0 if no intersection.</p>
  929. </dd>
  930. <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
  931. (v0, v1, v2) or -1.0 if no intersection.</p>
  932. </dd>
  933. <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
  934. the frustum defined by the planes ((n0, d0), (n1, d1), …, (n5, d5)). The
  935. planes be given in BRTLNF order, where B = bottom plane, R = right plane etc.</p>
  936. </dd>
  937. <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>
  938. </dd>
  939. <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
  940. (b_tm, b_half_extents) and any number of boxes after B.
  941. Note that the returned OBB will have the same orientation as A and won’t
  942. necessarily be the smallest enclosing box.</p>
  943. </dd>
  944. </dl>
  945. </section>
  946. </section>
  947. <section id="physicsworld">
  948. <h2>PhysicsWorld<a class="headerlink" href="#physicsworld" title="Permalink to this headline">¶</a></h2>
  949. <dl class="simple">
  950. <dt><strong>gravity</strong> (pw)<span class="classifier">Vector3</span></dt><dd><p>Returns the gravity.</p>
  951. </dd>
  952. <dt><strong>set_gravity</strong> (pw, gravity)</dt><dd><p>Sets the gravity.</p>
  953. </dd>
  954. <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.
  955. If <em>hit</em> is true the following return values contain the <em>collision_pos</em> in
  956. world space, the <em>normal</em> of the surface that was hit, the time of impact
  957. in [0..1] and the <em>unit</em> and the <em>actor</em> that was hit.</p>
  958. </dd>
  959. <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
  960. actors it intersects with as an array of <a class="reference internal" href="#raycasthit">RaycastHit</a> tables.</p>
  961. </dd>
  962. <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.
  963. If <em>hit</em> is true the following return values contain the <em>collision_pos</em> in
  964. world space, the <em>normal</em> of the surface that was hit, the time of impact
  965. in [0..1] and the <em>unit</em> and the <em>actor</em> that was hit.</p>
  966. </dd>
  967. <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.
  968. If <em>hit</em> is true the following return values contain the <em>collision_pos</em> in
  969. world space, the <em>normal</em> of the surface that was hit, the time of impact
  970. in [0..1] and the <em>unit</em> and the <em>actor</em> that was hit.</p>
  971. </dd>
  972. <dt><strong>enable_debug_drawing</strong> (pw, enable)</dt><dd><p>Sets whether to <em>enable</em> debug drawing.</p>
  973. </dd>
  974. </dl>
  975. <section id="raycasthit">
  976. <h3>RaycastHit<a class="headerlink" href="#raycasthit" title="Permalink to this headline">¶</a></h3>
  977. <p>RaycastHit is a lua table with 5 fields:</p>
  978. <ul class="simple">
  979. <li><p><code class="docutils literal notranslate"><span class="pre">[1]</span></code>: The collision position in world space.</p></li>
  980. <li><p><code class="docutils literal notranslate"><span class="pre">[2]</span></code>: The normal of the surface that was hit.</p></li>
  981. <li><p><code class="docutils literal notranslate"><span class="pre">[3]</span></code>: The time of impact in [0..1].</p></li>
  982. <li><p><code class="docutils literal notranslate"><span class="pre">[4]</span></code>: The unit that was hit.</p></li>
  983. <li><p><code class="docutils literal notranslate"><span class="pre">[5]</span></code>: The actor that was hit.</p></li>
  984. </ul>
  985. </section>
  986. <section id="actor">
  987. <h3>Actor<a class="headerlink" href="#actor" title="Permalink to this headline">¶</a></h3>
  988. <dl>
  989. <dt><strong>actor_destroy</strong> (pw, actor)</dt><dd><p>Destroys the <em>actor</em> instance.</p>
  990. </dd>
  991. <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>
  992. </dd>
  993. <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>
  994. </dd>
  995. <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>
  996. </dd>
  997. <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>
  998. </dd>
  999. <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>
  1000. </dd>
  1001. <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>
  1002. </dd>
  1003. <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>
  1004. </dd>
  1005. <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>
  1006. </dd>
  1007. <dt><strong>actor_enable_gravity</strong> (pw, actor)</dt><dd><p>Enables gravity for the <em>actor</em>.</p>
  1008. </dd>
  1009. <dt><strong>actor_disable_gravity</strong> (pw, actor)</dt><dd><p>Disables gravity for the <em>actor</em>.</p>
  1010. </dd>
  1011. <dt><strong>actor_enable_collision</strong> (pw, actor)</dt><dd><p>Enables collision detection for the <em>actor</em>.</p>
  1012. </dd>
  1013. <dt><strong>actor_disable_collision</strong> (pw, actor)</dt><dd><p>Disables collision detection for the <em>actor</em>.</p>
  1014. </dd>
  1015. <dt><strong>actor_set_collision_filter</strong> (pw, actor, name)</dt><dd><p>Sets the collision filter of the <em>actor</em>.</p>
  1016. </dd>
  1017. <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>
  1018. <div class="admonition note">
  1019. <p class="admonition-title">Note</p>
  1020. <p>This call has no effect on static actors.</p>
  1021. </div>
  1022. </dd>
  1023. <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>
  1024. </dd>
  1025. <dt><strong>actor_is_dynamic</strong> (pw, actor) bool</dt><dd><p>Returns whether the <em>actor</em> is dynamic.</p>
  1026. </dd>
  1027. <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>
  1028. </dd>
  1029. <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>
  1030. </dd>
  1031. <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>
  1032. </dd>
  1033. <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>
  1034. </dd>
  1035. <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>
  1036. </dd>
  1037. <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>
  1038. </dd>
  1039. <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>
  1040. </dd>
  1041. <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>
  1042. <div class="admonition note">
  1043. <p class="admonition-title">Note</p>
  1044. <p>This call only affects nonkinematic actors.</p>
  1045. </div>
  1046. </dd>
  1047. <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>
  1048. </dd>
  1049. <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>
  1050. <div class="admonition note">
  1051. <p class="admonition-title">Note</p>
  1052. <p>This call only affects nonkinematic actors.</p>
  1053. </div>
  1054. </dd>
  1055. <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>
  1056. <div class="admonition note">
  1057. <p class="admonition-title">Note</p>
  1058. <p>This call only affects nonkinematic actors.</p>
  1059. </div>
  1060. </dd>
  1061. <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>
  1062. <div class="admonition note">
  1063. <p class="admonition-title">Note</p>
  1064. <p>This call only affects nonkinematic actors.</p>
  1065. </div>
  1066. </dd>
  1067. <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>
  1068. </dd>
  1069. <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>
  1070. travelling at the given <em>velocity</em>.</p>
  1071. <div class="admonition note">
  1072. <p class="admonition-title">Note</p>
  1073. <p>This call only affects nonkinematic actors.</p>
  1074. </div>
  1075. </dd>
  1076. <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>
  1077. <div class="admonition note">
  1078. <p class="admonition-title">Note</p>
  1079. <p>This call only affects nonkinematic actors.</p>
  1080. </div>
  1081. </dd>
  1082. <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>
  1083. </dd>
  1084. <dt><strong>actor_wake_up</strong> (pw, actor)</dt><dd><p>Wakes the <em>actor</em> up.</p>
  1085. </dd>
  1086. <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>
  1087. </dd>
  1088. </dl>
  1089. </section>
  1090. <section id="mover">
  1091. <h3>Mover<a class="headerlink" href="#mover" title="Permalink to this headline">¶</a></h3>
  1092. <dl class="simple">
  1093. <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>
  1094. </dd>
  1095. <dt><strong>mover_destroy</strong> (pw, mover)</dt><dd><p>Destroys the <em>mover</em>.</p>
  1096. </dd>
  1097. <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>
  1098. </dd>
  1099. <dt><strong>mover_set_height</strong> (pw, mover, height)</dt><dd><p>Sets the <em>height</em> of the <em>mover</em> capsule.</p>
  1100. </dd>
  1101. <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>
  1102. </dd>
  1103. <dt><strong>mover_set_radius</strong> (pw, mover, radius)</dt><dd><p>Sets the <em>radius</em> of the <em>mover</em> capsule.</p>
  1104. </dd>
  1105. <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>
  1106. </dd>
  1107. <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>
  1108. </dd>
  1109. <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>
  1110. </dd>
  1111. <dt><strong>mover_position</strong> (pw, mover)<span class="classifier">Vector3</span></dt><dd><p>Returns the position of the <em>mover</em>.</p>
  1112. </dd>
  1113. <dt><strong>mover_set_position</strong> (pw, mover, position)</dt><dd><p>Teleports the <em>mover</em> to the specified <em>position</em>.</p>
  1114. </dd>
  1115. <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>
  1116. </dd>
  1117. <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>
  1118. </dd>
  1119. <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.
  1120. The <em>mover</em> will slide against physical actors.</p>
  1121. </dd>
  1122. <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>
  1123. </dd>
  1124. <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>
  1125. </dd>
  1126. <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>
  1127. </dd>
  1128. <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>
  1129. </dd>
  1130. </dl>
  1131. </section>
  1132. </section>
  1133. <section id="profiler">
  1134. <h2>Profiler<a class="headerlink" href="#profiler" title="Permalink to this headline">¶</a></h2>
  1135. <dl class="simple">
  1136. <dt><strong>enter_scope</strong> (name)</dt><dd><p>Starts a new profile scope with the given <em>name</em>.</p>
  1137. </dd>
  1138. <dt><strong>leave_scope</strong> ()</dt><dd><p>Ends the last profile scope.</p>
  1139. </dd>
  1140. <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>
  1141. </dd>
  1142. </dl>
  1143. </section>
  1144. <section id="renderworld">
  1145. <h2>RenderWorld<a class="headerlink" href="#renderworld" title="Permalink to this headline">¶</a></h2>
  1146. <dl class="simple">
  1147. <dt><strong>enable_debug_drawing</strong> (rw, enable)</dt><dd><p>Sets whether to <em>enable</em> debug drawing.</p>
  1148. </dd>
  1149. </dl>
  1150. <section id="mesh">
  1151. <h3>Mesh<a class="headerlink" href="#mesh" title="Permalink to this headline">¶</a></h3>
  1152. <dl class="simple">
  1153. <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>
  1154. </dd>
  1155. <dt><strong>mesh_destroy</strong> (rw, mesh)</dt><dd><p>Destroys the <em>mesh</em> instance.</p>
  1156. </dd>
  1157. <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>
  1158. </dd>
  1159. <dt><strong>mesh_material</strong> (rw, mesh)<span class="classifier">Material</span></dt><dd><p>Returns the material of the <em>mesh</em>.</p>
  1160. </dd>
  1161. <dt><strong>mesh_set_material</strong> (rw, mesh, material)</dt><dd><p>Sets the <em>material</em> of the <em>mesh</em>.</p>
  1162. </dd>
  1163. <dt><strong>mesh_set_visible</strong> (rw, mesh, visible)</dt><dd><p>Sets whether the <em>mesh</em> is <em>visible</em>.</p>
  1164. </dd>
  1165. <dt><strong>mesh_set_cast_shadows</strong> (rw, mesh, cast_shadows)</dt><dd><p>Sets whether the <em>mesh</em> cast shadows.</p>
  1166. </dd>
  1167. <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>
  1168. </dd>
  1169. <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>
  1170. </dd>
  1171. </dl>
  1172. </section>
  1173. <section id="sprite">
  1174. <h3>Sprite<a class="headerlink" href="#sprite" title="Permalink to this headline">¶</a></h3>
  1175. <dl class="simple">
  1176. <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>
  1177. </dd>
  1178. <dt><strong>sprite_destroy</strong> (rw, sprite)</dt><dd><p>Destroys the <em>sprite</em> instance.</p>
  1179. </dd>
  1180. <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>
  1181. </dd>
  1182. <dt><strong>sprite_material</strong> (rw, sprite)<span class="classifier">Material</span></dt><dd><p>Returns the material of the <em>sprite</em>.</p>
  1183. </dd>
  1184. <dt><strong>sprite_set_material</strong> (rw, sprite, material)</dt><dd><p>Sets the <em>material</em> of the <em>sprite</em>.</p>
  1185. </dd>
  1186. <dt><strong>sprite_set_frame</strong> (rw, sprite, index)</dt><dd><p>Sets the frame <em>index</em> of the <em>sprite</em>.
  1187. The <em>index</em> automatically wraps if it greater than the total number of
  1188. frames in the sprite.</p>
  1189. </dd>
  1190. <dt><strong>sprite_set_visible</strong> (rw, sprite, visible)</dt><dd><p>Sets whether the <em>sprite</em> is <em>visible</em>.</p>
  1191. </dd>
  1192. <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>
  1193. </dd>
  1194. <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>
  1195. </dd>
  1196. <dt><strong>sprite_set_layer</strong> (rw, sprite, layer)</dt><dd><p>Sets the rendering <em>layer</em> of the <em>sprite</em>.</p>
  1197. </dd>
  1198. <dt><strong>sprite_set_depth</strong> (rw, sprite, depth)</dt><dd><p>Sets the rendering <em>depth</em> of the <em>sprite</em>.</p>
  1199. </dd>
  1200. <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>
  1201. </dd>
  1202. <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
  1203. intersection point with the <em>sprite</em> or -1.0 if no intersection.</p>
  1204. </dd>
  1205. </dl>
  1206. </section>
  1207. <section id="light">
  1208. <h3>Light<a class="headerlink" href="#light" title="Permalink to this headline">¶</a></h3>
  1209. <dl class="simple">
  1210. <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.
  1211. 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>
  1212. </dd>
  1213. <dt><strong>light_destroy</strong> (rw, light)</dt><dd><p>Destroys the <em>light</em> instance.</p>
  1214. </dd>
  1215. <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>
  1216. </dd>
  1217. <dt><strong>light_type</strong> (rw, light)<span class="classifier">string</span></dt><dd><p>Returns the type of the <em>light</em>.
  1218. 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>
  1219. </dd>
  1220. <dt><strong>light_color</strong> (rw, light)<span class="classifier">Color4</span></dt><dd><p>Returns the color of the <em>light</em>.</p>
  1221. </dd>
  1222. <dt><strong>light_range</strong> (rw, light)<span class="classifier">float</span></dt><dd><p>Returns the range of the <em>light</em>.</p>
  1223. </dd>
  1224. <dt><strong>light_intensity</strong> (rw, light)<span class="classifier">float</span></dt><dd><p>Returns the intensity of the <em>light</em>.</p>
  1225. </dd>
  1226. <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>
  1227. </dd>
  1228. <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>
  1229. </dd>
  1230. <dt><strong>light_set_type</strong> (rw, light, type)</dt><dd><p>Sets the <em>type</em> of the <em>light</em>.</p>
  1231. </dd>
  1232. <dt><strong>light_set_color</strong> (rw, light, color)</dt><dd><p>Sets the <em>color</em> of the <em>light</em>.</p>
  1233. </dd>
  1234. <dt><strong>light_set_range</strong> (rw, light, range)</dt><dd><p>Sets the <em>range</em> of the <em>light</em>.</p>
  1235. </dd>
  1236. <dt><strong>light_set_intensity</strong> (rw, light, intensity)</dt><dd><p>Sets the <em>intensity</em> of the <em>light</em>.</p>
  1237. </dd>
  1238. <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>
  1239. </dd>
  1240. <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>
  1241. </dd>
  1242. <dt><strong>light_set_cast_shadows</strong> (rw, light, cast_shadows)</dt><dd><p>Sets whether the <em>light</em> casts shadows.</p>
  1243. </dd>
  1244. <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>
  1245. </dd>
  1246. </dl>
  1247. </section>
  1248. <section id="fog">
  1249. <h3>Fog<a class="headerlink" href="#fog" title="Permalink to this headline">¶</a></h3>
  1250. <dl class="simple">
  1251. <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.
  1252. Note that the fog component is limited to one instance per World. Every call
  1253. to this function will overwrite any previously created fog instance.</p>
  1254. </dd>
  1255. <dt><strong>fog_destroy</strong> (rw, fog)</dt><dd><p>Destroys the <em>fog</em> instance.</p>
  1256. </dd>
  1257. <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>
  1258. </dd>
  1259. <dt><strong>fog_set_color</strong> (rw, fog, color)</dt><dd><p>Sets the <em>color</em> of the <em>fog</em>.</p>
  1260. </dd>
  1261. <dt><strong>fog_set_density</strong> (rw, fog, density)</dt><dd><p>Sets the <em>density</em> of the <em>fog</em>.</p>
  1262. </dd>
  1263. <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>
  1264. </dd>
  1265. <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>
  1266. </dd>
  1267. <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>
  1268. </dd>
  1269. <dt><strong>fog_set_enabled</strong> (rw, fog, enable)</dt><dd><p>Sets whether the <em>fog</em> is <em>enabled</em>.</p>
  1270. </dd>
  1271. </dl>
  1272. </section>
  1273. </section>
  1274. <section id="resourcepackage">
  1275. <h2>ResourcePackage<a class="headerlink" href="#resourcepackage" title="Permalink to this headline">¶</a></h2>
  1276. <dl>
  1277. <dt><strong>load</strong> (package)</dt><dd><p>Loads all the resources in the <em>package</em>.</p>
  1278. <div class="admonition note">
  1279. <p class="admonition-title">Note</p>
  1280. <p>The resources are not immediately available after the call is made,
  1281. instead, you have to poll for completion with has_loaded().</p>
  1282. </div>
  1283. </dd>
  1284. <dt><strong>unload</strong> (package)</dt><dd><p>Unloads all the resources in the <em>package</em>.</p>
  1285. </dd>
  1286. <dt><strong>flush</strong> (package)</dt><dd><p>Waits until the <em>package</em> has been loaded.</p>
  1287. </dd>
  1288. <dt><strong>has_loaded</strong> (package)<span class="classifier">bool</span></dt><dd><p>Returns whether the <em>package</em> has been loaded.</p>
  1289. </dd>
  1290. </dl>
  1291. </section>
  1292. <section id="scenegraph">
  1293. <h2>SceneGraph<a class="headerlink" href="#scenegraph" title="Permalink to this headline">¶</a></h2>
  1294. <dl class="simple">
  1295. <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>
  1296. </dd>
  1297. <dt><strong>destroy</strong> (sg, transform)</dt><dd><p>Destroys the <em>transform</em> instance.</p>
  1298. </dd>
  1299. <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>
  1300. </dd>
  1301. <dt><strong>owner</strong> (sg, transform)<span class="classifier">UnitId</span></dt><dd><p>Returns the unit that owns <em>transform</em>.</p>
  1302. </dd>
  1303. <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>
  1304. </dd>
  1305. <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>
  1306. </dd>
  1307. <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>
  1308. </dd>
  1309. <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>
  1310. </dd>
  1311. <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>
  1312. </dd>
  1313. <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>
  1314. </dd>
  1315. <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>
  1316. </dd>
  1317. <dt><strong>set_local_position</strong> (sg, transform, position)</dt><dd><p>Sets the local <em>position</em> of the <em>transform</em>.</p>
  1318. </dd>
  1319. <dt><strong>set_local_rotation</strong> (sg, transform, rotation)</dt><dd><p>Sets the local <em>rotation</em> of the <em>transform</em>.</p>
  1320. </dd>
  1321. <dt><strong>set_local_scale</strong> (sg, transform, scale)</dt><dd><p>Sets the local <em>scale</em> of the <em>transform</em>.</p>
  1322. </dd>
  1323. <dt><strong>set_local_pose</strong> (sg, transform, pose)</dt><dd><p>Sets the local <em>pose</em> of the <em>transform</em>.</p>
  1324. </dd>
  1325. <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
  1326. parent. Set child_local_* to modify the child position after it has been
  1327. linked to the parent, otherwise che child will be positioned at the
  1328. location of its parent.</p>
  1329. </dd>
  1330. <dt><strong>unlink</strong> (sg, child)</dt><dd><p>Unlinks <em>child</em> from its parent if it has any. After unlinking, the local
  1331. pose of the <em>child</em> is set to its previous world pose.</p>
  1332. </dd>
  1333. <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>
  1334. if <em>child</em> has no parent.</p>
  1335. </dd>
  1336. <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>
  1337. if <em>parent</em> has no children.</p>
  1338. </dd>
  1339. <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>
  1340. if <em>child</em> has no sibling.</p>
  1341. </dd>
  1342. </dl>
  1343. </section>
  1344. <section id="soundworld">
  1345. <h2>SoundWorld<a class="headerlink" href="#soundworld" title="Permalink to this headline">¶</a></h2>
  1346. <dl class="simple">
  1347. <dt><strong>stop_all</strong> (sound_world)</dt><dd><p>Stops all the sounds in the world.</p>
  1348. </dd>
  1349. <dt><strong>pause_all</strong> (sound_world)</dt><dd><p>Pauses all the sounds in the world</p>
  1350. </dd>
  1351. <dt><strong>resume_all</strong> (sound_world)</dt><dd><p>Resumes all previously paused sounds in the world.</p>
  1352. </dd>
  1353. <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>
  1354. </dd>
  1355. <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
  1356. <em>group</em> is multiplied by the group’s volume.</p>
  1357. </dd>
  1358. </dl>
  1359. </section>
  1360. <section id="unitmanager">
  1361. <h2>UnitManager<a class="headerlink" href="#unitmanager" title="Permalink to this headline">¶</a></h2>
  1362. <dl class="simple">
  1363. <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
  1364. that world.</p>
  1365. </dd>
  1366. <dt><strong>destroy</strong> (unit)</dt><dd><p>Destroys the given <em>unit</em>.</p>
  1367. </dd>
  1368. <dt><strong>alive</strong> (unit)<span class="classifier">bool</span></dt><dd><p>Returns whether the unit is alive.</p>
  1369. </dd>
  1370. </dl>
  1371. </section>
  1372. <section id="window">
  1373. <h2>Window<a class="headerlink" href="#window" title="Permalink to this headline">¶</a></h2>
  1374. <dl class="simple">
  1375. <dt><strong>show</strong> ()</dt><dd><p>Shows the window.</p>
  1376. </dd>
  1377. <dt><strong>hide</strong> ()</dt><dd><p>Hides the window.</p>
  1378. </dd>
  1379. <dt><strong>resize</strong> (width, height)</dt><dd><p>Resizes the window to <em>width</em> and <em>height</em>.</p>
  1380. </dd>
  1381. <dt><strong>move</strong> (x, y)</dt><dd><p>Moves the window to <em>x</em> and <em>y</em>.</p>
  1382. </dd>
  1383. <dt><strong>minimize</strong> ()</dt><dd><p>Minimizes the window.</p>
  1384. </dd>
  1385. <dt><strong>maximize</strong> ()</dt><dd><p>Maximizes the window.</p>
  1386. </dd>
  1387. <dt><strong>restore</strong> ()</dt><dd><p>Restores the window.</p>
  1388. </dd>
  1389. <dt><strong>title</strong> ()<span class="classifier">string</span></dt><dd><p>Returns the title of the window.</p>
  1390. </dd>
  1391. <dt><strong>set_title</strong> (title)</dt><dd><p>Sets the title of the window.</p>
  1392. </dd>
  1393. <dt><strong>show_cursor</strong> (show)</dt><dd><p>Sets whether to <em>show</em> the cursor.</p>
  1394. </dd>
  1395. <dt><strong>set_fullscreen</strong> (fullscreen)</dt><dd><p>Sets whether the window is <em>fullscreen</em>.</p>
  1396. </dd>
  1397. <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>,
  1398. <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>,
  1399. <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>,
  1400. <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>
  1401. </dd>
  1402. <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>
  1403. 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
  1404. automatically re-centers it every time it is moved.</p>
  1405. </dd>
  1406. </dl>
  1407. </section>
  1408. <section id="world">
  1409. <h2>World<a class="headerlink" href="#world" title="Permalink to this headline">¶</a></h2>
  1410. <dl class="simple">
  1411. <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>
  1412. </dd>
  1413. <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>
  1414. </dd>
  1415. <dt><strong>destroy_unit</strong> (world, unit)</dt><dd><p>Destroys the given <em>unit</em>.</p>
  1416. </dd>
  1417. <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>
  1418. </dd>
  1419. <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>
  1420. </dd>
  1421. <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.
  1422. If there are multiple units with the same name, a random one will be returned.</p>
  1423. </dd>
  1424. <dt><strong>update_animations</strong> (world, dt)</dt><dd><p>Update all animations with <em>dt</em>.</p>
  1425. </dd>
  1426. <dt><strong>update_scene</strong> (world, dt)</dt><dd><p>Updates the scene with <em>dt</em>.</p>
  1427. </dd>
  1428. <dt><strong>update</strong> (world, dt)</dt><dd><p>Updates the world with <em>dt</em>.</p>
  1429. </dd>
  1430. <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
  1431. enable depth test when rendering the lines.</p>
  1432. </dd>
  1433. <dt><strong>destroy_debug_line</strong> (world, line)</dt><dd><p>Destroys the debug <em>line</em>.</p>
  1434. </dd>
  1435. <dt><strong>create_screen_gui</strong> (world)<span class="classifier">Gui</span></dt><dd><p>Creates a new Gui for 2D drawing.</p>
  1436. </dd>
  1437. <dt><strong>create_world_gui</strong> (world)<span class="classifier">Gui</span></dt><dd><p>Creates a new Gui for 3D drawing.</p>
  1438. </dd>
  1439. <dt><strong>destroy_gui</strong> (world, gui)</dt><dd><p>Destroys the <em>gui</em>.</p>
  1440. </dd>
  1441. <dt><strong>scene_graph</strong> (world)<span class="classifier">SceneGraph</span></dt><dd><p>Returns the scene graph.</p>
  1442. </dd>
  1443. <dt><strong>render_world</strong> (world)<span class="classifier">RenderWorld</span></dt><dd><p>Returns the render sub-world.</p>
  1444. </dd>
  1445. <dt><strong>physics_world</strong> (world)<span class="classifier">PhysicsWorld</span></dt><dd><p>Returns the physics sub-world.</p>
  1446. </dd>
  1447. <dt><strong>sound_world</strong> (world)<span class="classifier">SoundWorld</span></dt><dd><p>Returns the sound sub-world.</p>
  1448. </dd>
  1449. <dt><strong>animation_state_machine</strong> (world)<span class="classifier">AnimationStateMachine</span></dt><dd><p>Returns the animation state machine.</p>
  1450. </dd>
  1451. </dl>
  1452. <section id="camera">
  1453. <h3>Camera<a class="headerlink" href="#camera" title="Permalink to this headline">¶</a></h3>
  1454. <dl class="simple">
  1455. <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.
  1456. 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>
  1457. </dd>
  1458. <dt><strong>camera_destroy</strong> (world, camera)</dt><dd><p>Destroys the <em>camera</em> instance.</p>
  1459. </dd>
  1460. <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>
  1461. </dd>
  1462. <dt><strong>camera_set_projection_type</strong> (world, camera, projection)</dt><dd><p>Sets the projection type of the <em>camera</em>.
  1463. 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>
  1464. </dd>
  1465. <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>.
  1466. 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>
  1467. </dd>
  1468. <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>
  1469. </dd>
  1470. <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>
  1471. </dd>
  1472. <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>
  1473. </dd>
  1474. <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>
  1475. </dd>
  1476. <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>
  1477. </dd>
  1478. <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>
  1479. </dd>
  1480. <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.
  1481. The horizontal size is proportional to the viewport’s aspect ratio.</p>
  1482. </dd>
  1483. <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>
  1484. </dd>
  1485. <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>
  1486. </dd>
  1487. </dl>
  1488. </section>
  1489. <section id="sound">
  1490. <h3>Sound<a class="headerlink" href="#sound" title="Permalink to this headline">¶</a></h3>
  1491. <dl class="simple">
  1492. <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
  1493. <em>range</em> the sound will not be heard. If <em>position</em> is not specified the
  1494. sound will be played as a 2d-sound (i.e. no attenuation nor spatialization).
  1495. <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>
  1496. </dd>
  1497. <dt><strong>stop_sound</strong> (world, id)</dt><dd><p>Stops the sound with the given <em>id</em>.</p>
  1498. </dd>
  1499. <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>.
  1500. After this call, the sound <em>id</em> will follow the unit <em>unit</em>.</p>
  1501. </dd>
  1502. <dt><strong>set_listener_pose</strong> (world, pose)</dt><dd><p>Sets the <em>pose</em> of the listener.</p>
  1503. </dd>
  1504. <dt><strong>set_sound_position</strong> (world, id, position)</dt><dd><p>Sets the <em>position</em> of the sound <em>id</em>.</p>
  1505. </dd>
  1506. <dt><strong>set_sound_range</strong> (world, id, range)</dt><dd><p>Sets the <em>range</em> of the sound <em>id</em>.</p>
  1507. </dd>
  1508. <dt><strong>set_sound_volume</strong> (world, id, volume)</dt><dd><p>Sets the <em>volume</em> of the sound <em>id</em>.</p>
  1509. </dd>
  1510. </dl>
  1511. </section>
  1512. <section id="level">
  1513. <h3>Level<a class="headerlink" href="#level" title="Permalink to this headline">¶</a></h3>
  1514. <dl class="simple">
  1515. <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>
  1516. </dd>
  1517. <dt><strong>destroy_level</strong> (world, level)</dt><dd><p>Destroys a level previously loaded by load_level(). Only units directly
  1518. spawned by the level are unspawned.</p>
  1519. </dd>
  1520. </dl>
  1521. </section>
  1522. </section>
  1523. </section>
  1524. </div>
  1525. </div>
  1526. <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
  1527. <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>
  1528. <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>
  1529. </div>
  1530. <hr/>
  1531. <div role="contentinfo">
  1532. <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.
  1533. <span class="lastupdated">Last updated on Jan 19, 2026.
  1534. </span></p>
  1535. </div>
  1536. Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
  1537. <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
  1538. provided by <a href="https://readthedocs.org">Read the Docs</a>.
  1539. </footer>
  1540. </div>
  1541. </div>
  1542. </section>
  1543. </div>
  1544. <script>
  1545. jQuery(function () {
  1546. SphinxRtdTheme.Navigation.enable(true);
  1547. });
  1548. </script>
  1549. <!-- Theme Analytics -->
  1550. <script async src="https://www.googletagmanager.com/gtag/js?id=G-XNVGCMNDZH"></script>
  1551. <script>
  1552. window.dataLayer = window.dataLayer || [];
  1553. function gtag(){dataLayer.push(arguments);}
  1554. gtag('js', new Date());
  1555. gtag('config', 'G-XNVGCMNDZH', {
  1556. 'anonymize_ip': true,
  1557. });
  1558. </script>
  1559. </body>
  1560. </html>