lua_api.rst 40 KB

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