lua_api.html 112 KB

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