lua_api.html 107 KB

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