lua_api.rst 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222
  1. =================
  2. Lua API reference
  3. =================
  4. Math
  5. ====
  6. Vector3
  7. -------
  8. Constructors
  9. ~~~~~~~~~~~~
  10. **Vector3** (x, y, z) : Vector3
  11. Returns a new vector from individual elements.
  12. Functions
  13. ~~~~~~~~~
  14. **x** (v) : float
  15. Returns the x value of the vector.
  16. **y** (v) : float
  17. Returns the y value of the vector.
  18. **z** (v) : float
  19. Returns the z value of the vector.
  20. **.x** : float
  21. Returns/assigns the x value of the vector.
  22. **.y** : float
  23. Returns/assigns the y value of the vector.
  24. **.z** : float
  25. Returns/assigns the z value of the vector.
  26. **set_x** (v, x)
  27. Sets the value of the x value of the vector.
  28. **set_y** (v, y)
  29. Sets the value of the y value of the vector.
  30. **set_z** (v, z)
  31. Sets the value of the z value of the vector.
  32. **elements** (v) : float, float, float
  33. Returns the x, y and z elements of the vector.
  34. **add** (a, b) : Vector3
  35. Adds the vector *a* to *b* and returns the result.
  36. **subtract** (a, b) : Vector3
  37. Subtracts the vector *b* from *a* and returns the result.
  38. **multiply** (a, k) : Vector3
  39. Multiplies the vector *a* by the scalar *k* and returns the result.
  40. **dot** (a, b) : float
  41. Returns the dot product between the vectors *a* and *b*.
  42. **cross** (a, b) : Vector3
  43. Returns the cross product between the vectors *a* and *b*.
  44. **equal** (a, b) : bool
  45. Returns true whether the vectors *a* and *b* are equal.
  46. **length** (a) : float
  47. Returns the lenght of *a*.
  48. **length_squared** (a) : float
  49. Returns the squared length of *a*.
  50. **set_length** (a, len)
  51. Sets the lenght of *a* to *len*.
  52. **normalize** (a) : Vector3
  53. Normalizes *a* and returns the result.
  54. **distance** (a, b) : float
  55. Returns the distance between the points *a* and *b*.
  56. **distance_squared** (a, b) : float
  57. Returns the squared distance between the points *a* and *b*.
  58. **angle** (a, b) : float
  59. Returns the angle between the vectors *a* and *b*.
  60. **max** (a, b) : Vector3
  61. Returns a vector that contains the largest value for each element from *a* and *b*.
  62. **min** (a, b) : Vector3
  63. Returns a vector that contains the smallest value for each element from *a* and *b*.
  64. **lerp** (a, b, t) : Vector3
  65. Returns the linearly interpolated vector between *a* and *b* at time *t* in [0, 1].
  66. | **forward** () : Vector3
  67. | **backward** () : Vector3
  68. | **left** () : Vector3
  69. | **right** () : Vector3
  70. | **up** () : Vector3
  71. | **down** () : Vector3
  72. | Returns the corresponding semantic axis.
  73. **zero** () : Vector3
  74. Returns a vector with all values set to zero.
  75. **to_string** (v) : string
  76. Returns a string representing the vector *v*.
  77. Vector3Box
  78. ----------
  79. Constructors
  80. ~~~~~~~~~~~~
  81. **Vector3Box** () : Vector3Box
  82. Returns a new Vector3Box initialized with the zero vector.
  83. **Vector3Box** (v) : Vector3Box
  84. Returns a new Vector3Box from the Vector3 *v*.
  85. **Vector3Box** (x, y, z) : Vector3Box
  86. Returns a new Vector3Box from individual elements.
  87. Functions
  88. ~~~~~~~~~
  89. **store** (v)
  90. Stores the Vector3 *v* in the box.
  91. **store** (x, y, z)
  92. Stores Vector3(x, y, z) in the box.
  93. **unbox** () : Vector3
  94. Returns the stored vector from the box.
  95. Quaternion
  96. ----------
  97. Constructors
  98. ~~~~~~~~~~~~
  99. **Quaternion** (axis, angle) : Quaternion
  100. Returns a new quaternion from *axis* and *angle*.
  101. **from_elements** (x, y, z, w) : Quaternion
  102. Returns a new quaternion from individual elements.
  103. **from_axis_angle** (axis, angle) : Quaternion
  104. Returns a new quaternion from *axis* and *angle*.
  105. Functions
  106. ~~~~~~~~~
  107. **negate** (q) : Quaternion
  108. Negates the quaternion *q* and returns the result.
  109. **identity** () : Quaternion
  110. Returns the identity quaternion.
  111. **multiply** (a, b) : Quaternion
  112. Multiplies the quaternions *a* and *b*. (i.e. rotates first by *a* then by *b*).
  113. **multiply_by_scalar** (a, k) : Quaternion
  114. Multiplies the quaternion *a* by the scalar *k*.
  115. **dot** (a, b) : float
  116. Returns the dot product between quaternions *a* and *b*.
  117. **length** (q) : float
  118. Returns the length of *q*.
  119. **normalize** (q) : Quaternion
  120. Normalizes the quaternion *q* and returns the result.
  121. **conjugate** (q) : Quaternion
  122. Returns the conjugate of quaternion *q*.
  123. **inverse** (q) : Quaternion
  124. Returns the inverse of quaternion *q*.
  125. **power** (q, exp) : Quaternion
  126. Returns the quaternion *q* raised to the power of *exp*.
  127. **elements** (q) : float, float, float, float
  128. Returns the x, y, z and w elements of the quaternion.
  129. **look** (dir, [up]) : Quaternion
  130. Returns the quaternion describing the rotation needed to face towards *dir*.
  131. If *up* is not specified, Vector3.up() is used.
  132. **right** (q) : Vector3
  133. Returns the right axis of the rotation described by *q*.
  134. **up** (q) : Vector3
  135. Returns the up axis of the rotation described by *q*.
  136. **forward** (q) : Vector3
  137. Returns the forward axis of the rotation described by *q*.
  138. **lerp** (a, b, t) : Quaternion
  139. Returns the linearly interpolated quaternion between *a* and *b* at time *t* in [0, 1].
  140. It uses NLerp.
  141. **to_string** (q) : string
  142. Returns a string representing the quaternion *q*.
  143. QuaternionBox
  144. -------------
  145. Constructors
  146. ~~~~~~~~~~~~
  147. **QuaternionBox** () : QuaternionBox
  148. Returns a new QuaternionBox initialized with the identity quaternion.
  149. **QuaternionBox** (q) : QuaternionBox
  150. Returns a new QuaternionBox from the Quaternion *q*.
  151. **QuaternionBox** (x, y, z, w) : QuaternionBox
  152. Returns a new QuaternionBox from individual elements.
  153. Functions
  154. ~~~~~~~~~
  155. **store** (q)
  156. Stores the Quaternion *q* in the box.
  157. **store** (x, y, z, w)
  158. Stores Quaternion(x, y, z, w) in the box.
  159. **unbox** () : Quaternion
  160. Returns the stored quaternion from the box.
  161. Matrix4x4
  162. ---------
  163. Constructors
  164. ~~~~~~~~~~~~
  165. **Matrix4x4** (xx, xy, xz, xw, yx, yy, yz, yw, zx, zy, zz, zw, tx, ty, tz, tw) : Matrix4x4
  166. Returns a new matrix from individual elements.
  167. **from_quaternion** (q) : Matrix4x4
  168. Returns a new matrix from *q*.
  169. **from_translation** (t) : Matrix4x4
  170. Returns a new matrix from *t*.
  171. **from_quaternion_translation** (q, t) : Matrix4x4
  172. Returns a new matrix from *q* and *t*.
  173. **from_axes** (x, y, z, t) : Matrix4x4
  174. Returns a new matrix from *x*, *y*, *z* and *t*.
  175. Functions
  176. ~~~~~~~~~
  177. **copy** (m) : Matrix4x4
  178. Returns a copy of the matrix *m*.
  179. **add** (a, b) : Matrix4x4
  180. Adds the matrix *a* to *b* and returns the result.
  181. **subtract** (a, b) : Matrix4x4
  182. Subtracts the matrix *b* from *a* and returns the result.
  183. **multiply** (a, b) : Matrix4x4
  184. Multiplies the matrix *a* by *b* and returns the result. (i.e. transforms first by *a* then by *b*)
  185. **transpose** (m) : Matrix4x4
  186. Transposes the matrix *m* and returns the result.
  187. **determinant** (m) : float
  188. Returns the determinant of the matrix *m*.
  189. **invert** (m) : Matrix4x4
  190. Inverts the matrix *m* and returns the result.
  191. **x** (m) : Vector3
  192. Returns the x axis of the matrix *m*.
  193. **y** (m) : Vector3
  194. Returns the y axis of the matrix *m*.
  195. **z** (m) : Vector3
  196. Returns the z axis of the matrix *m*.
  197. **set_x** (m, x)
  198. Sets the x axis of the matrix *m*.
  199. **set_y** (m, y)
  200. Sets the y axis of the matrix *m*.
  201. **set_z** (m, z)
  202. Sets the z axis of the matrix *m*.
  203. **rotation** (m) : Quaternion
  204. Returns the rotation portion of the matrix *m*.
  205. **set_rotation** (m, r)
  206. Sets the rotation portion of the matrix *m*.
  207. **translation** (m, a) : Vector3
  208. Returns the translation portion of the matrix *m*.
  209. **set_translation** (m, t)
  210. Sets the translation portion of the matrix *m*.
  211. **identity** ()
  212. Returns the identity matrix.
  213. **transform** (m, v) : Vector3
  214. Transforms the vector *v* by the matrix *m* and returns the result.
  215. **to_string** (m) : string
  216. Returns a string representing the matrix *m*.
  217. Matrix4x4Box
  218. ------------
  219. Constructors
  220. ~~~~~~~~~~~~
  221. **Matrix4x4Box** () : Matrix4x4Box
  222. Returns a new Matrix4x4Box initialized with the identity matrix.
  223. **Matrix4x4Box** (m) : Matrix4x4Box
  224. Returns a new Matrix4x4Box from the Matrix4x4 *m*.
  225. Functions
  226. ~~~~~~~~~
  227. **store** (m)
  228. Stores the Matrix4x4 *m* in the box.
  229. **unbox** () : Matrix4x4
  230. Returns the stored matrix from the box.
  231. Color4
  232. ------
  233. Constructors
  234. ~~~~~~~~~~~~
  235. **Color4** (r, g, b, a) : Color4
  236. Returns a new Color4 from individual elements.
  237. Functions
  238. ~~~~~~~~~
  239. **lerp** (a, b, t) : Color4
  240. Returns the linearly interpolated color between *a* and *b* at time *t* in [0, 1].
  241. | **black** () : Color4
  242. | **white** () : Color4
  243. | **red** () : Color4
  244. | **green** () : Color4
  245. | **blue** () : Color4
  246. | **yellow** () : Color4
  247. | **orange** () : Color4
  248. | Returns the corresponding mnemonic color.
  249. **to_string** (c) : string
  250. Returns a string representing the color *c*.
  251. Math
  252. ----
  253. **ray_plane_intersection** (from, dir, point, normal) : float
  254. Returns the distance along ray (from, dir) to intersection point with plane defined by
  255. *point* and *normal* or -1.0 if no intersection.
  256. **ray_disc_intersection** (from, dir, center, radius, normal) : float
  257. Returns the distance along ray (from, dir) to intersection point with disc defined by
  258. *center*, *radius* and *normal* or -1.0 if no intersection.
  259. **ray_sphere_intersection** (from, dir, center, radius) : float
  260. Returns the distance along ray (from, dir) to intersection point with sphere defined by
  261. *center* and *radius* or -1.0 if no intersection.
  262. **ray_obb_intersection** (from, dir, tm, half_extents) : float
  263. Returns the distance along ray (from, dir) to intersection point with the oriented
  264. bounding box (tm, half_extents) or -1.0 if no intersection.
  265. **ray_triangle_intersection** (from, dir, v0, v1, v2) : float
  266. Returns the distance along ray (from, dir) to intersection point with the triangle
  267. (v0, v1, v2) or -1.0 if no intersection.
  268. UnitManager
  269. ===========
  270. **create** ([world]) : UnitId
  271. Creates a new empty unit. If *world* is specified, the unit will be owned by
  272. that world.
  273. **destroy** (unit)
  274. Destroys the given *unit*.
  275. **alive** (unit) : bool
  276. Returns whether the unit is alive.
  277. World
  278. =====
  279. **spawn_unit** (world, name, [position, rotation]) : UnitId
  280. Spawns a new instance of the unit *name* at the given *position* and *rotation*.
  281. **spawn_empty_unit** (world) : UnitId
  282. Spawns a new empty unit and returns its id.
  283. **destroy_unit** (world, unit)
  284. Destroys the given *unit*.
  285. **num_units** (world) : int
  286. Returns the number of units in the *world*.
  287. **units** (world) : table
  288. Returns all the the units in the world in a table.
  289. **update_animations** (world, dt)
  290. Update all animations with *dt*.
  291. **update_scene** (world, dt)
  292. Updates the scene with *dt*.
  293. **update** (world, dt)
  294. Updates the world with *dt*.
  295. **create_debug_line** (world, depth_test) : DebugLine
  296. Creates a new DebugLine. *depth_test* controls whether to
  297. enable depth test when rendering the lines.
  298. **destroy_debug_line** (world, line)
  299. Destroys the debug *line*.
  300. **scene_graph** (world) : SceneGraph
  301. Returns the scene graph.
  302. **render_world** (world) : RenderWorld
  303. Returns the render sub-world.
  304. **physics_world** (world) : PhysicsWorld
  305. Returns the physics sub-world.
  306. **sound_world** (world) : SoundWorld
  307. Returns the sound sub-world.
  308. Camera
  309. ------
  310. **camera_create** (world, unit, projection, fov, far_range, near_range, pose) : Id
  311. Creates a new camera for *unit* and returns its id.
  312. Projection can be either ``orthographic`` or ``perspective``.
  313. **camera_instances** (world, unit) : Id
  314. Returns the IDs for all the cameras of the *unit*.
  315. **camera_set_projection_type** (world, camera, projection)
  316. Sets the projection type of the camera.
  317. Projection can be either ``orthographic`` or ``perspective``.
  318. **camera_projection_type** (world, camera) : string
  319. Returns the projection type of the camera.
  320. It can be either ``orthographic`` or ``perspective``.
  321. **camera_fov** (world, camera) : float
  322. Returns the field-of-view of the camera in degrees.
  323. **camera_set_fov** (world, camera, fov)
  324. Sets the field-of-view of the camera in degrees.
  325. **camera_near_clip_distance** (world, camera) : float
  326. Returns the near clip distance of the camera.
  327. **camera_set_near_clip_distance** (world, camera, near)
  328. Sets the near clip distance of the camera.
  329. **camera_far_clip_distance** (world, camera) : float
  330. Returns the far clip distance of the camera.
  331. **camera_set_far_clip_distance** (world, camera, far)
  332. Sets the far clip distance of the camera.
  333. **camera_set_orthographic_metrics** (world, camera, left, right, bottom, top)
  334. Sets the coordinates for orthographic clipping planes. (Orthographic projection only.)
  335. **camera_screen_to_world** (world, camera, pos) : Vector3
  336. Returns *pos* from screen-space to world-space coordinates.
  337. **camera_world_to_screen** (world, camera, pos) : Vector3
  338. Returns *pos* from world-space to screen-space coordinates.
  339. Sound
  340. -----
  341. **play_sound** (world, name, [loop, volume, position, range]) : SoundInstanceId
  342. Plays the sound with the given *name* at the given *position*, with the given
  343. *volume* and *range*. *loop* controls whether the sound must loop or not.
  344. **stop_sound** (world, id)
  345. Stops the sound with the given *id*.
  346. **link_sound** (world, id, unit, node)
  347. Links the sound *id* to the *node* of the given *unit*.
  348. After this call, the sound *id* will follow the unit *unit*.
  349. **set_listener_pose** (world, pose)
  350. Sets the *pose* of the listener.
  351. **set_sound_position** (world, id, position)
  352. Sets the *position* of the sound *id*.
  353. **set_sound_range** (world, id, range)
  354. Sets the *range* of the sound *id*.
  355. **set_sound_volume** (world, id, volume)
  356. Sets the *volume* of the sound *id*.
  357. Level
  358. -----
  359. **load_level** (world, name, [pos, rot]) : Level
  360. Loads the level *name* into the world at the given *position* and *rotation*.
  361. SceneGraph
  362. ==========
  363. **create** (sg, unit, position, rotation, scale) : Id
  364. Creates the transform for the *unit* and returns its ID.
  365. **destroy** (sg, unit, id)
  366. Destroys the transform for the *unit*. The transform *id* is ignored.
  367. **instances** (sg, unit) : Id
  368. Returns the IDs for all the transforms of the *unit*.
  369. **local_position** (sg, unit) : Vector3
  370. Returns the local position of the *unit*.
  371. **local_rotation** (sg, unit) : Quaternion
  372. Returns the local rotation of the *unit*.
  373. **local_scale** (sg, unit) : Vector3
  374. Returns the local scale of the *unit*.
  375. **local_pose** (sg, unit) : Matrix4x4
  376. Returns the local pose of the *unit*.
  377. **world_position** (sg, unit) : Vector3
  378. Returns the world position of the *unit*.
  379. **world_rotation** (sg, unit) : Quaternion
  380. Returns the world rotation of the *unit*.
  381. **world_pose** (sg, unit) : Matrix4x4
  382. Returns the world pose of the *unit*.
  383. **set_local_position** (sg, unit, position)
  384. Sets the local *position* of the *unit*.
  385. **set_local_rotation** (sg, unit, rotation)
  386. Sets the local *rotation* of the *unit*.
  387. **set_local_scale** (sg, unit, scale)
  388. Sets the local *scale* of the *unit*.
  389. **set_local_pose** (sg, unit, pose)
  390. Sets the local *pose* of the *unit*.
  391. **link** (sg, child, parent)
  392. Links the unit *child* to the unit *parent*.
  393. **unlink** (sg, unit)
  394. Unlinks the *unit* from its parent if it has any.
  395. After unlinking, the @a unit's local pose is set to its previous world pose.
  396. Material
  397. ========
  398. **set_float** (material, name, value)
  399. Sets the *value* of the variable *name*.
  400. **set_vector2** (material, name, value)
  401. Sets the *value* of the variable *name*.
  402. **set_vector3** (material, name, value)
  403. Sets the *value* of the variable *name*.
  404. RenderWorld
  405. ===========
  406. **enable_debug_drawing** (rw, enable)
  407. Sets whether to *enable* debug drawing.
  408. Mesh
  409. ----
  410. **mesh_create** (rw, unit, mesh_resource, geometry_name, material_resource, visible, pose) : Id
  411. Creates a new mesh instance for *unit* and returns its id.
  412. **mesh_destroy** (rw, id)
  413. Destroys the mesh *id*.
  414. **mesh_instances** (rw, unit) : Id
  415. Returns the IDs for all the meshes of the *unit*.
  416. **mesh_raycast** (rw, id, from, dir) : float
  417. Returns the distance along ray (from, dir) to intersection point with the mesh *id* or -1.0 if no intersection.
  418. Sprite
  419. ------
  420. **sprite_create** (rw, unit, sprite_resource, material_resource, visible, pose) : Id
  421. Creates a new sprite instance for the *unit* and returns its id.
  422. **sprite_destroy** (rw, unit)
  423. Destroys the sprite of the *unit*.
  424. **sprite_instances** (rw, unit) : Id
  425. Returns the IDs for all the sprites of the *unit*.
  426. **sprite_set_frame** (rw, unit, index)
  427. Sets the frame *index* of the sprite.
  428. **sprite_set_visible** (rw, unit, visible)
  429. Sets whether the sprite is *visible*.
  430. **sprite_flip_x** (rw, unit, flip)
  431. Sets whether to flip the sprite on the x-axis.
  432. **sprite_flip_y** (rw, unit, flip)
  433. Sets whether to flip the sprite on the y-axis.
  434. Light
  435. -----
  436. **light_create** (rw, unit, type, range, intensity, spot_angle, color, pose) : Id
  437. Creates a new light for the *unit* and returns its id.
  438. Type can be either ``directional``, ``omni`` or ``spot``.
  439. **light_destroy** (rw, unit)
  440. Destroys the light of the *unit*.
  441. **light_instances** (rw, unit) : Id
  442. Returns the IDs for all the lights of the *unit*.
  443. **light_type** (rw, unit) : string
  444. Returns the type of the light of the *unit*.
  445. It can be either ``directional``, ``omni`` or ``spot``.
  446. **light_color** (rw, unit) : Color4
  447. Returns the color of the light.
  448. **light_range** (rw, unit) : float
  449. Returns the range of the light.
  450. **light_intensity** (rw, unit) : float
  451. Returns the intensity of the light.
  452. **light_spot_angle** (rw, unit) : float
  453. Returns the spot angle of the light.
  454. **light_set_type** (rw, unit, type)
  455. Sets the *type* of the light.
  456. **light_set_color** (rw, unit, color)
  457. Sets the *color* of the light.
  458. **light_set_range** (rw, unit, range)
  459. Sets the *range* of the light.
  460. **light_set_intensity** (rw, unit, intensity)
  461. Sets the *intensity* of the light.
  462. **light_set_spot_angle** (rw, unit, angle)v
  463. Sets the spot *angle* of the light.
  464. **light_debug_draw** (rw, unit, debug_line)
  465. Fills *debug_line* with debug lines from the light.
  466. PhysicsWorld
  467. =============
  468. **gravity** (pw) : Vector3
  469. Returns the gravity.
  470. **set_gravity** (pw, gravity)
  471. Sets the gravity.
  472. **raycast** (pw, from, dir, length, mode) : table
  473. Returns the actors which intersects the raycast.
  474. Mode can be either ``closest`` or ``all``.
  475. **enable_debug_drawing** (pw, enable)
  476. Sets whether to *enable* debug drawing.
  477. Actor
  478. -----
  479. **actor_instances** (pw, unit) : Id
  480. Returns the IDs for all the actors of the *unit*.
  481. **actor_world_position** (pw, actor) : Vector3
  482. Returns the world position of the actor.
  483. **actor_world_rotation** (pw, actor) : Quaternion
  484. Returns the world rotation of the actor.
  485. **actor_world_pose** (pw, actor) : Matrix4x4
  486. Returns the world pose of the actor.
  487. **actor_teleport_world_position** (pw, actor, position)
  488. Teleports the actor to the given world position.
  489. **actor_teleport_world_rotation** (pw, actor, rotation)
  490. Teleports the actor to the given world rotation.
  491. **actor_teleport_world_pose** (pw, actor, pose)
  492. Teleports the actor to the given world pose.
  493. **actor_center_of_mass** (pw, actor) : Vector3
  494. Returns the center of mass of the actor.
  495. **actor_enable_gravity** (pw, actor)
  496. Enables gravity for the actor.
  497. **actor_disable_gravity** (pw, actor)
  498. Disables gravity for the actor.
  499. **actor_enable_collision** (pw, actor)
  500. Enables collision detection for the actor.
  501. **actor_disable_collision** (pw, actor)
  502. Disables collision detection for the actor.
  503. **actor_set_collision_filter** (pw, actor, name)
  504. Sets the collision filter of the actor.
  505. **actor_set_kinematic** (pw, actor, kinematic)
  506. Sets whether the actor is kinematic or not.
  507. Note that this call has no effect on static actors.
  508. **actor_move** (pw, actor, position)
  509. Moves the actor to *pos*
  510. Note that this call only affects nonkinematic actors.
  511. **actor_is_static** (pw, actor) : bool
  512. Returns whether the actor is static.
  513. **actor_is_dynamic** (pw, actor) bool
  514. Returns whether the actor is dynamic.
  515. **actor_is_kinematic** (pw, actor) : bool
  516. Returns whether the actor is kinematic (keyframed).
  517. **actor_is_nonkinematic** (pw, actor) : bool
  518. Returns whether the actor is nonkinematic (i.e. dynamic and not kinematic).
  519. **actor_linear_damping** (pw, actor) : float
  520. Returns the linear damping of the actor.
  521. **actor_set_linear_damping** (pw, actor, damping)
  522. Sets the linear damping of the actor.
  523. **actor_angular_damping** (pw, actor) : float
  524. Returns the angular damping of the actor.
  525. **actor_set_angular_damping** (pw, actor, rate)
  526. Sets the angular damping of the actor.
  527. **actor_linear_velocity** (pw, actor) : Vector3
  528. Returns the linear velocity of the actor.
  529. **actor_set_linear_velocity** (pw, actor, velocity)
  530. Sets the linear velocity of the actor.
  531. Note that this call only affects nonkinematic actors.
  532. **actor_angular_velocity** (pw, actor) : Vector3
  533. Returns the angular velocity of the actor.
  534. **actor_set_angular_velocity** (pw, actor, velocity)
  535. Sets the angular velocity of the actor.
  536. Note that this call only affects nonkinematic actors.
  537. **actor_add_impulse** (pw, actor, impulse)
  538. Adds a linear impulse (acting along the center of mass) to the actor.
  539. Note that this call only affects nonkinematic actors.
  540. **actor_add_impulse_at** (pw, actor, impulse, position)
  541. Adds a linear impulse (acting along the world position *pos*) to the actor.
  542. Note that this call only affects nonkinematic actors.
  543. **actor_add_torque_impulse** (pw, actor, impulse)
  544. Adds a torque impulse to the actor.
  545. **actor_push** (pw, actor, velocity, mass)
  546. Pushes the actor as if it was hit by a point object with the given *mass*
  547. travelling at the given *velocity*.
  548. Note that this call only affects nonkinematic actors.
  549. **actor_push_at** (pw, actor, velocity, mass, position)
  550. Like push() but applies the force at the world position *pos*.
  551. Note that this call only affects nonkinematic actors.
  552. **actor_is_sleeping** (pw, actor) : bool
  553. Returns whether the actor is sleeping.
  554. **actor_wake_up** (pw, actor)
  555. Wakes the actor up.
  556. SoundWorld
  557. ===========
  558. **stop_all** (sound_world)
  559. Stops all the sounds in the world.
  560. **pause_all** (sound_world)
  561. Pauses all the sounds in the world
  562. **resume_all** (sound_world)
  563. Resumes all previously paused sounds in the world.
  564. **is_playing** (sound_world, id) : bool
  565. Returns whether the sound *id* is playing.
  566. ResourcePackage
  567. ================
  568. **load** (package)
  569. Loads all the resources in the package.
  570. Note that the resources are not immediately available after the call is made,
  571. instead, you have to poll for completion with has_loaded().
  572. **unload** (package)
  573. Unloads all the resources in the package.
  574. **flush** (package)
  575. Waits until the package has been loaded.
  576. **has_loaded** (package) : bool
  577. Returns whether the package has been loaded.
  578. Device
  579. ======
  580. **argv** () : table
  581. Returns a table containing the command line parameters the engine was started with.
  582. **platform** () : string
  583. Returns a string identifying what platform the engine is running on.
  584. It can be either ``android``, ``linux`` or ``windows``
  585. **architecture** () : string
  586. Returns a string identifying what architecture the engine is running on.
  587. It can be either ``32-bit`` or ``64-bit``.
  588. **version** () : string
  589. Returns a string identifying the engine version.
  590. The form is "major.minor.micro".
  591. **last_delta_time** () : float
  592. Returns the time in seconds needed to render the last frame
  593. **quit** ()
  594. Quits the application.
  595. **resolution** () : float, float
  596. Returns the main window resolution (width, height).
  597. **create_world** () : World
  598. Creates a new world.
  599. **destroy_world** (world)
  600. Destroys the given *world*.
  601. **render** (world, camera)
  602. Renders *world* using *camera*.
  603. **create_resource_package** (name) : ResourcePackage
  604. Returns the resource package with the given *package_name* name.
  605. **destroy_resource_package** (package)
  606. Destroy a previously created resource *package*.
  607. Note that to unload the resources loaded by the package, you have to call
  608. ResourcePackage.unload() first.
  609. **console_send** (table)
  610. Sends the given lua *table* to clients connected to the engine.
  611. Values can be either ``nil``, bool, number, string, table, array, Vector2, Vector3, Quaternion, Matrix4x4 or Color4.
  612. **can_get** (type, name) : bool
  613. Returns whether the resource (type, name) is loaded.
  614. When resource autoload is enabled it always returns true.
  615. **enable_resource_autoload** (enable)
  616. Sets whether resources should be automatically loaded when accessed.
  617. **temp_count** () : int, int, int
  618. Returns the number of temporary objects used by Lua.
  619. **set_temp_count** (nv, nq, nm)
  620. Sets the number of temporary objects used by Lua.
  621. **guid** () : string
  622. Returns a new GUID.
  623. DebugGui
  624. ========
  625. **rect** (pos, size, material_resource, color)
  626. Draws a rectangle.
  627. **image** (pos, size, material_resource, color)
  628. Draws an image.
  629. **image_uv** (pos, size, uv0, uv1, material_resource, color)
  630. Draws an image with explicit UV coordinates.
  631. **text** (pos, font_size, str, font_resource, material_resource, color)
  632. Draws text.
  633. DebugLine
  634. =========
  635. **add_line** (debug_line, start, end, color)
  636. Adds a line from *start* to *end* with the given *color*.
  637. **add_axes** (debug_line, tm, length)
  638. Adds lines for each axis with the given *length*.
  639. **add_circle** (debug_line, center, radius, normal, color, [segments = 36])
  640. Adds a circle at *center* with the given *radius* and *normal* vector.
  641. **add_cone** (debug_line, from, to, radius, color, [segments = 36])
  642. Adds a cone with the base centered at *from* and the tip at *to*.
  643. **add_sphere** (debug_line, center, radius, color, [segments = 36])
  644. Adds a sphere at *center* with the given *radius*.
  645. **add_obb** (debug_line, tm, half_extents, color)
  646. Adds an orientd bounding box. *tm* describes the position and orientation of
  647. the box. *half_extents* describes the size of the box along the axis.
  648. **add_frustum** (debug_line, mvp, color)
  649. Adds a frustum defined by *mvp*.
  650. **add_unit** (debug_line, tm, name, color)
  651. Adds the meshes from the unit *name*.
  652. **reset** (debug_line)
  653. Resets all the lines.
  654. **submit** (debug_line)
  655. Submits the lines to renderer for drawing.
  656. Input
  657. =====
  658. Keyboard
  659. --------
  660. **name** () : string
  661. Returns the name of keyboard.
  662. **connected** () : bool
  663. Returns whether the keyboard is connected and functioning.
  664. **num_buttons** () : int
  665. Returns the number of buttons of the keyboard.
  666. **num_axes** () : int
  667. Returns the number of axes of the keyboard.
  668. **pressed** (id) : bool
  669. Returns whether the button *id* is pressed in the current frame.
  670. **released** (id) : bool
  671. Returns whether the button *id* is released in the current frame.
  672. **any_pressed** () : bool
  673. Returns whether any button is pressed in the current frame.
  674. **any_released** () : bool
  675. Returns whether any button is released in the current frame.
  676. **button_name** (id) : string
  677. Returns the name of the button *id*.
  678. **button_id** (name) : int
  679. Returns the *id* of the button *name* or ``nil`` if no matching button is found.
  680. Keyboard Button Names
  681. ~~~~~~~~~~~~~~~~~~~~~
  682. * ``tab``, ``enter``, ``escape``, ``space``, ``backspace``
  683. * ``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``
  684. * ``f1``, ``f2``, ``f3``, ``f4``, ``f5``, ``f6``, ``f7``, ``f8``, ``f9``, ``f10``, ``f11``, ``f12``
  685. * ``home``, ``left``, ``up``, ``right``, ``down``, ``page_up``, ``page_down``, ``ins``, ``del``, ``end``
  686. * ``ctrl_left``, ``ctrl_right``, ``shift_left``, ``shift_right``, ``caps_lock``, ``alt_left``, ``alt_right``, ``super_left``, ``super_right``
  687. * ``0``, ``1``, ``2``, ``3``, ``4``, ``5``, ``6``, ``7``, ``8``, ``9``
  688. * ``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``
  689. Keyboard Axis Names
  690. ~~~~~~~~~~~~~~~~~~~
  691. None.
  692. Mouse
  693. -----
  694. **name** () : string
  695. Returns the name of the mouse.
  696. **connected** () : bool
  697. Returns whether the mouse is connected and functioning.
  698. **num_buttons** () : int
  699. Returns the number of buttons of the mouse.
  700. **num_axes** () : int
  701. Returns the number of axes of the mouse.
  702. **pressed** (id) : bool
  703. Returns whether the button *id* is pressed in the current frame.
  704. **released** (id) : bool
  705. Returns whether the button *id* is released in the current frame.
  706. **any_pressed** () : bool
  707. Returns whether any button is pressed in the current frame.
  708. **any_released** () : bool
  709. Returns whether any button is released in the current frame.
  710. **axis** (id) : Vector3
  711. Returns the value of the axis *id*.
  712. **button_name** (id) : string
  713. Returns the name of the button *id*.
  714. **axis_name** (id) : string
  715. Returns the name of the axis *id*.
  716. **button_id** (name) : int
  717. Returns the *id* of the button *name* or ``nil`` if no matching button is found.
  718. **axis_id** (name) : int
  719. Returns the *id* of the axis *name* or ``nil`` if no matching axis is found.
  720. Mouse Button Names
  721. ~~~~~~~~~~~~~~~~~~
  722. ``left``, ``middle``, ``right``, ``extra_1``, ``extra_2``
  723. Mouse Axis Names
  724. ~~~~~~~~~~~~~~~~
  725. * ``cursor``: Returns the cursor position (x, y) in screen coordinates.
  726. * ``cursor_delta``: Returns the delta of the cursor position (x, y) since last frame.
  727. * ``wheel``: Returns the movement of the mouse wheel in the y axis. Positive values of y mean upward scrolling, negative values mean downward scrolling.
  728. Touch
  729. -----
  730. **name** () : string
  731. Returns the name of the touch.
  732. **connected** () : bool
  733. Returns whether the touch is connected and functioning.
  734. **num_buttons** () : int
  735. Returns the number of buttons of the touch.
  736. **num_axes** () : int
  737. Returns the number of axes of the touch.
  738. **pressed** (id) : bool
  739. Returns whether the button *id* is pressed in the current frame.
  740. **released** (id) : bool
  741. Returns whether the button *id* is released in the current frame.
  742. **any_pressed** () : bool
  743. Returns whether any button is pressed in the current frame.
  744. **any_released** () : bool
  745. Returns whether any button is released in the current frame.
  746. **axis** (id) : Vector3
  747. Returns the value of the axis *id*.
  748. **button_name** (id) : string
  749. Returns the name of the button *id*.
  750. **axis_name** (id) : string
  751. Returns the name of the axis *id*.
  752. **button_id** (name) : int
  753. Returns the *id* of the button *name* or ``nil`` if no matching button is found.
  754. **axis_id** (name) : int
  755. Returns the *id* of the axis *name* or ``nil`` if no matching axis is found.
  756. Pad1, Pad2, Pad3, Pad4
  757. ----------------------
  758. **name** () : string
  759. Returns the name of the pad.
  760. **connected** () : bool
  761. Returns whether the pad is connected and functioning.
  762. **num_buttons** () : int
  763. Returns the number of buttons of the pad.
  764. **num_axes** () : int
  765. Returns the number of axes of the pad.
  766. **pressed** (id) : bool
  767. Returns whether the button *id* is pressed in the current frame.
  768. **released** (id) : bool
  769. Returns whether the button *id* is released in the current frame.
  770. **any_pressed** () : bool
  771. Returns whether any button is pressed in the current frame.
  772. **any_released** () : bool
  773. Returns whether any button is released in the current frame.
  774. **axis** (id) : Vector3
  775. Returns the value of the axis *id*.
  776. **button_name** (id) : string
  777. Returns the name of the button *id*.
  778. **axis_name** (id) : string
  779. Returns the name of the axis *id*.
  780. **button_id** (name) : int
  781. Returns the *id* of the button *name* or ``nil`` if no matching button is found.
  782. **axis_id** (name) : int
  783. Returns the *id* of the axis *name* or ``nil`` if no matching axis is found.
  784. Pad Button Names
  785. ~~~~~~~~~~~~~~~~
  786. * ``up``, ``down``, ``left``, ``right``
  787. * ``start``, ``back``, ``guide``
  788. * ``thumb_left``, ``thumb_right``
  789. * ``shoulder_left``, ``shoulder_right``
  790. * ``a``, ``b``, ``x``, ``y``
  791. Pad Axis Names
  792. ~~~~~~~~~~~~~~
  793. * ``left``, ``right``: Returns the direction (x, y) of the left or right thumbstick [-1; +1]. The z element represents the left or right trigger [0; +1].
  794. Profiler
  795. ========
  796. **enter_scope** (name)
  797. Starts a new profile scope with the given *name*.
  798. **leave_scope** ()
  799. Ends the last profile scope.
  800. **record** (name, value)
  801. Records *value* with the given *name*. Value can be either number or Vector3.
  802. Display
  803. =======
  804. **modes** () : table
  805. Returns an array of display modes. See `Display Mode`_.
  806. **set_mode** (id)
  807. Sets the display mode *id*.
  808. The initial display mode is automatically reset when the program terminates.
  809. Display Mode
  810. ------------
  811. Display mode is a lua table with 3 fields:
  812. * ``id``: The id of the display mode.
  813. * ``width``: The width of the display mode.
  814. * ``height``: The height of the display mode.
  815. Window
  816. ======
  817. **show** ()
  818. Shows the window.
  819. **hide** ()
  820. Hides the window.
  821. **resize** (width, height)
  822. Resizes the window to *width* and *height*.
  823. **move** (x, y)
  824. Moves the window to *x* and *y*.
  825. **minimize** ()
  826. Minimizes the window.
  827. **restore** ()
  828. Restores the window.
  829. **title** () : string
  830. Returns the title of the window.
  831. **set_title** (title)
  832. Sets the title of the window.
  833. **show_cursor** (show)
  834. Sets whether to *show* the cursor.