lua_api.html 108 KB

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