lua_api.html 101 KB

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