lua_api.rst 39 KB

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