lua_api.rst 40 KB

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