lua_api.rst 41 KB

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