lua_api.html 99 KB

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