lua_api.html 92 KB

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