lua_api.html 102 KB

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