lua_api.html 106 KB

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