lua_api.html 110 KB

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