lua_api.rst 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293
  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 length of *a*.
  48. **length_squared** (a) : float
  49. Returns the squared length of *a*.
  50. **set_length** (a, len)
  51. Sets the length 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. **invert** (m) : Matrix4x4
  188. Inverts the matrix *m* and returns the result.
  189. **x** (m) : Vector3
  190. Returns the x axis of the matrix *m*.
  191. **y** (m) : Vector3
  192. Returns the y axis of the matrix *m*.
  193. **z** (m) : Vector3
  194. Returns the z axis of the matrix *m*.
  195. **set_x** (m, x)
  196. Sets the x axis of the matrix *m*.
  197. **set_y** (m, y)
  198. Sets the y axis of the matrix *m*.
  199. **set_z** (m, z)
  200. Sets the z axis of the matrix *m*.
  201. **rotation** (m) : Quaternion
  202. Returns the rotation portion of the matrix *m*.
  203. **set_rotation** (m, r)
  204. Sets the rotation portion of the matrix *m*.
  205. **translation** (m) : Vector3
  206. Returns the translation portion of the matrix *m*.
  207. **set_translation** (m, t)
  208. Sets the translation portion of the matrix *m*.
  209. **identity** ()
  210. Returns the identity matrix.
  211. **transform** (m, v) : Vector3
  212. Transforms the vector *v* by the matrix *m* and returns the result.
  213. **to_string** (m) : string
  214. Returns a string representing the matrix *m*.
  215. Matrix4x4Box
  216. ------------
  217. Constructors
  218. ~~~~~~~~~~~~
  219. **Matrix4x4Box** () : Matrix4x4Box
  220. Returns a new Matrix4x4Box initialized with the identity matrix.
  221. **Matrix4x4Box** (m) : Matrix4x4Box
  222. Returns a new Matrix4x4Box from the Matrix4x4 *m*.
  223. Functions
  224. ~~~~~~~~~
  225. **store** (m)
  226. Stores the Matrix4x4 *m* in the box.
  227. **unbox** () : Matrix4x4
  228. Returns the stored matrix from the box.
  229. Color4
  230. ------
  231. Constructors
  232. ~~~~~~~~~~~~
  233. **Color4** (r, g, b, a) : Color4
  234. Returns a new Color4 from individual elements.
  235. Functions
  236. ~~~~~~~~~
  237. **lerp** (a, b, t) : Color4
  238. Returns the linearly interpolated color between *a* and *b* at time *t* in [0, 1].
  239. | **black** () : Color4
  240. | **white** () : Color4
  241. | **red** () : Color4
  242. | **green** () : Color4
  243. | **blue** () : Color4
  244. | **yellow** () : Color4
  245. | **orange** () : Color4
  246. | Returns the corresponding mnemonic color.
  247. **to_string** (c) : string
  248. Returns a string representing the color *c*.
  249. Math
  250. ----
  251. **ray_plane_intersection** (from, dir, point, normal) : float
  252. Returns the distance along ray (from, dir) to intersection point with plane defined by
  253. *point* and *normal* or -1.0 if no intersection.
  254. **ray_disc_intersection** (from, dir, center, radius, normal) : float
  255. Returns the distance along ray (from, dir) to intersection point with disc defined by
  256. *center*, *radius* and *normal* or -1.0 if no intersection.
  257. **ray_sphere_intersection** (from, dir, center, radius) : float
  258. Returns the distance along ray (from, dir) to intersection point with sphere defined by
  259. *center* and *radius* or -1.0 if no intersection.
  260. **ray_obb_intersection** (from, dir, tm, half_extents) : float
  261. Returns the distance along ray (from, dir) to intersection point with the oriented
  262. bounding box (tm, half_extents) or -1.0 if no intersection.
  263. **ray_triangle_intersection** (from, dir, v0, v1, v2) : float
  264. Returns the distance along ray (from, dir) to intersection point with the triangle
  265. (v0, v1, v2) or -1.0 if no intersection.
  266. UnitManager
  267. ===========
  268. **create** ([world]) : UnitId
  269. Creates a new empty unit. If *world* is specified, the unit will be owned by
  270. that world.
  271. **destroy** (unit)
  272. Destroys the given *unit*.
  273. **alive** (unit) : bool
  274. Returns whether the unit is alive.
  275. World
  276. =====
  277. **spawn_unit** (world, name, [position, rotation]) : UnitId
  278. Spawns a new instance of the unit *name* at the given *position* and *rotation*.
  279. **spawn_empty_unit** (world) : UnitId
  280. Spawns a new empty unit and returns its id.
  281. **destroy_unit** (world, unit)
  282. Destroys the given *unit*.
  283. **num_units** (world) : int
  284. Returns the number of units in the *world*.
  285. **units** (world) : table
  286. Returns all the the units in the world in a table.
  287. **update_animations** (world, dt)
  288. Update all animations with *dt*.
  289. **update_scene** (world, dt)
  290. Updates the scene with *dt*.
  291. **update** (world, dt)
  292. Updates the world with *dt*.
  293. **create_debug_line** (world, depth_test) : DebugLine
  294. Creates a new DebugLine. *depth_test* controls whether to
  295. enable depth test when rendering the lines.
  296. **destroy_debug_line** (world, line)
  297. Destroys the debug *line*.
  298. **create_screen_gui** (world) : Gui
  299. Creates a new Gui.
  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. **animation_state_machine** (world) : AnimationStateMachine
  309. Returns the animation state machine.
  310. Camera
  311. ------
  312. **camera_create** (world, unit, projection, fov, far_range, near_range, pose) : Id
  313. Creates a new camera for *unit* and returns its id.
  314. Projection can be either ``orthographic`` or ``perspective``.
  315. **camera_instances** (world, unit) : Id
  316. Returns the IDs for all the cameras of the *unit*.
  317. **camera_set_projection_type** (world, unit, projection)
  318. Sets the projection type of the camera.
  319. Projection can be either ``orthographic`` or ``perspective``.
  320. **camera_projection_type** (world, unit) : string
  321. Returns the projection type of the camera.
  322. It can be either ``orthographic`` or ``perspective``.
  323. **camera_fov** (world, unit) : float
  324. Returns the field-of-view of the camera in degrees.
  325. **camera_set_fov** (world, unit, fov)
  326. Sets the field-of-view of the camera in degrees.
  327. **camera_near_clip_distance** (world, unit) : float
  328. Returns the near clip distance of the camera.
  329. **camera_set_near_clip_distance** (world, unit, near)
  330. Sets the near clip distance of the camera.
  331. **camera_far_clip_distance** (world, unit) : float
  332. Returns the far clip distance of the camera.
  333. **camera_set_far_clip_distance** (world, unit, far)
  334. Sets the far clip distance of the camera.
  335. **camera_set_orthographic_size** (world, unit, half_size)
  336. Sets the vertical *half_size* of the orthographic view volume.
  337. The horizontal size is proportional to the viewport's aspect ratio.
  338. **camera_screen_to_world** (world, unit, pos) : Vector3
  339. Returns *pos* from screen-space to world-space coordinates.
  340. **camera_world_to_screen** (world, unit, pos) : Vector3
  341. Returns *pos* from world-space to screen-space coordinates.
  342. Sound
  343. -----
  344. **play_sound** (world, name, [loop, volume, position, range]) : SoundInstanceId
  345. Plays the sound with the given *name* at the given *position*, with the given
  346. *volume* and *range*. *loop* controls whether the sound must loop or not.
  347. **stop_sound** (world, id)
  348. Stops the sound with the given *id*.
  349. **link_sound** (world, id, unit, node)
  350. Links the sound *id* to the *node* of the given *unit*.
  351. After this call, the sound *id* will follow the unit *unit*.
  352. **set_listener_pose** (world, pose)
  353. Sets the *pose* of the listener.
  354. **set_sound_position** (world, id, position)
  355. Sets the *position* of the sound *id*.
  356. **set_sound_range** (world, id, range)
  357. Sets the *range* of the sound *id*.
  358. **set_sound_volume** (world, id, volume)
  359. Sets the *volume* of the sound *id*.
  360. Level
  361. -----
  362. **load_level** (world, name, [pos, rot]) : Level
  363. Loads the level *name* into the world at the given *position* and *rotation*.
  364. SceneGraph
  365. ==========
  366. **create** (sg, unit, position, rotation, scale) : Id
  367. Creates the transform for the *unit* and returns its ID.
  368. **destroy** (sg, unit, id)
  369. Destroys the transform for the *unit*. The transform *id* is ignored.
  370. **instances** (sg, unit) : Id
  371. Returns the IDs for all the transforms of the *unit*.
  372. **local_position** (sg, unit) : Vector3
  373. Returns the local position of the *unit*.
  374. **local_rotation** (sg, unit) : Quaternion
  375. Returns the local rotation of the *unit*.
  376. **local_scale** (sg, unit) : Vector3
  377. Returns the local scale of the *unit*.
  378. **local_pose** (sg, unit) : Matrix4x4
  379. Returns the local pose of the *unit*.
  380. **world_position** (sg, unit) : Vector3
  381. Returns the world position of the *unit*.
  382. **world_rotation** (sg, unit) : Quaternion
  383. Returns the world rotation of the *unit*.
  384. **world_pose** (sg, unit) : Matrix4x4
  385. Returns the world pose of the *unit*.
  386. **set_local_position** (sg, unit, position)
  387. Sets the local *position* of the *unit*.
  388. **set_local_rotation** (sg, unit, rotation)
  389. Sets the local *rotation* of the *unit*.
  390. **set_local_scale** (sg, unit, scale)
  391. Sets the local *scale* of the *unit*.
  392. **set_local_pose** (sg, unit, pose)
  393. Sets the local *pose* of the *unit*.
  394. **link** (sg, child, parent)
  395. Links the unit *child* to the unit *parent*.
  396. **unlink** (sg, unit)
  397. Unlinks the *unit* from its parent if it has any.
  398. After unlinking, the @a unit's local pose is set to its previous world pose.
  399. Material
  400. ========
  401. **set_float** (material, name, value)
  402. Sets the *value* of the variable *name*.
  403. **set_vector2** (material, name, value)
  404. Sets the *value* of the variable *name*.
  405. **set_vector3** (material, name, value)
  406. Sets the *value* of the variable *name*.
  407. RenderWorld
  408. ===========
  409. **enable_debug_drawing** (rw, enable)
  410. Sets whether to *enable* debug drawing.
  411. Mesh
  412. ----
  413. **mesh_create** (rw, unit, mesh_resource, geometry_name, material_resource, visible, pose) : Id
  414. Creates a new mesh instance for *unit* and returns its id.
  415. **mesh_destroy** (rw, id)
  416. Destroys the mesh *id*.
  417. **mesh_instances** (rw, unit) : Id
  418. Returns the IDs for all the meshes of the *unit*.
  419. **mesh_obb** (rw, id) : Matrix4x4, Vector3
  420. Returns the OBB of the mesh *id* as (pose, half_extents).
  421. **mesh_raycast** (rw, id, from, dir) : float
  422. Returns the distance along ray (from, dir) to intersection point with the mesh *id* or -1.0 if no intersection.
  423. Sprite
  424. ------
  425. **sprite_create** (rw, unit, sprite_resource, material_resource, visible, pose) : Id
  426. Creates a new sprite instance for the *unit* and returns its id.
  427. **sprite_destroy** (rw, unit)
  428. Destroys the sprite of the *unit*.
  429. **sprite_instances** (rw, unit) : Id
  430. Returns the IDs for all the sprites of the *unit*.
  431. **sprite_set_frame** (rw, unit, index)
  432. Sets the frame *index* of the sprite.
  433. **sprite_set_visible** (rw, unit, visible)
  434. Sets whether the sprite is *visible*.
  435. **sprite_flip_x** (rw, unit, flip)
  436. Sets whether to flip the sprite on the x-axis.
  437. **sprite_flip_y** (rw, unit, flip)
  438. Sets whether to flip the sprite on the y-axis.
  439. **sprite_set_layer** (rw, unit, layer)
  440. Sets the layer of the sprite.
  441. **sprite_set_depth** (rw, unit, depth)
  442. Sets the depth of the sprite.
  443. **sprite_obb** (rw, unit) : Matrix4x4, Vector3
  444. Returns the OBB of the sprite as (pose, half_extents).
  445. **sprite_raycast** (rw, unit, from, dir) : float, int, int
  446. Returns (t, layer, depth), where *t* is the distance along ray (from, dir) to
  447. intersection point with the sprite or -1.0 if no intersection.
  448. Light
  449. -----
  450. **light_create** (rw, unit, type, range, intensity, spot_angle, color, pose) : Id
  451. Creates a new light for the *unit* and returns its id.
  452. Type can be either ``directional``, ``omni`` or ``spot``.
  453. **light_destroy** (rw, unit)
  454. Destroys the light of the *unit*.
  455. **light_instances** (rw, unit) : Id
  456. Returns the IDs for all the lights of the *unit*.
  457. **light_type** (rw, unit) : string
  458. Returns the type of the light of the *unit*.
  459. It can be either ``directional``, ``omni`` or ``spot``.
  460. **light_color** (rw, unit) : Color4
  461. Returns the color of the light.
  462. **light_range** (rw, unit) : float
  463. Returns the range of the light.
  464. **light_intensity** (rw, unit) : float
  465. Returns the intensity of the light.
  466. **light_spot_angle** (rw, unit) : float
  467. Returns the spot angle of the light.
  468. **light_set_type** (rw, unit, type)
  469. Sets the *type* of the light.
  470. **light_set_color** (rw, unit, color)
  471. Sets the *color* of the light.
  472. **light_set_range** (rw, unit, range)
  473. Sets the *range* of the light.
  474. **light_set_intensity** (rw, unit, intensity)
  475. Sets the *intensity* of the light.
  476. **light_set_spot_angle** (rw, unit, angle)
  477. Sets the spot *angle* of the light.
  478. **light_debug_draw** (rw, unit, debug_line)
  479. Fills *debug_line* with debug lines from the light.
  480. PhysicsWorld
  481. =============
  482. **gravity** (pw) : Vector3
  483. Returns the gravity.
  484. **set_gravity** (pw, gravity)
  485. Sets the gravity.
  486. **raycast_closest** (pw, from, dir, length) : hit, collision_pos, normal, Actor
  487. Casts a ray into the physics world and returns the closest
  488. actor it intersects with.
  489. If *hit* is true the following return values contain
  490. the *collision_pos* in world space, the *normal* of
  491. the surface that was hit and the *actor* that was hit.
  492. **raycast_all** (pw, from, dir, length) : table
  493. Casts a ray into the physics world and returns all the
  494. actors it intersects with as an array of `RaycastHit`_ tables.
  495. **enable_debug_drawing** (pw, enable)
  496. Sets whether to *enable* debug drawing.
  497. RaycastHit
  498. ----------
  499. RaycastHit is a lua table with 3 fields:
  500. * ``[1]``: The collision position in world space.
  501. * ``[2]``: The normal of the surface that was hit.
  502. * ``[3]``: The actor that was hit.
  503. Actor
  504. -----
  505. **actor_instances** (pw, unit) : Id
  506. Returns the IDs for all the actors of the *unit*.
  507. **actor_world_position** (pw, actor) : Vector3
  508. Returns the world position of the actor.
  509. **actor_world_rotation** (pw, actor) : Quaternion
  510. Returns the world rotation of the actor.
  511. **actor_world_pose** (pw, actor) : Matrix4x4
  512. Returns the world pose of the actor.
  513. **actor_teleport_world_position** (pw, actor, position)
  514. Teleports the actor to the given world position.
  515. **actor_teleport_world_rotation** (pw, actor, rotation)
  516. Teleports the actor to the given world rotation.
  517. **actor_teleport_world_pose** (pw, actor, pose)
  518. Teleports the actor to the given world pose.
  519. **actor_center_of_mass** (pw, actor) : Vector3
  520. Returns the center of mass of the actor.
  521. **actor_enable_gravity** (pw, actor)
  522. Enables gravity for the actor.
  523. **actor_disable_gravity** (pw, actor)
  524. Disables gravity for the actor.
  525. **actor_enable_collision** (pw, actor)
  526. Enables collision detection for the actor.
  527. **actor_disable_collision** (pw, actor)
  528. Disables collision detection for the actor.
  529. **actor_set_collision_filter** (pw, actor, name)
  530. Sets the collision filter of the actor.
  531. **actor_set_kinematic** (pw, actor, kinematic)
  532. Sets whether the actor is kinematic or not.
  533. .. note::
  534. This call has no effect on static actors.
  535. **actor_is_static** (pw, actor) : bool
  536. Returns whether the actor is static.
  537. **actor_is_dynamic** (pw, actor) bool
  538. Returns whether the actor is dynamic.
  539. **actor_is_kinematic** (pw, actor) : bool
  540. Returns whether the actor is kinematic (keyframed).
  541. **actor_is_nonkinematic** (pw, actor) : bool
  542. Returns whether the actor is nonkinematic (i.e. dynamic and not kinematic).
  543. **actor_linear_damping** (pw, actor) : float
  544. Returns the linear damping of the actor.
  545. **actor_set_linear_damping** (pw, actor, damping)
  546. Sets the linear damping of the actor.
  547. **actor_angular_damping** (pw, actor) : float
  548. Returns the angular damping of the actor.
  549. **actor_set_angular_damping** (pw, actor, rate)
  550. Sets the angular damping of the actor.
  551. **actor_linear_velocity** (pw, actor) : Vector3
  552. Returns the linear velocity of the actor.
  553. **actor_set_linear_velocity** (pw, actor, velocity)
  554. Sets the linear velocity of the actor.
  555. .. note::
  556. This call only affects nonkinematic actors.
  557. **actor_angular_velocity** (pw, actor) : Vector3
  558. Returns the angular velocity of the actor.
  559. **actor_set_angular_velocity** (pw, actor, velocity)
  560. Sets the angular velocity of the actor.
  561. .. note::
  562. This call only affects nonkinematic actors.
  563. **actor_add_impulse** (pw, actor, impulse)
  564. Adds a linear impulse (acting along the center of mass) to the actor.
  565. .. note::
  566. This call only affects nonkinematic actors.
  567. **actor_add_impulse_at** (pw, actor, impulse, position)
  568. Adds a linear impulse (acting along the world position *pos*) to the actor.
  569. .. note::
  570. This call only affects nonkinematic actors.
  571. **actor_add_torque_impulse** (pw, actor, impulse)
  572. Adds a torque impulse to the actor.
  573. **actor_push** (pw, actor, velocity, mass)
  574. Pushes the actor as if it was hit by a point object with the given *mass*
  575. travelling at the given *velocity*.
  576. .. note::
  577. This call only affects nonkinematic actors.
  578. **actor_push_at** (pw, actor, velocity, mass, position)
  579. Like push() but applies the force at the world position *pos*.
  580. .. note::
  581. This call only affects nonkinematic actors.
  582. **actor_is_sleeping** (pw, actor) : bool
  583. Returns whether the actor is sleeping.
  584. **actor_wake_up** (pw, actor)
  585. Wakes the actor up.
  586. SoundWorld
  587. ===========
  588. **stop_all** (sound_world)
  589. Stops all the sounds in the world.
  590. **pause_all** (sound_world)
  591. Pauses all the sounds in the world
  592. **resume_all** (sound_world)
  593. Resumes all previously paused sounds in the world.
  594. **is_playing** (sound_world, id) : bool
  595. Returns whether the sound *id* is playing.
  596. AnimationStateMachine
  597. =====================
  598. **variable_id** (state_machine, unit, name) : Id
  599. Returns the ID of the variable *name* in the *state_machine*.
  600. **variable** (state_machine, unit, variable_id) : number
  601. Returns the value of the *variable_id* in the *state_machine*.
  602. **set_variable** (state_machine, unit, variable_id, value)
  603. Sets the *value* of the *variable_id* in the *state_machine*.
  604. **trigger** (state_machine, unit, name)
  605. Triggers the event *name* in the *state_machine*.
  606. ResourcePackage
  607. ===============
  608. **load** (package)
  609. Loads all the resources in the *package*.
  610. .. note::
  611. The resources are not immediately available after the call is made,
  612. instead, you have to poll for completion with has_loaded().
  613. **unload** (package)
  614. Unloads all the resources in the *package*.
  615. **flush** (package)
  616. Waits until the *package* has been loaded.
  617. **has_loaded** (package) : bool
  618. Returns whether the *package* has been loaded.
  619. Device
  620. ======
  621. **argv** () : table
  622. Returns a table containing the command line parameters the engine was started with.
  623. **platform** () : string
  624. Returns a string identifying what platform the engine is running on.
  625. It can be either ``android``, ``linux`` or ``windows``
  626. **architecture** () : string
  627. Returns a string identifying what architecture the engine is running on.
  628. It can be either ``32-bit`` or ``64-bit``.
  629. **version** () : string
  630. Returns a string identifying the engine version.
  631. The form is "major.minor.micro".
  632. **quit** ()
  633. Quits the application.
  634. **resolution** () : float, float
  635. Returns the main window resolution (width, height).
  636. **create_world** () : World
  637. Creates a new world.
  638. **destroy_world** (world)
  639. Destroys the given *world*.
  640. **render** (world, camera)
  641. Renders *world* using *camera*.
  642. **create_resource_package** (name) : ResourcePackage
  643. Returns the resource package with the given *package_name* name.
  644. **destroy_resource_package** (package)
  645. Destroy a previously created resource *package*.
  646. .. note::
  647. To unload the resources loaded by the package, you have to call
  648. ResourcePackage.unload() first.
  649. **console_send** (table)
  650. Sends the given lua *table* to clients connected to the engine.
  651. Values can be either ``nil``, bool, number, string, table, array, Vector2, Vector3, Quaternion, Matrix4x4 or Color4.
  652. **can_get** (type, name) : bool
  653. Returns whether the resource (type, name) is loaded.
  654. When resource autoload is enabled it always returns true.
  655. **enable_resource_autoload** (enable)
  656. Sets whether resources should be automatically loaded when accessed.
  657. **temp_count** () : int, int, int
  658. Returns the number of temporary objects used by Lua.
  659. **set_temp_count** (nv, nq, nm)
  660. Sets the number of temporary objects used by Lua.
  661. **guid** () : string
  662. Returns a new GUID.
  663. Gui
  664. ===
  665. **move** (pos)
  666. Moves the Gui to *pos*.
  667. **triangle** (a, b, c, color)
  668. Draws a triangle defined by vertices *a*, *b* and *c*.
  669. **rect** (pos, size, color)
  670. Draws a rectangle.
  671. **image** (pos, size, material_resource, color)
  672. Draws an image.
  673. **image_uv** (pos, size, uv0, uv1, material_resource, color)
  674. Draws an image with explicit UV coordinates.
  675. **text** (pos, font_size, str, font_resource, material_resource, color)
  676. Draws text.
  677. DebugLine
  678. =========
  679. **add_line** (debug_line, start, end, color)
  680. Adds a line from *start* to *end* with the given *color*.
  681. **add_axes** (debug_line, tm, length)
  682. Adds lines for each axis with the given *length*.
  683. **add_arc** (debug_line, center, radius, plane_normal, midpoint_normal, color, [circle_segments = 36]);
  684. Adds an arc at *center* with the given *radius* and *plane_normal* and *midpoint_normal* vectors.
  685. **add_circle** (debug_line, center, radius, normal, color, [segments = 36])
  686. Adds a circle at *center* with the given *radius* and *normal* vector.
  687. **add_cone** (debug_line, from, to, radius, color, [segments = 36])
  688. Adds a cone with the base centered at *from* and the tip at *to*.
  689. **add_sphere** (debug_line, center, radius, color, [segments = 36])
  690. Adds a sphere at *center* with the given *radius*.
  691. **add_obb** (debug_line, tm, half_extents, color)
  692. Adds an orientd bounding box. *tm* describes the position and orientation of
  693. the box. *half_extents* describes the size of the box along the axis.
  694. **add_frustum** (debug_line, mvp, color)
  695. Adds a frustum defined by *mvp*.
  696. **add_unit** (debug_line, tm, name, color)
  697. Adds the meshes from the unit *name*.
  698. **reset** (debug_line)
  699. Resets all the lines.
  700. **submit** (debug_line)
  701. Submits the lines to renderer for drawing.
  702. Input
  703. =====
  704. Keyboard
  705. --------
  706. **name** () : string
  707. Returns the name of keyboard.
  708. **connected** () : bool
  709. Returns whether the keyboard is connected and functioning.
  710. **num_buttons** () : int
  711. Returns the number of buttons of the keyboard.
  712. **num_axes** () : int
  713. Returns the number of axes of the keyboard.
  714. **pressed** (id) : bool
  715. Returns whether the button *id* is pressed in the current frame.
  716. **released** (id) : bool
  717. Returns whether the button *id* is released in the current frame.
  718. **any_pressed** () : bool
  719. Returns whether any button is pressed in the current frame.
  720. **any_released** () : bool
  721. Returns whether any button is released in the current frame.
  722. **button_name** (id) : string
  723. Returns the name of the button *id*.
  724. **button_id** (name) : int
  725. Returns the *id* of the button *name* or ``nil`` if no matching button is found.
  726. Keyboard Button Names
  727. ~~~~~~~~~~~~~~~~~~~~~
  728. * ``tab``, ``enter``, ``escape``, ``space``, ``backspace``
  729. * ``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``
  730. * ``f1``, ``f2``, ``f3``, ``f4``, ``f5``, ``f6``, ``f7``, ``f8``, ``f9``, ``f10``, ``f11``, ``f12``
  731. * ``home``, ``left``, ``up``, ``right``, ``down``, ``page_up``, ``page_down``, ``ins``, ``del``, ``end``
  732. * ``ctrl_left``, ``ctrl_right``, ``shift_left``, ``shift_right``, ``caps_lock``, ``alt_left``, ``alt_right``, ``super_left``, ``super_right``
  733. * ``0``, ``1``, ``2``, ``3``, ``4``, ``5``, ``6``, ``7``, ``8``, ``9``
  734. * ``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``
  735. Keyboard Axis Names
  736. ~~~~~~~~~~~~~~~~~~~
  737. None.
  738. Mouse
  739. -----
  740. **name** () : string
  741. Returns the name of the mouse.
  742. **connected** () : bool
  743. Returns whether the mouse is connected and functioning.
  744. **num_buttons** () : int
  745. Returns the number of buttons of the mouse.
  746. **num_axes** () : int
  747. Returns the number of axes of the mouse.
  748. **pressed** (id) : bool
  749. Returns whether the button *id* is pressed in the current frame.
  750. **released** (id) : bool
  751. Returns whether the button *id* is released in the current frame.
  752. **any_pressed** () : bool
  753. Returns whether any button is pressed in the current frame.
  754. **any_released** () : bool
  755. Returns whether any button is released in the current frame.
  756. **axis** (id) : Vector3
  757. Returns the value of the axis *id*.
  758. **button_name** (id) : string
  759. Returns the name of the button *id*.
  760. **axis_name** (id) : string
  761. Returns the name of the axis *id*.
  762. **button_id** (name) : int
  763. Returns the *id* of the button *name* or ``nil`` if no matching button is found.
  764. **axis_id** (name) : int
  765. Returns the *id* of the axis *name* or ``nil`` if no matching axis is found.
  766. Mouse Button Names
  767. ~~~~~~~~~~~~~~~~~~
  768. ``left``, ``middle``, ``right``, ``extra_1``, ``extra_2``
  769. Mouse Axis Names
  770. ~~~~~~~~~~~~~~~~
  771. * ``cursor``: Returns the cursor position (x, y) in screen coordinates.
  772. * ``cursor_delta``: Returns the delta of the cursor position (x, y) since last frame.
  773. * ``wheel``: Returns the movement of the mouse wheel in the y axis. Positive values of y mean upward scrolling, negative values mean downward scrolling.
  774. Touch
  775. -----
  776. **name** () : string
  777. Returns the name of the touch.
  778. **connected** () : bool
  779. Returns whether the touch is connected and functioning.
  780. **num_buttons** () : int
  781. Returns the number of buttons of the touch.
  782. **num_axes** () : int
  783. Returns the number of axes of the touch.
  784. **pressed** (id) : bool
  785. Returns whether the button *id* is pressed in the current frame.
  786. **released** (id) : bool
  787. Returns whether the button *id* is released in the current frame.
  788. **any_pressed** () : bool
  789. Returns whether any button is pressed in the current frame.
  790. **any_released** () : bool
  791. Returns whether any button is released in the current frame.
  792. **axis** (id) : Vector3
  793. Returns the value of the axis *id*.
  794. **button_name** (id) : string
  795. Returns the name of the button *id*.
  796. **axis_name** (id) : string
  797. Returns the name of the axis *id*.
  798. **button_id** (name) : int
  799. Returns the *id* of the button *name* or ``nil`` if no matching button is found.
  800. **axis_id** (name) : int
  801. Returns the *id* of the axis *name* or ``nil`` if no matching axis is found.
  802. Pad1, Pad2, Pad3, Pad4
  803. ----------------------
  804. **name** () : string
  805. Returns the name of the pad.
  806. **connected** () : bool
  807. Returns whether the pad is connected and functioning.
  808. **num_buttons** () : int
  809. Returns the number of buttons of the pad.
  810. **num_axes** () : int
  811. Returns the number of axes of the pad.
  812. **pressed** (id) : bool
  813. Returns whether the button *id* is pressed in the current frame.
  814. **released** (id) : bool
  815. Returns whether the button *id* is released in the current frame.
  816. **any_pressed** () : bool
  817. Returns whether any button is pressed in the current frame.
  818. **any_released** () : bool
  819. Returns whether any button is released in the current frame.
  820. **axis** (id) : Vector3
  821. Returns the value of the axis *id*.
  822. **button_name** (id) : string
  823. Returns the name of the button *id*.
  824. **axis_name** (id) : string
  825. Returns the name of the axis *id*.
  826. **button_id** (name) : int
  827. Returns the *id* of the button *name* or ``nil`` if no matching button is found.
  828. **axis_id** (name) : int
  829. Returns the *id* of the axis *name* or ``nil`` if no matching axis is found.
  830. Pad Button Names
  831. ~~~~~~~~~~~~~~~~
  832. * ``up``, ``down``, ``left``, ``right``
  833. * ``start``, ``back``, ``guide``
  834. * ``thumb_left``, ``thumb_right``
  835. * ``shoulder_left``, ``shoulder_right``
  836. * ``a``, ``b``, ``x``, ``y``
  837. Pad Axis Names
  838. ~~~~~~~~~~~~~~
  839. * ``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].
  840. Profiler
  841. ========
  842. **enter_scope** (name)
  843. Starts a new profile scope with the given *name*.
  844. **leave_scope** ()
  845. Ends the last profile scope.
  846. **record** (name, value)
  847. Records *value* with the given *name*. Value can be either number or Vector3.
  848. Display
  849. =======
  850. **modes** () : table
  851. Returns an array of `DisplayMode`_ tables.
  852. **set_mode** (id)
  853. Sets the display mode *id*.
  854. The initial display mode is automatically reset when the program terminates.
  855. DisplayMode
  856. -----------
  857. DisplayMode is a lua table with 3 fields:
  858. * ``id``: The id of the display mode.
  859. * ``width``: The width of the display mode.
  860. * ``height``: The height of the display mode.
  861. Window
  862. ======
  863. **show** ()
  864. Shows the window.
  865. **hide** ()
  866. Hides the window.
  867. **resize** (width, height)
  868. Resizes the window to *width* and *height*.
  869. **move** (x, y)
  870. Moves the window to *x* and *y*.
  871. **minimize** ()
  872. Minimizes the window.
  873. **restore** ()
  874. Restores the window.
  875. **title** () : string
  876. Returns the title of the window.
  877. **set_title** (title)
  878. Sets the title of the window.
  879. **show_cursor** (show)
  880. Sets whether to *show* the cursor.