lua_api.txt 32 KB

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