lua_api.rst 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512
  1. =================
  2. Lua API reference
  3. =================
  4. AnimationStateMachine
  5. =====================
  6. **instance** (asm, unit) : Id
  7. Returns the ID of the state machine owned by the *unit*, or ``nil``.
  8. **variable_id** (asm, state_machine, name) : Id
  9. Returns the ID of the variable *name* in the *state_machine*.
  10. **variable** (asm, state_machine, variable_id) : number
  11. Returns the value of the *variable_id* in the *state_machine*.
  12. **set_variable** (asm, state_machine, variable_id, value)
  13. Sets the *value* of the *variable_id* in the *state_machine*.
  14. **trigger** (asm, state_machine, event)
  15. Triggers the *event* in the *state_machine*.
  16. DebugLine
  17. =========
  18. **add_line** (debug_line, start, end, color)
  19. Adds a line from *start* to *end* with the given *color*.
  20. **add_axes** (debug_line, tm, length)
  21. Adds lines for each axis with the given *length*.
  22. **add_arc** (debug_line, center, radius, plane_normal, midpoint_normal, color, [circle_segments = 36]);
  23. Adds an arc at *center* with the given *radius* and *plane_normal* and *midpoint_normal* vectors.
  24. **add_circle** (debug_line, center, radius, normal, color, [segments = 36])
  25. Adds a circle at *center* with the given *radius* and *normal* vector.
  26. **add_cone** (debug_line, from, to, radius, color, [segments = 36])
  27. Adds a cone with the base centered at *from* and the tip at *to*.
  28. **add_sphere** (debug_line, center, radius, color, [segments = 36])
  29. Adds a sphere at *center* with the given *radius*.
  30. **add_obb** (debug_line, tm, half_extents, color)
  31. Adds an orientd bounding box. *tm* describes the position and orientation of
  32. the box. *half_extents* describes the size of the box along the axis.
  33. **add_frustum** (debug_line, mvp, color)
  34. Adds a frustum defined by *mvp*.
  35. **reset** (debug_line)
  36. Resets all the lines.
  37. **submit** (debug_line)
  38. Submits the lines to renderer for drawing.
  39. Device
  40. ======
  41. **argv** () : table
  42. Returns a table containing the command line parameters the engine was started with.
  43. **platform** () : string
  44. Returns a string identifying what platform the engine is running on.
  45. It can be either ``android``, ``linux`` or ``windows``
  46. **architecture** () : string
  47. Returns a string identifying what architecture the engine is running on.
  48. It can be either ``32-bit`` or ``64-bit``.
  49. **version** () : string
  50. Returns a string identifying the engine version.
  51. The form is "major.minor.micro".
  52. **quit** ([exit_code])
  53. Quits the application. On platforms that support it, *exit_code* is
  54. returned to the system after the application exits.
  55. **resolution** () : float, float
  56. Returns the main window resolution (width, height).
  57. **create_world** () : World
  58. Creates a new world.
  59. **destroy_world** (world)
  60. Destroys the given *world*.
  61. **render** (world, camera)
  62. Renders *world* using *camera*.
  63. **create_resource_package** (name) : ResourcePackage
  64. Returns the resource package with the given *package_name* name.
  65. **destroy_resource_package** (package)
  66. Destroy a previously created resource *package*.
  67. .. note::
  68. To unload the resources loaded by the package, you have to call
  69. ResourcePackage.unload() first.
  70. **screenshot** (path)
  71. Captures a screenshot of the main window's backbuffer and saves it at *path* in PNG format.
  72. The global callback ``screenshot (path)`` will be called after the file is written to disk.
  73. .. note::
  74. Only available in debug and development builds.
  75. **console_send** (table)
  76. Sends the given lua *table* to clients connected to the engine.
  77. Values can be either ``nil``, bool, number, string, table, array, Vector2, Vector3, Quaternion, Matrix4x4 or Color4.
  78. **can_get** (type, name) : bool
  79. Returns whether the resource (type, name) is loaded.
  80. When resource autoload is enabled it always returns true.
  81. **enable_resource_autoload** (enable)
  82. Sets whether resources should be automatically loaded when accessed.
  83. **temp_count** () : int, int, int
  84. Returns the number of temporary objects used by Lua.
  85. **set_temp_count** (nv, nq, nm)
  86. Sets the number of temporary objects used by Lua.
  87. **guid** () : string
  88. Returns a new GUID.
  89. **set_timestep_policy** (policy)
  90. Sets the timestep policy:
  91. * ``variable``: the timestep is the time it took for the previous frame to simulate. This is the default;
  92. * ``smoothed``: the timestep is computed as an average of the previous delta times.
  93. **set_timestep_smoothing** (num_samples, num_outliers, average_cap)
  94. Sets the number of samples to be averaged, the outliers to be excluded and the maximum
  95. allowed deviation in percent from the previous average. Given a delta time series DTs, and
  96. a previous average AVGp:
  97. * DTs = [ .33; .30; .32; .33; .24; .33; .25; .35; .33; .42 ]
  98. * AVGp = 0.33
  99. A call to set_smoothing(10, 2, 0.1) would compute the new average like so:
  100. 1. Remove the 2 minimum and maximum values in DTs;
  101. 2. Compute the average for the remaining 6 values in DTs: AVG = 0.323.
  102. 3. Smooth the newly computed average: AVG = lerp(AVGp, AVG, 0.1) = 0.329.
  103. Display
  104. =======
  105. **modes** () : table
  106. Returns an array of `DisplayMode`_ tables.
  107. **set_mode** (id)
  108. Sets the display mode *id*.
  109. The initial display mode is automatically reset when the program terminates.
  110. DisplayMode
  111. -----------
  112. DisplayMode is a lua table with 3 fields:
  113. * ``id``: The id of the display mode.
  114. * ``width``: The width of the display mode.
  115. * ``height``: The height of the display mode.
  116. Gui
  117. ===
  118. **move** (gui, pos)
  119. Moves the Gui to *pos*.
  120. **triangle** (gui, a, b, c, color [, depth])
  121. Draws a triangle defined by vertices *a*, *b* and *c*.
  122. Objects with a lower depth are drawn in front. If depth is omitted its value
  123. is set to 0.
  124. **triangle_3d** (gui, local_pose, a, b, c, color [, depth])
  125. Draws a 3D triangle defined by vertices *a*, *b* and *c*.
  126. **rect** (gui, pos, size, color)
  127. Draws a rectangle.
  128. If pos is a Vector3, the z element specifies the drawing depth. Objects with
  129. a lower depth are drawn in front. If pos is a Vector2, the z elements is set
  130. to 0.
  131. **rect_3d** (gui, local_pose, pos, size, color [, depth])
  132. Draws a 3D rectangle.
  133. **image** (gui, pos, size, material_resource, color)
  134. Draws an image.
  135. If pos is a Vector3, the z element specifies the drawing depth. Objects with
  136. a lower depth are drawn in front. If pos is a Vector2, the z elements is set
  137. to 0.
  138. **image_3d** (gui, local_pose, pos, size, material_resource, color [, depth])
  139. Draws a 3D image.
  140. **image_uv** (gui, pos, size, uv0, uv1, material_resource, color)
  141. Draws an image with explicit UV coordinates.
  142. If pos is a Vector3, the z element specifies the drawing depth. Objects with
  143. a lower depth are drawn in front. If pos is a Vector2, the z elements is set
  144. to 0.
  145. **image_3d_uv** (gui, local_pose, pos, size, uv0, uv1, material_resource, color [, depth])
  146. Draws a 3D image with explicit UV coordinates.
  147. **text** (gui, pos, font_size, str, font_resource, material_resource, color)
  148. Draws text.
  149. If pos is a Vector3, the z element specifies the drawing depth. Objects with
  150. a lower depth are drawn in front. If pos is a Vector2, the z elements is set
  151. to 0.
  152. **text_3d** (gui, local_pose, pos, font_size, str, font_resource, material_resource, color [, depth])
  153. Draws 3D text.
  154. **material** (material_resource) : Material
  155. Returns the material *material_resource*.
  156. Input
  157. =====
  158. **events** () : table
  159. Returns an array of `InputEvent`_ tables.
  160. InputEvent
  161. ----------
  162. InputEvent is a lua table with 4 fields:
  163. * ``id``: The id of the button or axis as returned by ``Keyboard.button_id()`` for example.
  164. * ``type``: One of the values from `InputEventType`_.
  165. * ``value``: The value of the axis as a Vector3 or ``nil`` when ``type`` is not an axis event.
  166. * ``device``: The input device that generated the event. This is one of ``Keyboard``, ``Mouse``, ``Pad1`` etc.
  167. InputEventType
  168. --------------
  169. * ``BUTTON_PRESSED``: A button has been pressed.
  170. * ``BUTTON_RELEASED``: A button has been released.
  171. * ``AXIS_CHANGED``: An axis changed its value.
  172. Keyboard
  173. --------
  174. **name** () : string
  175. Returns the name of keyboard.
  176. **connected** () : bool
  177. Returns whether the keyboard is connected and functioning.
  178. **num_buttons** () : int
  179. Returns the number of buttons of the keyboard.
  180. **num_axes** () : int
  181. Returns the number of axes of the keyboard.
  182. **pressed** (id) : bool
  183. Returns whether the button *id* is pressed in the current frame.
  184. **released** (id) : bool
  185. Returns whether the button *id* is released in the current frame.
  186. **any_pressed** () : bool
  187. Returns the *id* of the first button that was pressed in the current frame
  188. or ``nil`` if no buttons were pressed at all.
  189. **any_released** () : bool
  190. Returns the *id* of the first button that was released in the current frame
  191. or ``nil`` if no buttons were released at all.
  192. **button** (id) : float
  193. Returns the value of the button *id* in the range [0..1].
  194. **button_name** (id) : string
  195. Returns the name of the button *id*.
  196. **button_id** (name) : int
  197. Returns the *id* of the button *name* or ``nil`` if no matching button is found.
  198. Keyboard Button Names
  199. ~~~~~~~~~~~~~~~~~~~~~
  200. * ``tab``, ``enter``, ``escape``, ``space``, ``backspace``
  201. * ``num_lock``, ``numpad_enter``, ``numpad_.``, ``numpad_*``, ``numpad_+``, ``numpad_-``, ``numpad_/``, ``numpad_0``, ``numpad_1``, ``numpad_2``, ``numpad_3``, ``numpad_4``, ``numpad_5``, ``numpad_6``, ``numpad_7``, ``numpad_8``, ``numpad_9``
  202. * ``f1``, ``f2``, ``f3``, ``f4``, ``f5``, ``f6``, ``f7``, ``f8``, ``f9``, ``f10``, ``f11``, ``f12``
  203. * ``home``, ``left``, ``up``, ``right``, ``down``, ``page_up``, ``page_down``, ``ins``, ``del``, ``end``
  204. * ``ctrl_left``, ``ctrl_right``, ``shift_left``, ``shift_right``, ``caps_lock``, ``alt_left``, ``alt_right``, ``super_left``, ``super_right``
  205. * ``0``, ``1``, ``2``, ``3``, ``4``, ``5``, ``6``, ``7``, ``8``, ``9``
  206. * ``a``, ``b``, ``c``, ``d``, ``e``, ``f``, ``g``, ``h``, ``i``, ``j``, ``k``, ``l``, ``m``, ``n``, ``o``, ``p``, ``q``, ``r``, ``s``, ``t``, ``u``, ``v``, ``w``, ``x``, ``y``, ``z``
  207. Keyboard Axis Names
  208. ~~~~~~~~~~~~~~~~~~~
  209. None.
  210. Mouse
  211. -----
  212. **name** () : string
  213. Returns the name of the mouse.
  214. **connected** () : bool
  215. Returns whether the mouse is connected and functioning.
  216. **num_buttons** () : int
  217. Returns the number of buttons of the mouse.
  218. **num_axes** () : int
  219. Returns the number of axes of the mouse.
  220. **pressed** (id) : bool
  221. Returns whether the button *id* is pressed in the current frame.
  222. **released** (id) : bool
  223. Returns whether the button *id* is released in the current frame.
  224. **any_pressed** () : bool
  225. Returns the *id* of the first button that was pressed in the current frame
  226. or ``nil`` if no buttons were pressed at all.
  227. **any_released** () : bool
  228. Returns the *id* of the first button that was released in the current frame
  229. or ``nil`` if no buttons were released at all.
  230. **button** (id) : float
  231. Returns the value of the button *id* in the range [0..1].
  232. **axis** (id) : Vector3
  233. Returns the value of the axis *id*.
  234. **button_name** (id) : string
  235. Returns the name of the button *id*.
  236. **axis_name** (id) : string
  237. Returns the name of the axis *id*.
  238. **button_id** (name) : int
  239. Returns the *id* of the button *name* or ``nil`` if no matching button is found.
  240. **axis_id** (name) : int
  241. Returns the *id* of the axis *name* or ``nil`` if no matching axis is found.
  242. Mouse Button Names
  243. ~~~~~~~~~~~~~~~~~~
  244. ``left``, ``middle``, ``right``, ``extra_1``, ``extra_2``
  245. Mouse Axis Names
  246. ~~~~~~~~~~~~~~~~
  247. * ``cursor``: Returns the cursor position (x, y) in screen coordinates.
  248. * ``cursor_delta``: Returns the delta of the cursor position (x, y) since last frame.
  249. * ``wheel``: Returns the movement of the mouse wheel in the y axis. Positive values of y mean upward scrolling, negative values mean downward scrolling.
  250. Touch
  251. -----
  252. **name** () : string
  253. Returns the name of the touch.
  254. **connected** () : bool
  255. Returns whether the touch is connected and functioning.
  256. **num_buttons** () : int
  257. Returns the number of buttons of the touch.
  258. **num_axes** () : int
  259. Returns the number of axes of the touch.
  260. **pressed** (id) : bool
  261. Returns whether the button *id* is pressed in the current frame.
  262. **released** (id) : bool
  263. Returns whether the button *id* is released in the current frame.
  264. **any_pressed** () : bool
  265. Returns the *id* of the first button that was pressed in the current frame
  266. or ``nil`` if no buttons were pressed at all.
  267. **any_released** () : bool
  268. Returns the *id* of the first button that was released in the current frame
  269. or ``nil`` if no buttons were released at all.
  270. **button** (id) : float
  271. Returns the value of the button *id* in the range [0..1].
  272. **axis** (id) : Vector3
  273. Returns the value of the axis *id*.
  274. **button_name** (id) : string
  275. Returns the name of the button *id*.
  276. **axis_name** (id) : string
  277. Returns the name of the axis *id*.
  278. **button_id** (name) : int
  279. Returns the *id* of the button *name* or ``nil`` if no matching button is found.
  280. **axis_id** (name) : int
  281. Returns the *id* of the axis *name* or ``nil`` if no matching axis is found.
  282. Pad1, Pad2, Pad3, Pad4
  283. ----------------------
  284. **name** () : string
  285. Returns the name of the pad.
  286. **connected** () : bool
  287. Returns whether the pad is connected and functioning.
  288. **num_buttons** () : int
  289. Returns the number of buttons of the pad.
  290. **num_axes** () : int
  291. Returns the number of axes of the pad.
  292. **pressed** (id) : bool
  293. Returns whether the button *id* is pressed in the current frame.
  294. **released** (id) : bool
  295. Returns whether the button *id* is released in the current frame.
  296. **any_pressed** () : bool
  297. Returns the *id* of the first button that was pressed in the current frame
  298. or ``nil`` if no buttons were pressed at all.
  299. **any_released** () : bool
  300. Returns the *id* of the first button that was released in the current frame
  301. or ``nil`` if no buttons were released at all.
  302. **button** (id) : float
  303. Returns the value of the button *id* in the range [0..1].
  304. **axis** (id) : Vector3
  305. Returns the value of the axis *id*.
  306. **button_name** (id) : string
  307. Returns the name of the button *id*.
  308. **axis_name** (id) : string
  309. Returns the name of the axis *id*.
  310. **button_id** (name) : int
  311. Returns the *id* of the button *name* or ``nil`` if no matching button is found.
  312. **axis_id** (name) : int
  313. Returns the *id* of the axis *name* or ``nil`` if no matching axis is found.
  314. **deadzone** (id) : deadzone_mode, deadzone_size
  315. Returns the deadzone mode and size for the axis *id*.
  316. **set_deadzone** (id, deadzone_mode, deadzone_size)
  317. Sets the *deadzone_mode* and *deadzone_size* for the axis *id*.
  318. Pad Button Names
  319. ~~~~~~~~~~~~~~~~
  320. * ``up``, ``down``, ``left``, ``right``
  321. * ``start``, ``back``, ``guide``
  322. * ``thumb_left``, ``thumb_right``
  323. * ``shoulder_left``, ``shoulder_right``
  324. * ``a``, ``b``, ``x``, ``y``
  325. Pad Axis Names
  326. ~~~~~~~~~~~~~~
  327. * ``left``, ``right``: Returns the direction (x, y) of the left or right thumbstick [-1; +1].
  328. * ``trigger_left``, ``trigger_right``: The z element represents the left or right trigger [0; +1].
  329. Material
  330. ========
  331. **set_float** (material, name, value)
  332. Sets the *value* of the variable *name*.
  333. **set_vector2** (material, name, value)
  334. Sets the *value* of the variable *name*.
  335. **set_vector3** (material, name, value)
  336. Sets the *value* of the variable *name*.
  337. **set_vector4** (material, name, value)
  338. Sets the *value* of the variable *name*.
  339. **set_matrix4x4** (material, name, value)
  340. Sets the *value* of the variable *name*.
  341. **set_texture** (material, sampler_name, texture_name)
  342. Sets the *texture_resource* of the sampler *sampler_name*.
  343. Math
  344. ====
  345. Vector3
  346. -------
  347. Constructors
  348. ~~~~~~~~~~~~
  349. **Vector3** (x, y, z) : Vector3
  350. Returns a new vector from individual elements.
  351. Functions
  352. ~~~~~~~~~
  353. **x** (v) : float
  354. Returns the x value of the vector.
  355. **y** (v) : float
  356. Returns the y value of the vector.
  357. **z** (v) : float
  358. Returns the z value of the vector.
  359. **.x** : float
  360. Returns/assigns the x value of the vector.
  361. **.y** : float
  362. Returns/assigns the y value of the vector.
  363. **.z** : float
  364. Returns/assigns the z value of the vector.
  365. **set_x** (v, x)
  366. Sets the value of the x value of the vector.
  367. **set_y** (v, y)
  368. Sets the value of the y value of the vector.
  369. **set_z** (v, z)
  370. Sets the value of the z value of the vector.
  371. **elements** (v) : float, float, float
  372. Returns the x, y and z elements of the vector.
  373. **add** (a, b) : Vector3
  374. Adds the vector *a* to *b* and returns the result.
  375. **subtract** (a, b) : Vector3
  376. Subtracts the vector *b* from *a* and returns the result.
  377. **multiply** (a, k) : Vector3
  378. Multiplies the vector *a* by the scalar *k* and returns the result.
  379. **dot** (a, b) : float
  380. Returns the dot product between the vectors *a* and *b*.
  381. **cross** (a, b) : Vector3
  382. Returns the cross product between the vectors *a* and *b*.
  383. **equal** (a, b) : bool
  384. Returns true whether the vectors *a* and *b* are equal.
  385. **length** (a) : float
  386. Returns the length of *a*.
  387. **length_squared** (a) : float
  388. Returns the squared length of *a*.
  389. **set_length** (a, len)
  390. Sets the length of *a* to *len*.
  391. **normalize** (a) : Vector3
  392. Normalizes *a* and returns the result.
  393. **distance** (a, b) : float
  394. Returns the distance between the points *a* and *b*.
  395. **distance_squared** (a, b) : float
  396. Returns the squared distance between the points *a* and *b*.
  397. **angle** (a, b) : float
  398. Returns the angle between the vectors *a* and *b*.
  399. **max** (a, b) : Vector3
  400. Returns a vector that contains the largest value for each element from *a* and *b*.
  401. **min** (a, b) : Vector3
  402. Returns a vector that contains the smallest value for each element from *a* and *b*.
  403. **lerp** (a, b, t) : Vector3
  404. Returns the linearly interpolated vector between *a* and *b* at time *t* in [0, 1].
  405. | **forward** () : Vector3
  406. | **backward** () : Vector3
  407. | **left** () : Vector3
  408. | **right** () : Vector3
  409. | **up** () : Vector3
  410. | **down** () : Vector3
  411. | Returns the corresponding semantic axis.
  412. **zero** () : Vector3
  413. Returns a vector with all values set to zero.
  414. **to_string** (v) : string
  415. Returns a string representing the vector *v*.
  416. Vector3Box
  417. ----------
  418. Constructors
  419. ~~~~~~~~~~~~
  420. **Vector3Box** () : Vector3Box
  421. Returns a new Vector3Box initialized with the zero vector.
  422. **Vector3Box** (v) : Vector3Box
  423. Returns a new Vector3Box from the Vector3 *v*.
  424. **Vector3Box** (x, y, z) : Vector3Box
  425. Returns a new Vector3Box from individual elements.
  426. Functions
  427. ~~~~~~~~~
  428. **store** (v)
  429. Stores the Vector3 *v* in the box.
  430. **store** (x, y, z)
  431. Stores Vector3(x, y, z) in the box.
  432. **unbox** () : Vector3
  433. Returns the stored vector from the box.
  434. Quaternion
  435. ----------
  436. Constructors
  437. ~~~~~~~~~~~~
  438. **Quaternion** (axis, angle) : Quaternion
  439. Returns a new quaternion from *axis* and *angle*.
  440. **from_elements** (x, y, z, w) : Quaternion
  441. Returns a new quaternion from individual elements.
  442. **from_axis_angle** (axis, angle) : Quaternion
  443. Returns a new quaternion from *axis* and *angle*.
  444. Functions
  445. ~~~~~~~~~
  446. **negate** (q) : Quaternion
  447. Negates the quaternion *q* and returns the result.
  448. **identity** () : Quaternion
  449. Returns the identity quaternion.
  450. **multiply** (a, b) : Quaternion
  451. Multiplies the quaternions *a* and *b*. (i.e. rotates first by *a* then by *b*).
  452. **multiply_by_scalar** (a, k) : Quaternion
  453. Multiplies the quaternion *a* by the scalar *k*.
  454. **dot** (a, b) : float
  455. Returns the dot product between quaternions *a* and *b*.
  456. **length** (q) : float
  457. Returns the length of *q*.
  458. **normalize** (q) : Quaternion
  459. Normalizes the quaternion *q* and returns the result.
  460. **conjugate** (q) : Quaternion
  461. Returns the conjugate of quaternion *q*.
  462. **inverse** (q) : Quaternion
  463. Returns the inverse of quaternion *q*.
  464. **power** (q, exp) : Quaternion
  465. Returns the quaternion *q* raised to the power of *exp*.
  466. **elements** (q) : float, float, float, float
  467. Returns the x, y, z and w elements of the quaternion.
  468. **look** (dir, [up]) : Quaternion
  469. Returns the quaternion describing the rotation needed to face towards *dir*.
  470. If *up* is not specified, Vector3.up() is used.
  471. **right** (q) : Vector3
  472. Returns the right axis of the rotation described by *q*.
  473. **up** (q) : Vector3
  474. Returns the up axis of the rotation described by *q*.
  475. **forward** (q) : Vector3
  476. Returns the forward axis of the rotation described by *q*.
  477. **lerp** (a, b, t) : Quaternion
  478. Returns the linearly interpolated quaternion between *a* and *b* at time *t* in [0, 1].
  479. It uses NLerp.
  480. **to_string** (q) : string
  481. Returns a string representing the quaternion *q*.
  482. QuaternionBox
  483. -------------
  484. Constructors
  485. ~~~~~~~~~~~~
  486. **QuaternionBox** () : QuaternionBox
  487. Returns a new QuaternionBox initialized with the identity quaternion.
  488. **QuaternionBox** (q) : QuaternionBox
  489. Returns a new QuaternionBox from the Quaternion *q*.
  490. **QuaternionBox** (x, y, z, w) : QuaternionBox
  491. Returns a new QuaternionBox from individual elements.
  492. Functions
  493. ~~~~~~~~~
  494. **store** (q)
  495. Stores the Quaternion *q* in the box.
  496. **store** (x, y, z, w)
  497. Stores Quaternion(x, y, z, w) in the box.
  498. **unbox** () : Quaternion
  499. Returns the stored quaternion from the box.
  500. Matrix4x4
  501. ---------
  502. Constructors
  503. ~~~~~~~~~~~~
  504. **Matrix4x4** (xx, xy, xz, xw, yx, yy, yz, yw, zx, zy, zz, zw, tx, ty, tz, tw) : Matrix4x4
  505. Returns a new matrix from individual elements.
  506. **from_quaternion** (q) : Matrix4x4
  507. Returns a new matrix from *q*.
  508. **from_translation** (t) : Matrix4x4
  509. Returns a new matrix from *t*.
  510. **from_quaternion_translation** (q, t) : Matrix4x4
  511. Returns a new matrix from *q* and *t*.
  512. **from_axes** (x, y, z, t) : Matrix4x4
  513. Returns a new matrix from *x*, *y*, *z* and *t*.
  514. Functions
  515. ~~~~~~~~~
  516. **copy** (m) : Matrix4x4
  517. Returns a copy of the matrix *m*.
  518. **add** (a, b) : Matrix4x4
  519. Adds the matrix *a* to *b* and returns the result.
  520. **subtract** (a, b) : Matrix4x4
  521. Subtracts the matrix *b* from *a* and returns the result.
  522. **multiply** (a, b) : Matrix4x4
  523. Multiplies the matrix *a* by *b* and returns the result. (i.e. transforms first by *a* then by *b*)
  524. **equal** (a, b) : bool
  525. Returns true whether the matrices *a* and *b* are equal.
  526. **transpose** (m) : Matrix4x4
  527. Transposes the matrix *m* and returns the result.
  528. **invert** (m) : Matrix4x4
  529. Inverts the matrix *m* and returns the result.
  530. **x** (m) : Vector3
  531. Returns the x axis of the matrix *m*.
  532. **y** (m) : Vector3
  533. Returns the y axis of the matrix *m*.
  534. **z** (m) : Vector3
  535. Returns the z axis of the matrix *m*.
  536. **set_x** (m, x)
  537. Sets the x axis of the matrix *m*.
  538. **set_y** (m, y)
  539. Sets the y axis of the matrix *m*.
  540. **set_z** (m, z)
  541. Sets the z axis of the matrix *m*.
  542. **translation** (m) : Vector3
  543. Returns the translation portion of the matrix *m*.
  544. **set_translation** (m, t)
  545. Sets the translation portion of the matrix *m*.
  546. **rotation** (m) : Quaternion
  547. Returns the rotation portion of the matrix *m*.
  548. **set_rotation** (m, r)
  549. Sets the rotation portion of the matrix *m*.
  550. **scale** (m) : Vector3
  551. Returns the scale of the matrix *m*.
  552. **set_scale** (m, r)
  553. Sets the scale of the matrix *m*.
  554. **identity** ()
  555. Returns the identity matrix.
  556. **transform** (m, v) : Vector3
  557. Transforms the vector *v* by the matrix *m* and returns the result.
  558. **to_string** (m) : string
  559. Returns a string representing the matrix *m*.
  560. Matrix4x4Box
  561. ------------
  562. Constructors
  563. ~~~~~~~~~~~~
  564. **Matrix4x4Box** () : Matrix4x4Box
  565. Returns a new Matrix4x4Box initialized with the identity matrix.
  566. **Matrix4x4Box** (m) : Matrix4x4Box
  567. Returns a new Matrix4x4Box from the Matrix4x4 *m*.
  568. Functions
  569. ~~~~~~~~~
  570. **store** (m)
  571. Stores the Matrix4x4 *m* in the box.
  572. **unbox** () : Matrix4x4
  573. Returns the stored matrix from the box.
  574. Color4
  575. ------
  576. Constructors
  577. ~~~~~~~~~~~~
  578. **Color4** (r, g, b, a) : Color4
  579. Returns a new Color4 from individual elements.
  580. Functions
  581. ~~~~~~~~~
  582. **lerp** (a, b, t) : Color4
  583. Returns the linearly interpolated color between *a* and *b* at time *t* in [0, 1].
  584. | **black** () : Color4
  585. | **white** () : Color4
  586. | **red** () : Color4
  587. | **green** () : Color4
  588. | **blue** () : Color4
  589. | **yellow** () : Color4
  590. | **orange** () : Color4
  591. | Returns the corresponding mnemonic color.
  592. **to_string** (c) : string
  593. Returns a string representing the color *c*.
  594. Math
  595. ----
  596. **ray_plane_intersection** (from, dir, point, normal) : float
  597. Returns the distance along ray (from, dir) to intersection point with plane defined by
  598. *point* and *normal* or -1.0 if no intersection.
  599. **ray_disc_intersection** (from, dir, center, radius, normal) : float
  600. Returns the distance along ray (from, dir) to intersection point with disc defined by
  601. *center*, *radius* and *normal* or -1.0 if no intersection.
  602. **ray_sphere_intersection** (from, dir, center, radius) : float
  603. Returns the distance along ray (from, dir) to intersection point with sphere defined by
  604. *center* and *radius* or -1.0 if no intersection.
  605. **ray_obb_intersection** (from, dir, tm, half_extents) : float
  606. Returns the distance along ray (from, dir) to intersection point with the oriented
  607. bounding box (tm, half_extents) or -1.0 if no intersection.
  608. **ray_triangle_intersection** (from, dir, v0, v1, v2) : float
  609. Returns the distance along ray (from, dir) to intersection point with the triangle
  610. (v0, v1, v2) or -1.0 if no intersection.
  611. **obb_intersects_frustum** (obb_tm, obb_half_extents, n0, d0, n1, d1, n2, d2, n3, d3, n4, d4, n4, d5) : bool
  612. Returns whether the oriented bounding box (obb_tm, obb_half_extents) intersects
  613. the frustum defined by the planes ((n0, d0), (n1, d1), ..., (n5, d5)). The
  614. planes be given in BRTLNF order, where B = bottom plane, R = right plane etc.
  615. **obb_vertices** (obb_tm, obb_half_extents) : v0, v1, v2, v3, v4, v5, v6, v7
  616. Returns the vertices of the oriented bounding box (obb_tm, obb_half_extents).
  617. **obb_merge** (a_tm, a_half_extents, b_tm, b_half_extents, ...) : Matrix4x4, Vector3
  618. Returns a new box which encloses both the box A (a_tm, a_half_extents) and B
  619. (b_tm, b_half_extents) and any number of boxes after B.
  620. Note that the returned OBB will have the same orientation as A and won't
  621. necessarily be the smallest enclosing box.
  622. PhysicsWorld
  623. =============
  624. **gravity** (pw) : Vector3
  625. Returns the gravity.
  626. **set_gravity** (pw, gravity)
  627. Sets the gravity.
  628. **cast_ray** (pw, from, dir, length) : hit, collision_pos, normal, time, UnitId, Actor
  629. Casts a ray into the physics world and returns the closest actor it intersects with.
  630. If *hit* is true the following return values contain the *collision_pos* in
  631. world space, the *normal* of the surface that was hit, the time of impact
  632. in [0..1] and the *unit* and the *actor* that was hit.
  633. **cast_ray_all** (pw, from, dir, length) : table
  634. Casts a ray into the physics world and returns all the
  635. actors it intersects with as an array of `RaycastHit`_ tables.
  636. **cast_sphere** (pw, from, radius, dir, length) : hit, collision_pos, normal, time, UnitId, Actor
  637. Casts a sphere into the physics world and returns the closest actor it intersects with.
  638. If *hit* is true the following return values contain the *collision_pos* in
  639. world space, the *normal* of the surface that was hit, the time of impact
  640. in [0..1] and the *unit* and the *actor* that was hit.
  641. **cast_box** (pw, from, half_extents, dir, length) : hit, collision_pos, normal, time, UnitId, Actor
  642. Casts a box into the physics world and returns the closest actor it intersects with.
  643. If *hit* is true the following return values contain the *collision_pos* in
  644. world space, the *normal* of the surface that was hit, the time of impact
  645. in [0..1] and the *unit* and the *actor* that was hit.
  646. **enable_debug_drawing** (pw, enable)
  647. Sets whether to *enable* debug drawing.
  648. RaycastHit
  649. ----------
  650. RaycastHit is a lua table with 5 fields:
  651. * ``[1]``: The collision position in world space.
  652. * ``[2]``: The normal of the surface that was hit.
  653. * ``[3]``: The time of impact in [0..1].
  654. * ``[4]``: The unit that was hit.
  655. * ``[5]``: The actor that was hit.
  656. Actor
  657. -----
  658. **actor_destroy** (pw, actor)
  659. Destroys the *actor* instance.
  660. **actor_instance** (pw, unit) : Id
  661. Returns the ID of the actor owned by the *unit*, or ``nil``.
  662. **actor_world_position** (pw, actor) : Vector3
  663. Returns the world position of the *actor*.
  664. **actor_world_rotation** (pw, actor) : Quaternion
  665. Returns the world rotation of the *actor*.
  666. **actor_world_pose** (pw, actor) : Matrix4x4
  667. Returns the world pose of the *actor*.
  668. **actor_teleport_world_position** (pw, actor, position)
  669. Teleports the *actor* to the given world *position*.
  670. **actor_teleport_world_rotation** (pw, actor, rotation)
  671. Teleports the *actor* to the given world *rotation*.
  672. **actor_teleport_world_pose** (pw, actor, pose)
  673. Teleports the *actor* to the given world *pose*.
  674. **actor_center_of_mass** (pw, actor) : Vector3
  675. Returns the center of mass of the *actor*.
  676. **actor_enable_gravity** (pw, actor)
  677. Enables gravity for the *actor*.
  678. **actor_disable_gravity** (pw, actor)
  679. Disables gravity for the *actor*.
  680. **actor_enable_collision** (pw, actor)
  681. Enables collision detection for the *actor*.
  682. **actor_disable_collision** (pw, actor)
  683. Disables collision detection for the *actor*.
  684. **actor_set_collision_filter** (pw, actor, name)
  685. Sets the collision filter of the *actor*.
  686. **actor_set_kinematic** (pw, actor, kinematic)
  687. Sets whether the *actor* is *kinematic* or not.
  688. .. note::
  689. This call has no effect on static actors.
  690. **actor_is_static** (pw, actor) : bool
  691. Returns whether the *actor* is static.
  692. **actor_is_dynamic** (pw, actor) bool
  693. Returns whether the *actor* is dynamic.
  694. **actor_is_kinematic** (pw, actor) : bool
  695. Returns whether the *actor* is kinematic (keyframed).
  696. **actor_is_nonkinematic** (pw, actor) : bool
  697. Returns whether the *actor* is nonkinematic (i.e. dynamic and not kinematic).
  698. **actor_linear_damping** (pw, actor) : float
  699. Returns the linear damping of the *actor*.
  700. **actor_set_linear_damping** (pw, actor, damping)
  701. Sets the linear *damping* of the *actor*.
  702. **actor_angular_damping** (pw, actor) : float
  703. Returns the angular damping rate of the *actor*.
  704. **actor_set_angular_damping** (pw, actor, rate)
  705. Sets the angular damping *rate* of the *actor*.
  706. **actor_linear_velocity** (pw, actor) : Vector3
  707. Returns the linear velocity of the *actor*.
  708. **actor_set_linear_velocity** (pw, actor, velocity)
  709. Sets the linear *velocity* of the *actor*.
  710. .. note::
  711. This call only affects nonkinematic actors.
  712. **actor_angular_velocity** (pw, actor) : Vector3
  713. Returns the angular velocity of the *actor*.
  714. **actor_set_angular_velocity** (pw, actor, velocity)
  715. Sets the angular *velocity* of the *actor*.
  716. .. note::
  717. This call only affects nonkinematic actors.
  718. **actor_add_impulse** (pw, actor, impulse)
  719. Adds a linear *impulse* (acting along the center of mass) to the *actor*.
  720. .. note::
  721. This call only affects nonkinematic actors.
  722. **actor_add_impulse_at** (pw, actor, impulse, position)
  723. Adds a linear *impulse* (acting along the world position *pos*) to the *actor*.
  724. .. note::
  725. This call only affects nonkinematic actors.
  726. **actor_add_torque_impulse** (pw, actor, impulse)
  727. Adds a torque *impulse* to the *actor*.
  728. **actor_push** (pw, actor, velocity, mass)
  729. Pushes the *actor* as if it was hit by a point object with the given *mass*
  730. travelling at the given *velocity*.
  731. .. note::
  732. This call only affects nonkinematic actors.
  733. **actor_push_at** (pw, actor, velocity, mass, position)
  734. Like push() but applies the force at the world *position*.
  735. .. note::
  736. This call only affects nonkinematic actors.
  737. **actor_is_sleeping** (pw, actor) : bool
  738. Returns whether the *actor* is sleeping.
  739. **actor_wake_up** (pw, actor)
  740. Wakes the *actor* up.
  741. Profiler
  742. ========
  743. **enter_scope** (name)
  744. Starts a new profile scope with the given *name*.
  745. **leave_scope** ()
  746. Ends the last profile scope.
  747. **record** (name, value)
  748. Records *value* with the given *name*. Value can be either number or Vector3.
  749. RenderWorld
  750. ===========
  751. **enable_debug_drawing** (rw, enable)
  752. Sets whether to *enable* debug drawing.
  753. Mesh
  754. ----
  755. **mesh_create** (rw, unit, mesh_resource, geometry_name, material_resource, visible, pose) : Id
  756. Creates a new mesh instance for *unit* and returns its id.
  757. **mesh_destroy** (rw, mesh)
  758. Destroys the *mesh* instance.
  759. **mesh_instance** (rw, unit) : Id
  760. Returns the ID of the mesh owned by the *unit*, or ``nil``.
  761. **mesh_material** (rw, mesh) : Material
  762. Returns the material of the *mesh*.
  763. **mesh_set_material** (rw, mesh, material)
  764. Sets the *material* of the *mesh*.
  765. **mesh_set_visible** (rw, mesh, visible)
  766. Sets whether the *mesh* is *visible*.
  767. **mesh_obb** (rw, mesh) : Matrix4x4, Vector3
  768. Returns the Oriented-Bounding-Box of the *mesh* as (pose, half_extents).
  769. **mesh_cast_ray** (rw, mesh, from, dir) : float
  770. Returns the distance along ray (from, dir) to intersection point with the *mesh* or -1.0 if no intersection.
  771. Sprite
  772. ------
  773. **sprite_create** (rw, unit, sprite_resource, material_resource, visible, pose) : Id
  774. Creates a new sprite instance for the *unit* and returns its id.
  775. **sprite_destroy** (rw, sprite)
  776. Destroys the *sprite* instance.
  777. **sprite_instance** (rw, unit) : Id
  778. Returns the ID of the sprite owned by the *unit*, or ``nil``.
  779. **sprite_material** (rw, sprite) : Material
  780. Returns the material of the *sprite*.
  781. **sprite_set_material** (rw, sprite, material)
  782. Sets the *material* of the *sprite*.
  783. **sprite_set_frame** (rw, sprite, index)
  784. Sets the frame *index* of the *sprite*.
  785. The *index* automatically wraps if it greater than the total number of
  786. frames in the sprite.
  787. **sprite_set_visible** (rw, sprite, visible)
  788. Sets whether the *sprite* is *visible*.
  789. **sprite_flip_x** (rw, sprite, flip)
  790. Sets whether to flip the *sprite* on the x-axis.
  791. **sprite_flip_y** (rw, sprite, flip)
  792. Sets whether to flip the *sprite* on the y-axis.
  793. **sprite_set_layer** (rw, sprite, layer)
  794. Sets the rendering *layer* of the *sprite*.
  795. **sprite_set_depth** (rw, sprite, depth)
  796. Sets the rendering *depth* of the *sprite*.
  797. **sprite_obb** (rw, sprite) : Matrix4x4, Vector3
  798. Returns the Oriented-Bounding-Box of the *sprite* as (pose, half_extents).
  799. **sprite_cast_ray** (rw, sprite, from, dir) : float, int, int
  800. Returns (t, layer, depth), where *t* is the distance along ray (from, dir) to
  801. intersection point with the *sprite* or -1.0 if no intersection.
  802. Light
  803. -----
  804. **light_create** (rw, unit, type, range, intensity, spot_angle, color, pose) : Id
  805. Creates a new light for the *unit* and returns its id.
  806. Type can be either ``directional``, ``omni`` or ``spot``.
  807. **light_destroy** (rw, light)
  808. Destroys the *light* instance.
  809. **light_instance** (rw, unit) : Id
  810. Returns the ID of the light owned by the *unit*, or ``nil``.
  811. **light_type** (rw, light) : string
  812. Returns the type of the *light*.
  813. It can be either ``directional``, ``omni`` or ``spot``.
  814. **light_color** (rw, light) : Color4
  815. Returns the color of the *light*.
  816. **light_range** (rw, light) : float
  817. Returns the range of the *light*.
  818. **light_intensity** (rw, light) : float
  819. Returns the intensity of the *light*.
  820. **light_spot_angle** (rw, light) : float
  821. Returns the spot angle of the *light*.
  822. **light_set_type** (rw, light, type)
  823. Sets the *type* of the *light*.
  824. **light_set_color** (rw, light, color)
  825. Sets the *color* of the *light*.
  826. **light_set_range** (rw, light, range)
  827. Sets the *range* of the *light*.
  828. **light_set_intensity** (rw, light, intensity)
  829. Sets the *intensity* of the *light*.
  830. **light_set_spot_angle** (rw, light, angle)
  831. Sets the spot *angle* of the *light*.
  832. **light_debug_draw** (rw, light, debug_line)
  833. Fills *debug_line* with debug lines from the *light*.
  834. ResourcePackage
  835. ===============
  836. **load** (package)
  837. Loads all the resources in the *package*.
  838. .. note::
  839. The resources are not immediately available after the call is made,
  840. instead, you have to poll for completion with has_loaded().
  841. **unload** (package)
  842. Unloads all the resources in the *package*.
  843. **flush** (package)
  844. Waits until the *package* has been loaded.
  845. **has_loaded** (package) : bool
  846. Returns whether the *package* has been loaded.
  847. SceneGraph
  848. ==========
  849. **create** (sg, unit, position, rotation, scale) : Id
  850. Creates the transform for the *unit* and returns its ID.
  851. **destroy** (sg, transform)
  852. Destroys the *transform* instance.
  853. **instance** (sg, unit) : Id
  854. Returns the ID of the transform owned by the *unit*, or ``nil``.
  855. **owner** (sg, transform) : UnitId
  856. Returns the unit that owns *transform*.
  857. **local_position** (sg, transform) : Vector3
  858. Returns the local position of the *transform*.
  859. **local_rotation** (sg, transform) : Quaternion
  860. Returns the local rotation of the *transform*.
  861. **local_scale** (sg, transform) : Vector3
  862. Returns the local scale of the *transform*.
  863. **local_pose** (sg, transform) : Matrix4x4
  864. Returns the local pose of the *transform*.
  865. **world_position** (sg, transform) : Vector3
  866. Returns the world position of the *transform*.
  867. **world_rotation** (sg, transform) : Quaternion
  868. Returns the world rotation of the *transform*.
  869. **world_pose** (sg, transform) : Matrix4x4
  870. Returns the world pose of the *transform*.
  871. **set_local_position** (sg, transform, position)
  872. Sets the local *position* of the *transform*.
  873. **set_local_rotation** (sg, transform, rotation)
  874. Sets the local *rotation* of the *transform*.
  875. **set_local_scale** (sg, transform, scale)
  876. Sets the local *scale* of the *transform*.
  877. **set_local_pose** (sg, transform, pose)
  878. Sets the local *pose* of the *transform*.
  879. **link** (sg, parent, child, child_local_position, child_local_rotation, child_local_scale)
  880. Links *child* to *parent*. After linking the child will follow its
  881. parent. Set child_local_* to modify the child position after it has been
  882. linked to the parent, otherwise che child will be positioned at the
  883. location of its parent.
  884. **unlink** (sg, child)
  885. Unlinks *child* from its parent if it has any. After unlinking, the local
  886. pose of the *child* is set to its previous world pose.
  887. **parent** (sg, child) : Id
  888. Returns the parent of the instance *child* or ``nil``
  889. if *child* has no parent.
  890. **first_child** (sg, parent) : Id
  891. Returns the first child of the instance *parent* or ``nil``
  892. if *parent* has no children.
  893. **next_sibling** (sg, child) : Id
  894. Returns the next sibling of the instance *child* or ``nil``
  895. if *child* has no sibling.
  896. SoundWorld
  897. ===========
  898. **stop_all** (sound_world)
  899. Stops all the sounds in the world.
  900. **pause_all** (sound_world)
  901. Pauses all the sounds in the world
  902. **resume_all** (sound_world)
  903. Resumes all previously paused sounds in the world.
  904. **is_playing** (sound_world, id) : bool
  905. Returns whether the sound *id* is playing.
  906. UnitManager
  907. ===========
  908. **create** ([world]) : UnitId
  909. Creates a new empty unit. If *world* is specified, the unit will be owned by
  910. that world.
  911. **destroy** (unit)
  912. Destroys the given *unit*.
  913. **alive** (unit) : bool
  914. Returns whether the unit is alive.
  915. Window
  916. ======
  917. **show** ()
  918. Shows the window.
  919. **hide** ()
  920. Hides the window.
  921. **resize** (width, height)
  922. Resizes the window to *width* and *height*.
  923. **move** (x, y)
  924. Moves the window to *x* and *y*.
  925. **minimize** ()
  926. Minimizes the window.
  927. **maximize** ()
  928. Maximizes the window.
  929. **restore** ()
  930. Restores the window.
  931. **title** () : string
  932. Returns the title of the window.
  933. **set_title** (title)
  934. Sets the title of the window.
  935. **show_cursor** (show)
  936. Sets whether to *show* the cursor.
  937. **set_fullscreen** (fullscreen)
  938. Sets whether the window is *fullscreen*.
  939. **set_cursor** (cursor)
  940. Sets the mouse *cursor* on this window. Cursor can be any of ``arrow``, ``hand``,
  941. ``text_input``, ``corner_top_left``, ``corner_top_right``, ``corner_bottom_left``,
  942. ``corner_bottom_right``, ``size_horizontal``, ``size_vertical`` or ``wait``.
  943. **set_cursor_mode** (cursor, mode)
  944. Sets the mouse cursor *mode* on this window. Mode can be either ``normal`` or ``disabled``.
  945. Setting the mode to ``disabled`` hides the cursor and automatically re-centers it every time it
  946. is moved.
  947. World
  948. =====
  949. **spawn_unit** (world, name, [position, rotation, scale]) : UnitId
  950. Spawns a new instance of the unit *name* at the given *position*, *rotation* and *scale*.
  951. **spawn_empty_unit** (world) : UnitId
  952. Spawns a new empty unit and returns its id.
  953. **destroy_unit** (world, unit)
  954. Destroys the given *unit*.
  955. **num_units** (world) : int
  956. Returns the number of units in the *world*.
  957. **units** (world) : table
  958. Returns all the the units in the world in a table.
  959. **unit_by_name** (world, name) : UnitId
  960. Returns the unit with the given Level Editor *name* or ``nil`` if no such unit is found.
  961. If there are multiple units with the same name, a random one will be returned.
  962. **update_animations** (world, dt)
  963. Update all animations with *dt*.
  964. **update_scene** (world, dt)
  965. Updates the scene with *dt*.
  966. **update** (world, dt)
  967. Updates the world with *dt*.
  968. **create_debug_line** (world, depth_test) : DebugLine
  969. Creates a new DebugLine. *depth_test* controls whether to
  970. enable depth test when rendering the lines.
  971. **destroy_debug_line** (world, line)
  972. Destroys the debug *line*.
  973. **create_screen_gui** (world) : Gui
  974. Creates a new Gui for 2D drawing.
  975. **create_world_gui** (world) : Gui
  976. Creates a new Gui for 3D drawing.
  977. **destroy_gui** (world, gui)
  978. Destroys the *gui*.
  979. **scene_graph** (world) : SceneGraph
  980. Returns the scene graph.
  981. **render_world** (world) : RenderWorld
  982. Returns the render sub-world.
  983. **physics_world** (world) : PhysicsWorld
  984. Returns the physics sub-world.
  985. **sound_world** (world) : SoundWorld
  986. Returns the sound sub-world.
  987. **animation_state_machine** (world) : AnimationStateMachine
  988. Returns the animation state machine.
  989. Camera
  990. ------
  991. **camera_create** (world, unit, projection, fov, far_range, near_range, pose) : Id
  992. Creates a new camera for *unit* and returns its id.
  993. Projection can be either ``orthographic`` or ``perspective``.
  994. **camera_destroy** (world, camera)
  995. Destroys the *camera* instance.
  996. **camera_instance** (world, unit) : Id
  997. Returns the ID of the camera owned by the *unit*, or ``nil``.
  998. **camera_set_projection_type** (world, camera, projection)
  999. Sets the projection type of the *camera*.
  1000. Projection can be either ``orthographic`` or ``perspective``.
  1001. **camera_projection_type** (world, camera) : string
  1002. Returns the projection type of the *camera*.
  1003. It can be either ``orthographic`` or ``perspective``.
  1004. **camera_fov** (world, camera) : float
  1005. Returns the field-of-view of the *camera* in degrees.
  1006. **camera_set_fov** (world, camera, fov)
  1007. Sets the field-of-view of the *camera* in degrees.
  1008. **camera_near_clip_distance** (world, camera) : float
  1009. Returns the near clip distance of the *camera*.
  1010. **camera_set_near_clip_distance** (world, camera, near)
  1011. Sets the near clip distance of the *camera*.
  1012. **camera_far_clip_distance** (world, camera) : float
  1013. Returns the far clip distance of the *camera*.
  1014. **camera_set_far_clip_distance** (world, camera, far)
  1015. Sets the far clip distance of the *camera*.
  1016. **camera_set_orthographic_size** (world, camera, half_size)
  1017. Sets the vertical *half_size* of the orthographic view volume.
  1018. The horizontal size is proportional to the viewport's aspect ratio.
  1019. **camera_screen_to_world** (world, camera, pos) : Vector3
  1020. Returns *pos* from screen-space to world-space coordinates.
  1021. **camera_world_to_screen** (world, camera, pos) : Vector3
  1022. Returns *pos* from world-space to screen-space coordinates.
  1023. Sound
  1024. -----
  1025. **play_sound** (world, name, [loop, volume, position, range]) : SoundInstanceId
  1026. Plays the sound with the given *name* at the given *position*, with the given
  1027. *volume* and *range*. *loop* controls whether the sound must loop or not.
  1028. **stop_sound** (world, id)
  1029. Stops the sound with the given *id*.
  1030. **link_sound** (world, id, unit, node)
  1031. Links the sound *id* to the *node* of the given *unit*.
  1032. After this call, the sound *id* will follow the unit *unit*.
  1033. **set_listener_pose** (world, pose)
  1034. Sets the *pose* of the listener.
  1035. **set_sound_position** (world, id, position)
  1036. Sets the *position* of the sound *id*.
  1037. **set_sound_range** (world, id, range)
  1038. Sets the *range* of the sound *id*.
  1039. **set_sound_volume** (world, id, volume)
  1040. Sets the *volume* of the sound *id*.
  1041. Level
  1042. -----
  1043. **load_level** (world, name, [pos, rot]) : Level
  1044. Loads the level *name* into the world at the given *position* and *rotation*.