lua_api.rst 44 KB

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