lua_api.rst 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257
  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_obb** (rw, unit) : Matrix4x4, Vector3
  440. Returns the OBB of the sprite as (pose, half_extents).
  441. **sprite_raycast** (rw, unit, from, dir) : float
  442. Returns the distance along ray (from, dir) to intersection point with the sprite or -1.0 if no
  443. intersection.
  444. Light
  445. -----
  446. **light_create** (rw, unit, type, range, intensity, spot_angle, color, pose) : Id
  447. Creates a new light for the *unit* and returns its id.
  448. Type can be either ``directional``, ``omni`` or ``spot``.
  449. **light_destroy** (rw, unit)
  450. Destroys the light of the *unit*.
  451. **light_instances** (rw, unit) : Id
  452. Returns the IDs for all the lights of the *unit*.
  453. **light_type** (rw, unit) : string
  454. Returns the type of the light of the *unit*.
  455. It can be either ``directional``, ``omni`` or ``spot``.
  456. **light_color** (rw, unit) : Color4
  457. Returns the color of the light.
  458. **light_range** (rw, unit) : float
  459. Returns the range of the light.
  460. **light_intensity** (rw, unit) : float
  461. Returns the intensity of the light.
  462. **light_spot_angle** (rw, unit) : float
  463. Returns the spot angle of the light.
  464. **light_set_type** (rw, unit, type)
  465. Sets the *type* of the light.
  466. **light_set_color** (rw, unit, color)
  467. Sets the *color* of the light.
  468. **light_set_range** (rw, unit, range)
  469. Sets the *range* of the light.
  470. **light_set_intensity** (rw, unit, intensity)
  471. Sets the *intensity* of the light.
  472. **light_set_spot_angle** (rw, unit, angle)
  473. Sets the spot *angle* of the light.
  474. **light_debug_draw** (rw, unit, debug_line)
  475. Fills *debug_line* with debug lines from the light.
  476. PhysicsWorld
  477. =============
  478. **gravity** (pw) : Vector3
  479. Returns the gravity.
  480. **set_gravity** (pw, gravity)
  481. Sets the gravity.
  482. **raycast** (pw, from, dir, length, mode) : table
  483. Returns the actors which intersects the raycast.
  484. Mode can be either ``closest`` or ``all``.
  485. **enable_debug_drawing** (pw, enable)
  486. Sets whether to *enable* debug drawing.
  487. Actor
  488. -----
  489. **actor_instances** (pw, unit) : Id
  490. Returns the IDs for all the actors of the *unit*.
  491. **actor_world_position** (pw, actor) : Vector3
  492. Returns the world position of the actor.
  493. **actor_world_rotation** (pw, actor) : Quaternion
  494. Returns the world rotation of the actor.
  495. **actor_world_pose** (pw, actor) : Matrix4x4
  496. Returns the world pose of the actor.
  497. **actor_teleport_world_position** (pw, actor, position)
  498. Teleports the actor to the given world position.
  499. **actor_teleport_world_rotation** (pw, actor, rotation)
  500. Teleports the actor to the given world rotation.
  501. **actor_teleport_world_pose** (pw, actor, pose)
  502. Teleports the actor to the given world pose.
  503. **actor_center_of_mass** (pw, actor) : Vector3
  504. Returns the center of mass of the actor.
  505. **actor_enable_gravity** (pw, actor)
  506. Enables gravity for the actor.
  507. **actor_disable_gravity** (pw, actor)
  508. Disables gravity for the actor.
  509. **actor_enable_collision** (pw, actor)
  510. Enables collision detection for the actor.
  511. **actor_disable_collision** (pw, actor)
  512. Disables collision detection for the actor.
  513. **actor_set_collision_filter** (pw, actor, name)
  514. Sets the collision filter of the actor.
  515. **actor_set_kinematic** (pw, actor, kinematic)
  516. Sets whether the actor is kinematic or not.
  517. Note that this call has no effect on static actors.
  518. **actor_move** (pw, actor, position)
  519. Moves the actor to *pos*
  520. Note that this call only affects nonkinematic actors.
  521. **actor_is_static** (pw, actor) : bool
  522. Returns whether the actor is static.
  523. **actor_is_dynamic** (pw, actor) bool
  524. Returns whether the actor is dynamic.
  525. **actor_is_kinematic** (pw, actor) : bool
  526. Returns whether the actor is kinematic (keyframed).
  527. **actor_is_nonkinematic** (pw, actor) : bool
  528. Returns whether the actor is nonkinematic (i.e. dynamic and not kinematic).
  529. **actor_linear_damping** (pw, actor) : float
  530. Returns the linear damping of the actor.
  531. **actor_set_linear_damping** (pw, actor, damping)
  532. Sets the linear damping of the actor.
  533. **actor_angular_damping** (pw, actor) : float
  534. Returns the angular damping of the actor.
  535. **actor_set_angular_damping** (pw, actor, rate)
  536. Sets the angular damping of the actor.
  537. **actor_linear_velocity** (pw, actor) : Vector3
  538. Returns the linear velocity of the actor.
  539. **actor_set_linear_velocity** (pw, actor, velocity)
  540. Sets the linear velocity of the actor.
  541. Note that this call only affects nonkinematic actors.
  542. **actor_angular_velocity** (pw, actor) : Vector3
  543. Returns the angular velocity of the actor.
  544. **actor_set_angular_velocity** (pw, actor, velocity)
  545. Sets the angular velocity of the actor.
  546. Note that this call only affects nonkinematic actors.
  547. **actor_add_impulse** (pw, actor, impulse)
  548. Adds a linear impulse (acting along the center of mass) to the actor.
  549. Note that this call only affects nonkinematic actors.
  550. **actor_add_impulse_at** (pw, actor, impulse, position)
  551. Adds a linear impulse (acting along the world position *pos*) to the actor.
  552. Note that this call only affects nonkinematic actors.
  553. **actor_add_torque_impulse** (pw, actor, impulse)
  554. Adds a torque impulse to the actor.
  555. **actor_push** (pw, actor, velocity, mass)
  556. Pushes the actor as if it was hit by a point object with the given *mass*
  557. travelling at the given *velocity*.
  558. Note that this call only affects nonkinematic actors.
  559. **actor_push_at** (pw, actor, velocity, mass, position)
  560. Like push() but applies the force at the world position *pos*.
  561. Note that this call only affects nonkinematic actors.
  562. **actor_is_sleeping** (pw, actor) : bool
  563. Returns whether the actor is sleeping.
  564. **actor_wake_up** (pw, actor)
  565. Wakes the actor up.
  566. SoundWorld
  567. ===========
  568. **stop_all** (sound_world)
  569. Stops all the sounds in the world.
  570. **pause_all** (sound_world)
  571. Pauses all the sounds in the world
  572. **resume_all** (sound_world)
  573. Resumes all previously paused sounds in the world.
  574. **is_playing** (sound_world, id) : bool
  575. Returns whether the sound *id* is playing.
  576. AnimationStateMachine
  577. =====================
  578. **variable_id** (state_machine, unit, name) : Id
  579. Returns the ID of the variable *name* in the *state_machine*.
  580. **variable** (state_machine, unit, variable_id) : number
  581. Returns the value of the *variable_id* in the *state_machine*.
  582. **set_variable** (state_machine, unit, variable_id, value)
  583. Sets the *value* of the *variable_id* in the *state_machine*.
  584. **trigger** (state_machine, unit, name)
  585. Triggers the event *name* in the *state_machine*.
  586. ResourcePackage
  587. ================
  588. **load** (package)
  589. Loads all the resources in the package.
  590. Note that the resources are not immediately available after the call is made,
  591. instead, you have to poll for completion with has_loaded().
  592. **unload** (package)
  593. Unloads all the resources in the package.
  594. **flush** (package)
  595. Waits until the package has been loaded.
  596. **has_loaded** (package) : bool
  597. Returns whether the package has been loaded.
  598. Device
  599. ======
  600. **argv** () : table
  601. Returns a table containing the command line parameters the engine was started with.
  602. **platform** () : string
  603. Returns a string identifying what platform the engine is running on.
  604. It can be either ``android``, ``linux`` or ``windows``
  605. **architecture** () : string
  606. Returns a string identifying what architecture the engine is running on.
  607. It can be either ``32-bit`` or ``64-bit``.
  608. **version** () : string
  609. Returns a string identifying the engine version.
  610. The form is "major.minor.micro".
  611. **quit** ()
  612. Quits the application.
  613. **resolution** () : float, float
  614. Returns the main window resolution (width, height).
  615. **create_world** () : World
  616. Creates a new world.
  617. **destroy_world** (world)
  618. Destroys the given *world*.
  619. **render** (world, camera)
  620. Renders *world* using *camera*.
  621. **create_resource_package** (name) : ResourcePackage
  622. Returns the resource package with the given *package_name* name.
  623. **destroy_resource_package** (package)
  624. Destroy a previously created resource *package*.
  625. Note that to unload the resources loaded by the package, you have to call
  626. ResourcePackage.unload() first.
  627. **console_send** (table)
  628. Sends the given lua *table* to clients connected to the engine.
  629. Values can be either ``nil``, bool, number, string, table, array, Vector2, Vector3, Quaternion, Matrix4x4 or Color4.
  630. **can_get** (type, name) : bool
  631. Returns whether the resource (type, name) is loaded.
  632. When resource autoload is enabled it always returns true.
  633. **enable_resource_autoload** (enable)
  634. Sets whether resources should be automatically loaded when accessed.
  635. **temp_count** () : int, int, int
  636. Returns the number of temporary objects used by Lua.
  637. **set_temp_count** (nv, nq, nm)
  638. Sets the number of temporary objects used by Lua.
  639. **guid** () : string
  640. Returns a new GUID.
  641. Gui
  642. ===
  643. **move** (pos)
  644. Moves the Gui to *pos*.
  645. **triangle** (a, b, c, color)
  646. Draws a triangle defined by vertices *a*, *b* and *c*.
  647. **rect** (pos, size, color)
  648. Draws a rectangle.
  649. **image** (pos, size, material_resource, color)
  650. Draws an image.
  651. **image_uv** (pos, size, uv0, uv1, material_resource, color)
  652. Draws an image with explicit UV coordinates.
  653. **text** (pos, font_size, str, font_resource, material_resource, color)
  654. Draws text.
  655. DebugLine
  656. =========
  657. **add_line** (debug_line, start, end, color)
  658. Adds a line from *start* to *end* with the given *color*.
  659. **add_axes** (debug_line, tm, length)
  660. Adds lines for each axis with the given *length*.
  661. **add_arc** (debug_line, center, radius, plane_normal, midpoint_normal, color, [circle_segments = 36]);
  662. Adds an arc at *center* with the given *radius* and *plane_normal* and *midpoint_normal* vectors.
  663. **add_circle** (debug_line, center, radius, normal, color, [segments = 36])
  664. Adds a circle at *center* with the given *radius* and *normal* vector.
  665. **add_cone** (debug_line, from, to, radius, color, [segments = 36])
  666. Adds a cone with the base centered at *from* and the tip at *to*.
  667. **add_sphere** (debug_line, center, radius, color, [segments = 36])
  668. Adds a sphere at *center* with the given *radius*.
  669. **add_obb** (debug_line, tm, half_extents, color)
  670. Adds an orientd bounding box. *tm* describes the position and orientation of
  671. the box. *half_extents* describes the size of the box along the axis.
  672. **add_frustum** (debug_line, mvp, color)
  673. Adds a frustum defined by *mvp*.
  674. **add_unit** (debug_line, tm, name, color)
  675. Adds the meshes from the unit *name*.
  676. **reset** (debug_line)
  677. Resets all the lines.
  678. **submit** (debug_line)
  679. Submits the lines to renderer for drawing.
  680. Input
  681. =====
  682. Keyboard
  683. --------
  684. **name** () : string
  685. Returns the name of keyboard.
  686. **connected** () : bool
  687. Returns whether the keyboard is connected and functioning.
  688. **num_buttons** () : int
  689. Returns the number of buttons of the keyboard.
  690. **num_axes** () : int
  691. Returns the number of axes of the keyboard.
  692. **pressed** (id) : bool
  693. Returns whether the button *id* is pressed in the current frame.
  694. **released** (id) : bool
  695. Returns whether the button *id* is released in the current frame.
  696. **any_pressed** () : bool
  697. Returns whether any button is pressed in the current frame.
  698. **any_released** () : bool
  699. Returns whether any button is released in the current frame.
  700. **button_name** (id) : string
  701. Returns the name of the button *id*.
  702. **button_id** (name) : int
  703. Returns the *id* of the button *name* or ``nil`` if no matching button is found.
  704. Keyboard Button Names
  705. ~~~~~~~~~~~~~~~~~~~~~
  706. * ``tab``, ``enter``, ``escape``, ``space``, ``backspace``
  707. * ``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``
  708. * ``f1``, ``f2``, ``f3``, ``f4``, ``f5``, ``f6``, ``f7``, ``f8``, ``f9``, ``f10``, ``f11``, ``f12``
  709. * ``home``, ``left``, ``up``, ``right``, ``down``, ``page_up``, ``page_down``, ``ins``, ``del``, ``end``
  710. * ``ctrl_left``, ``ctrl_right``, ``shift_left``, ``shift_right``, ``caps_lock``, ``alt_left``, ``alt_right``, ``super_left``, ``super_right``
  711. * ``0``, ``1``, ``2``, ``3``, ``4``, ``5``, ``6``, ``7``, ``8``, ``9``
  712. * ``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``
  713. Keyboard Axis Names
  714. ~~~~~~~~~~~~~~~~~~~
  715. None.
  716. Mouse
  717. -----
  718. **name** () : string
  719. Returns the name of the mouse.
  720. **connected** () : bool
  721. Returns whether the mouse is connected and functioning.
  722. **num_buttons** () : int
  723. Returns the number of buttons of the mouse.
  724. **num_axes** () : int
  725. Returns the number of axes of the mouse.
  726. **pressed** (id) : bool
  727. Returns whether the button *id* is pressed in the current frame.
  728. **released** (id) : bool
  729. Returns whether the button *id* is released in the current frame.
  730. **any_pressed** () : bool
  731. Returns whether any button is pressed in the current frame.
  732. **any_released** () : bool
  733. Returns whether any button is released in the current frame.
  734. **axis** (id) : Vector3
  735. Returns the value of the axis *id*.
  736. **button_name** (id) : string
  737. Returns the name of the button *id*.
  738. **axis_name** (id) : string
  739. Returns the name of the axis *id*.
  740. **button_id** (name) : int
  741. Returns the *id* of the button *name* or ``nil`` if no matching button is found.
  742. **axis_id** (name) : int
  743. Returns the *id* of the axis *name* or ``nil`` if no matching axis is found.
  744. Mouse Button Names
  745. ~~~~~~~~~~~~~~~~~~
  746. ``left``, ``middle``, ``right``, ``extra_1``, ``extra_2``
  747. Mouse Axis Names
  748. ~~~~~~~~~~~~~~~~
  749. * ``cursor``: Returns the cursor position (x, y) in screen coordinates.
  750. * ``cursor_delta``: Returns the delta of the cursor position (x, y) since last frame.
  751. * ``wheel``: Returns the movement of the mouse wheel in the y axis. Positive values of y mean upward scrolling, negative values mean downward scrolling.
  752. Touch
  753. -----
  754. **name** () : string
  755. Returns the name of the touch.
  756. **connected** () : bool
  757. Returns whether the touch is connected and functioning.
  758. **num_buttons** () : int
  759. Returns the number of buttons of the touch.
  760. **num_axes** () : int
  761. Returns the number of axes of the touch.
  762. **pressed** (id) : bool
  763. Returns whether the button *id* is pressed in the current frame.
  764. **released** (id) : bool
  765. Returns whether the button *id* is released in the current frame.
  766. **any_pressed** () : bool
  767. Returns whether any button is pressed in the current frame.
  768. **any_released** () : bool
  769. Returns whether any button is released in the current frame.
  770. **axis** (id) : Vector3
  771. Returns the value of the axis *id*.
  772. **button_name** (id) : string
  773. Returns the name of the button *id*.
  774. **axis_name** (id) : string
  775. Returns the name of the axis *id*.
  776. **button_id** (name) : int
  777. Returns the *id* of the button *name* or ``nil`` if no matching button is found.
  778. **axis_id** (name) : int
  779. Returns the *id* of the axis *name* or ``nil`` if no matching axis is found.
  780. Pad1, Pad2, Pad3, Pad4
  781. ----------------------
  782. **name** () : string
  783. Returns the name of the pad.
  784. **connected** () : bool
  785. Returns whether the pad is connected and functioning.
  786. **num_buttons** () : int
  787. Returns the number of buttons of the pad.
  788. **num_axes** () : int
  789. Returns the number of axes of the pad.
  790. **pressed** (id) : bool
  791. Returns whether the button *id* is pressed in the current frame.
  792. **released** (id) : bool
  793. Returns whether the button *id* is released in the current frame.
  794. **any_pressed** () : bool
  795. Returns whether any button is pressed in the current frame.
  796. **any_released** () : bool
  797. Returns whether any button is released in the current frame.
  798. **axis** (id) : Vector3
  799. Returns the value of the axis *id*.
  800. **button_name** (id) : string
  801. Returns the name of the button *id*.
  802. **axis_name** (id) : string
  803. Returns the name of the axis *id*.
  804. **button_id** (name) : int
  805. Returns the *id* of the button *name* or ``nil`` if no matching button is found.
  806. **axis_id** (name) : int
  807. Returns the *id* of the axis *name* or ``nil`` if no matching axis is found.
  808. Pad Button Names
  809. ~~~~~~~~~~~~~~~~
  810. * ``up``, ``down``, ``left``, ``right``
  811. * ``start``, ``back``, ``guide``
  812. * ``thumb_left``, ``thumb_right``
  813. * ``shoulder_left``, ``shoulder_right``
  814. * ``a``, ``b``, ``x``, ``y``
  815. Pad Axis Names
  816. ~~~~~~~~~~~~~~
  817. * ``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].
  818. Profiler
  819. ========
  820. **enter_scope** (name)
  821. Starts a new profile scope with the given *name*.
  822. **leave_scope** ()
  823. Ends the last profile scope.
  824. **record** (name, value)
  825. Records *value* with the given *name*. Value can be either number or Vector3.
  826. Display
  827. =======
  828. **modes** () : table
  829. Returns an array of display modes. See `Display Mode`_.
  830. **set_mode** (id)
  831. Sets the display mode *id*.
  832. The initial display mode is automatically reset when the program terminates.
  833. Display Mode
  834. ------------
  835. Display mode is a lua table with 3 fields:
  836. * ``id``: The id of the display mode.
  837. * ``width``: The width of the display mode.
  838. * ``height``: The height of the display mode.
  839. Window
  840. ======
  841. **show** ()
  842. Shows the window.
  843. **hide** ()
  844. Hides the window.
  845. **resize** (width, height)
  846. Resizes the window to *width* and *height*.
  847. **move** (x, y)
  848. Moves the window to *x* and *y*.
  849. **minimize** ()
  850. Minimizes the window.
  851. **restore** ()
  852. Restores the window.
  853. **title** () : string
  854. Returns the title of the window.
  855. **set_title** (title)
  856. Sets the title of the window.
  857. **show_cursor** (show)
  858. Sets whether to *show* the cursor.