lua_api.rst 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217
  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_create** (world, unit, projection, fov, far_range, near_range, pose) : Id
  309. Creates a new camera for *unit* and returns its id.
  310. Projection can be either `orthographic` or `perspective`.
  311. **camera_instances** (world, unit) : Id
  312. Returns the IDs for all the cameras of the *unit*.
  313. **camera_set_projection_type** (world, camera, projection)
  314. Sets the projection type of the camera.
  315. Projection can be either `orthographic` or `perspective`.
  316. **camera_projection_type** (world, camera) : string
  317. Returns the projection type of the camera.
  318. It can be either `orthographic` or `perspective`.
  319. **camera_fov** (world, camera) : float
  320. Returns the field-of-view of the camera in degrees.
  321. **camera_set_fov** (world, camera, fov)
  322. Sets the field-of-view of the camera in degrees.
  323. **camera_near_clip_distance** (world, camera) : float
  324. Returns the near clip distance of the camera.
  325. **camera_set_near_clip_distance** (world, camera, near)
  326. Sets the near clip distance of the camera.
  327. **camera_far_clip_distance** (world, camera) : float
  328. Returns the far clip distance of the camera.
  329. **camera_set_far_clip_distance** (world, camera, far)
  330. Sets the far clip distance of the camera.
  331. **camera_set_orthographic_metrics** (world, camera, left, right, bottom, top)
  332. Sets the coordinates for orthographic clipping planes. (Orthographic projection only.)
  333. **camera_screen_to_world** (world, camera, pos) : Vector3
  334. Returns *pos* from screen-space to world-space coordinates.
  335. **camera_world_to_screen** (world, camera, pos) : Vector3
  336. Returns *pos* from world-space to screen-space coordinates.
  337. Sound
  338. -----
  339. **play_sound** (world, name, [loop, volume, position, range]) : SoundInstanceId
  340. Plays the sound with the given *name* at the given *position*, with the given
  341. *volume* and *range*. *loop* controls whether the sound must loop or not.
  342. **stop_sound** (world, id)
  343. Stops the sound with the given *id*.
  344. **link_sound** (world, id, unit, node)
  345. Links the sound *id* to the *node* of the given *unit*.
  346. After this call, the sound *id* will follow the unit *unit*.
  347. **set_listener_pose** (world, pose)
  348. Sets the *pose* of the listener.
  349. **set_sound_position** (world, id, position)
  350. Sets the *position* of the sound *id*.
  351. **set_sound_range** (world, id, range)
  352. Sets the *range* of the sound *id*.
  353. **set_sound_volume** (world, id, volume)
  354. Sets the *volume* of the sound *id*.
  355. Level
  356. -----
  357. **load_level** (world, name, [pos, rot]) : Level
  358. Loads the level *name* into the world at the given *position* and *rotation*.
  359. SceneGraph
  360. ==========
  361. **create** (sg, unit, position, rotation, scale) : Id
  362. Creates the transform for the *unit* and returns its ID.
  363. **destroy** (sg, unit, id)
  364. Destroys the transform for the *unit*. The transform *id* is ignored.
  365. **instances** (sg, unit) : Id
  366. Returns the IDs for all the transforms of the *unit*.
  367. **local_position** (sg, unit) : Vector3
  368. Returns the local position of the *unit*.
  369. **local_rotation** (sg, unit) : Quaternion
  370. Returns the local rotation of the *unit*.
  371. **local_scale** (sg, unit) : Vector3
  372. Returns the local scale of the *unit*.
  373. **local_pose** (sg, unit) : Matrix4x4
  374. Returns the local pose of the *unit*.
  375. **world_position** (sg, unit) : Vector3
  376. Returns the world position of the *unit*.
  377. **world_rotation** (sg, unit) : Quaternion
  378. Returns the world rotation of the *unit*.
  379. **world_pose** (sg, unit) : Matrix4x4
  380. Returns the world pose of the *unit*.
  381. **set_local_position** (sg, unit, position)
  382. Sets the local *position* of the *unit*.
  383. **set_local_rotation** (sg, unit, rotation)
  384. Sets the local *rotation* of the *unit*.
  385. **set_local_scale** (sg, unit, scale)
  386. Sets the local *scale* of the *unit*.
  387. **set_local_pose** (sg, unit, pose)
  388. Sets the local *pose* of the *unit*.
  389. **link** (sg, child, parent)
  390. Links the unit *child* to the unit *parent*.
  391. **unlink** (sg, unit)
  392. Unlinks the *unit* from its parent if it has any.
  393. After unlinking, the @a unit's local pose is set to its previous world pose.
  394. Material
  395. ========
  396. **set_float** (material, name, value)
  397. Sets the *value* of the variable *name*.
  398. **set_vector2** (material, name, value)
  399. Sets the *value* of the variable *name*.
  400. **set_vector3** (material, name, value)
  401. Sets the *value* of the variable *name*.
  402. RenderWorld
  403. ===========
  404. **enable_debug_drawing** (rw, enable)
  405. Sets whether to *enable* debug drawing.
  406. Mesh
  407. ----
  408. **mesh_create** (rw, unit, mesh_resource, geometry_name, material_resource, visible, pose) : Id
  409. Creates a new mesh instance for *unit* and returns its id.
  410. **mesh_destroy** (rw, id)
  411. Destroys the mesh *id*.
  412. **mesh_instances** (rw, unit) : Id
  413. Returns the IDs for all the meshes of the *unit*.
  414. **mesh_raycast** (rw, id, from, dir) : float
  415. Returns the distance along ray (from, dir) to intersection point with the mesh *id* or -1.0 if no intersection.
  416. Sprite
  417. ------
  418. **sprite_create** (rw, unit, sprite_resource, material_resource, visible, pose) : Id
  419. Creates a new sprite instance for *unit* and returns its id.
  420. **sprite_destroy** (rw, id)
  421. Destroys the sprite *id*.
  422. **sprite_set_frame** (rw, id, index)
  423. Sets the frame *index* of the sprite *id*.
  424. **sprite_set_visible** (rw, id, visible)
  425. Sets whether the sprite *id* is *visible*.
  426. **sprite_flip_x** (rw, id, flip)
  427. Sets whether to flip the sprite on the x-axis.
  428. **sprite_flip_y** (rw, id, flip)
  429. Sets whether to flip the sprite on the y-axis.
  430. **sprite_instances** (rw, unit) : Id
  431. Returns the IDs for all the sprites of the *unit*.
  432. Light
  433. -----
  434. **light_create** (rw, unit, type, range, intensity, spot_angle, color, pose) : Id
  435. Creates a new light for *unit* and returns its id.
  436. Type can be either `directional`, `omni` or `spot`.
  437. **light_destroy** (rw, id)
  438. Destroys the light *id*.
  439. **light_instances** (rw, unit) : Id
  440. Returns the IDs for all the lights of the *unit*.
  441. **light_type** (rw, id) : string
  442. Returns the type of the light *id*.
  443. It can be either `directional`, `omni` or `spot`.
  444. **light_color** (rw, id) : Color4
  445. Returns the color of the light *id*.
  446. **light_range** (rw, id) : float
  447. Returns the range of the light *id*.
  448. **light_intensity** (rw, id) : float
  449. Returns the intensity of the light *id*.
  450. **light_spot_angle** (rw, id) : float
  451. Returns the spot angle of the light *id*.
  452. **light_set_type** (rw, id, type)
  453. Sets the *type* of the light *id*.
  454. **light_set_color** (rw, id, color)
  455. Sets the *color* of the light *id*.
  456. **light_set_range** (rw, id, range)
  457. Sets the *range* of the light *id*.
  458. **light_set_intensity** (rw, id, intensity)
  459. Sets the *intensity* of the light *id*.
  460. **light_set_spot_angle** (rw, id, angle)
  461. Sets the spot *angle* of the light *id*.
  462. PhysicsWorld
  463. =============
  464. **gravity** (pw) : Vector3
  465. Returns the gravity.
  466. **set_gravity** (pw, gravity)
  467. Sets the gravity.
  468. **raycast** (pw, from, dir, length, mode) : table
  469. Returns the actors which intersects the raycast.
  470. Mode can be either `closest` or `all`.
  471. **enable_debug_drawing** (pw, enable)
  472. Sets whether to *enable* debug drawing.
  473. Actor
  474. -----
  475. **actor_instances** (pw, unit) : Id
  476. Returns the IDs for all the actors of the *unit*.
  477. **actor_world_position** (pw, actor) : Vector3
  478. Returns the world position of the actor.
  479. **actor_world_rotation** (pw, actor) : Quaternion
  480. Returns the world rotation of the actor.
  481. **actor_world_pose** (pw, actor) : Matrix4x4
  482. Returns the world pose of the actor.
  483. **actor_teleport_world_position** (pw, actor, position)
  484. Teleports the actor to the given world position.
  485. **actor_teleport_world_rotation** (pw, actor, rotation)
  486. Teleports the actor to the given world rotation.
  487. **actor_teleport_world_pose** (pw, actor, pose)
  488. Teleports the actor to the given world pose.
  489. **actor_center_of_mass** (pw, actor) : Vector3
  490. Returns the center of mass of the actor.
  491. **actor_enable_gravity** (pw, actor)
  492. Enables gravity for the actor.
  493. **actor_disable_gravity** (pw, actor)
  494. Disables gravity for the actor.
  495. **actor_enable_collision** (pw, actor)
  496. Enables collision detection for the actor.
  497. **actor_disable_collision** (pw, actor)
  498. Disables collision detection for the actor.
  499. **actor_set_collision_filter** (pw, actor, name)
  500. Sets the collision filter of the actor.
  501. **actor_set_kinematic** (pw, actor, kinematic)
  502. Sets whether the actor is kinematic or not.
  503. Note that this call has no effect on static actors.
  504. **actor_move** (pw, actor, position)
  505. Moves the actor to *pos*
  506. Note that this call only affects nonkinematic actors.
  507. **actor_is_static** (pw, actor) : bool
  508. Returns whether the actor is static.
  509. **actor_is_dynamic** (pw, actor) bool
  510. Returns whether the actor is dynamic.
  511. **actor_is_kinematic** (pw, actor) : bool
  512. Returns whether the actor is kinematic (keyframed).
  513. **actor_is_nonkinematic** (pw, actor) : bool
  514. Returns whether the actor is nonkinematic (i.e. dynamic and not kinematic).
  515. **actor_linear_damping** (pw, actor) : float
  516. Returns the linear damping of the actor.
  517. **actor_set_linear_damping** (pw, actor, damping)
  518. Sets the linear damping of the actor.
  519. **actor_angular_damping** (pw, actor) : float
  520. Returns the angular damping of the actor.
  521. **actor_set_angular_damping** (pw, actor, rate)
  522. Sets the angular damping of the actor.
  523. **actor_linear_velocity** (pw, actor) : Vector3
  524. Returns the linear velocity of the actor.
  525. **actor_set_linear_velocity** (pw, actor, velocity)
  526. Sets the linear velocity of the actor.
  527. Note that this call only affects nonkinematic actors.
  528. **actor_angular_velocity** (pw, actor) : Vector3
  529. Returns the angular velocity of the actor.
  530. **actor_set_angular_velocity** (pw, actor, velocity)
  531. Sets the angular velocity of the actor.
  532. Note that this call only affects nonkinematic actors.
  533. **actor_add_impulse** (pw, actor, impulse)
  534. Adds a linear impulse (acting along the center of mass) to the actor.
  535. Note that this call only affects nonkinematic actors.
  536. **actor_add_impulse_at** (pw, actor, impulse, position)
  537. Adds a linear impulse (acting along the world position *pos*) to the actor.
  538. Note that this call only affects nonkinematic actors.
  539. **actor_add_torque_impulse** (pw, actor, impulse)
  540. Adds a torque impulse to the actor.
  541. **actor_push** (pw, actor, velocity, mass)
  542. Pushes the actor as if it was hit by a point object with the given *mass*
  543. travelling at the given *velocity*.
  544. Note that this call only affects nonkinematic actors.
  545. **actor_push_at** (pw, actor, velocity, mass, position)
  546. Like push() but applies the force at the world position *pos*.
  547. Note that this call only affects nonkinematic actors.
  548. **actor_is_sleeping** (pw, actor) : bool
  549. Returns whether the actor is sleeping.
  550. **actor_wake_up** (pw, actor)
  551. Wakes the actor up.
  552. SoundWorld
  553. ===========
  554. **stop_all** (sound_world)
  555. Stops all the sounds in the world.
  556. **pause_all** (sound_world)
  557. Pauses all the sounds in the world
  558. **resume_all** (sound_world)
  559. Resumes all previously paused sounds in the world.
  560. **is_playing** (sound_world, id) : bool
  561. Returns whether the sound *id* is playing.
  562. ResourcePackage
  563. ================
  564. **load** (package)
  565. Loads all the resources in the package.
  566. Note that the resources are not immediately available after the call is made,
  567. instead, you have to poll for completion with has_loaded().
  568. **unload** (package)
  569. Unloads all the resources in the package.
  570. **flush** (package)
  571. Waits until the package has been loaded.
  572. **has_loaded** (package) : bool
  573. Returns whether the package has been loaded.
  574. Device
  575. ======
  576. **argv** () : table
  577. Returns a table containing the command line parameters the engine was started with.
  578. **platform** () : string
  579. Returns a string identifying what platform the engine is running on.
  580. It can be either `android`, `linux` or `windows`
  581. **architecture** () : string
  582. Returns a string identifying what architecture the engine is running on.
  583. It can be either `32-bit` or `64-bit`.
  584. **version** () : string
  585. Returns a string identifying the engine version.
  586. The form is "major.minor.micro".
  587. **last_delta_time** () : float
  588. Returns the time in seconds needed to render the last frame
  589. **quit** ()
  590. Quits the application.
  591. **resolution** () : float, float
  592. Returns the main window resolution (width, height).
  593. **create_world** () : World
  594. Creates a new world.
  595. **destroy_world** (world)
  596. Destroys the given *world*.
  597. **render** (world, camera)
  598. Renders *world* using *camera*.
  599. **create_resource_package** (name) : ResourcePackage
  600. Returns the resource package with the given *package_name* name.
  601. **destroy_resource_package** (package)
  602. Destroy a previously created resource *package*.
  603. Note that to unload the resources loaded by the package, you have to call
  604. ResourcePackage.unload() first.
  605. **console_send** (table)
  606. Sends the given lua *table* to clients connected to the engine.
  607. Values can be either `nil`, bool, number, string, table, array, Vector2, Vector3, Quaternion, Matrix4x4 or Color4.
  608. **can_get** (type, name) : bool
  609. Returns whether the resource (type, name) is loaded.
  610. When resource autoload is enabled it always returns true.
  611. **enable_resource_autoload** (enable)
  612. Sets whether resources should be automatically loaded when accessed.
  613. **temp_count** () : int, int, int
  614. Returns the number of temporary objects used by Lua.
  615. **set_temp_count** (nv, nq, nm)
  616. Sets the number of temporary objects used by Lua.
  617. **guid** () : string
  618. Returns a new GUID.
  619. DebugGui
  620. ========
  621. **rect** (pos, size, material_resource, color)
  622. Draws a rectangle.
  623. **image** (pos, size, material_resource, color)
  624. Draws an image.
  625. **image_uv** (pos, size, uv0, uv1, material_resource, color)
  626. Draws an image with explicit UV coordinates.
  627. **text** (pos, font_size, str, font_resource, material_resource, color)
  628. Draws text.
  629. DebugLine
  630. =========
  631. **add_line** (debug_line, start, end, color)
  632. Adds a line from *start* to *end* with the given *color*.
  633. **add_axes** (debug_line, tm, length)
  634. Adds lines for each axis with the given *length*.
  635. **add_circle** (debug_line, center, radius, normal, color, [segments = 36])
  636. Adds a circle at *center* with the given *radius* and *normal* vector.
  637. **add_cone** (debug_line, from, to, radius, color, [segments = 36])
  638. Adds a cone with the base centered at *from* and the tip at *to*.
  639. **add_sphere** (debug_line, center, radius, color, [segments = 36])
  640. Adds a sphere at *center* with the given *radius*.
  641. **add_obb** (debug_line, tm, half_extents, color)
  642. Adds an orientd bounding box. *tm* describes the position and orientation of
  643. the box. *half_extents* describes the size of the box along the axis.
  644. **add_frustum** (debug_line, mvp, color)
  645. Adds a frustum defined by *mvp*.
  646. **add_unit** (debug_line, tm, name, color)
  647. Adds the meshes from the unit *name*.
  648. **reset** (debug_line)
  649. Resets all the lines.
  650. **submit** (debug_line)
  651. Submits the lines to renderer for drawing.
  652. Input
  653. =====
  654. Keyboard
  655. --------
  656. **name** () : string
  657. Returns the name of keyboard.
  658. **connected** () : bool
  659. Returns whether the keyboard is connected and functioning.
  660. **num_buttons** () : int
  661. Returns the number of buttons of the keyboard.
  662. **num_axes** () : int
  663. Returns the number of axes of the keyboard.
  664. **pressed** (id) : bool
  665. Returns whether the button *id* is pressed in the current frame.
  666. **released** (id) : bool
  667. Returns whether the button *id* is released in the current frame.
  668. **any_pressed** () : bool
  669. Returns whether any button is pressed in the current frame.
  670. **any_released** () : bool
  671. Returns whether any button is released in the current frame.
  672. **button_name** (id) : string
  673. Returns the name of the button *id*.
  674. **button_id** (name) : int
  675. Returns the *id* of the button *name* or `nil` if no matching button is found.
  676. Keyboard Button Names
  677. ~~~~~~~~~~~~~~~~~~~~~
  678. * `tab`, `enter`, `escape`, `space`, `backspace`
  679. * `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`
  680. * `f1`, `f2`, `f3`, `f4`, `f5`, `f6`, `f7`, `f8`, `f9`, `f10`, `f11`, `f12`
  681. * `home`, `left`, `up`, `right`, `down`, `page_up`, `page_down`, `ins`, `del`, `end`
  682. * `ctrl_left`, `ctrl_right`, `shift_left`, `shift_right`, `caps_lock`, `alt_left`, `alt_right`, `super_left`, `super_right`
  683. * `0`, `1`, `2`, `3`, `4`, `5`, `6`, `7`, `8`, `9`
  684. * `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`
  685. Keyboard Axis Names
  686. ~~~~~~~~~~~~~~~~~~~
  687. None.
  688. Mouse
  689. -----
  690. **name** () : string
  691. Returns the name of the mouse.
  692. **connected** () : bool
  693. Returns whether the mouse is connected and functioning.
  694. **num_buttons** () : int
  695. Returns the number of buttons of the mouse.
  696. **num_axes** () : int
  697. Returns the number of axes of the mouse.
  698. **pressed** (id) : bool
  699. Returns whether the button *id* is pressed in the current frame.
  700. **released** (id) : bool
  701. Returns whether the button *id* is released in the current frame.
  702. **any_pressed** () : bool
  703. Returns whether any button is pressed in the current frame.
  704. **any_released** () : bool
  705. Returns whether any button is released in the current frame.
  706. **axis** (id) : Vector3
  707. Returns the value of the axis *id*.
  708. **button_name** (id) : string
  709. Returns the name of the button *id*.
  710. **axis_name** (id) : string
  711. Returns the name of the axis *id*.
  712. **button_id** (name) : int
  713. Returns the *id* of the button *name* or `nil` if no matching button is found.
  714. **axis_id** (name) : int
  715. Returns the *id* of the axis *name* or `nil` if no matching axis is found.
  716. Mouse Button Names
  717. ~~~~~~~~~~~~~~~~~~
  718. `left`, `middle`, `right`, `extra_1`, `extra_2`
  719. Mouse Axis Names
  720. ~~~~~~~~~~~~~~~~
  721. * `cursor`: Returns the cursor position (x, y) in screen coordinates.
  722. * `cursor_delta`: Returns the delta of the cursor position (x, y) since last frame.
  723. * `wheel`: Returns the movement of the mouse wheel in the y axis. Positive values of y mean upward scrolling, negative values mean downward scrolling.
  724. Touch
  725. -----
  726. **name** () : string
  727. Returns the name of the touch.
  728. **connected** () : bool
  729. Returns whether the touch is connected and functioning.
  730. **num_buttons** () : int
  731. Returns the number of buttons of the touch.
  732. **num_axes** () : int
  733. Returns the number of axes of the touch.
  734. **pressed** (id) : bool
  735. Returns whether the button *id* is pressed in the current frame.
  736. **released** (id) : bool
  737. Returns whether the button *id* is released in the current frame.
  738. **any_pressed** () : bool
  739. Returns whether any button is pressed in the current frame.
  740. **any_released** () : bool
  741. Returns whether any button is released in the current frame.
  742. **axis** (id) : Vector3
  743. Returns the value of the axis *id*.
  744. **button_name** (id) : string
  745. Returns the name of the button *id*.
  746. **axis_name** (id) : string
  747. Returns the name of the axis *id*.
  748. **button_id** (name) : int
  749. Returns the *id* of the button *name* or `nil` if no matching button is found.
  750. **axis_id** (name) : int
  751. Returns the *id* of the axis *name* or `nil` if no matching axis is found.
  752. Pad1, Pad2, Pad3, Pad4
  753. ----------------------
  754. **name** () : string
  755. Returns the name of the pad.
  756. **connected** () : bool
  757. Returns whether the pad is connected and functioning.
  758. **num_buttons** () : int
  759. Returns the number of buttons of the pad.
  760. **num_axes** () : int
  761. Returns the number of axes of the pad.
  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. Pad Button Names
  781. ~~~~~~~~~~~~~~~~
  782. * `up`, `down`, `left`, `right`
  783. * `start`, `back`, `guide`
  784. * `thumb_left`, `thumb_right`
  785. * `shoulder_left`, `shoulder_right`
  786. * `a`, `b`, `x`, `y`
  787. Pad Axis Names
  788. ~~~~~~~~~~~~~~
  789. * `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].
  790. Profiler
  791. ========
  792. **enter_scope** (name)
  793. Starts a new profile scope with the given *name*.
  794. **leave_scope** ()
  795. Ends the last profile scope.
  796. **record** (name, value)
  797. Records *value* with the given *name*. Value can be either number or Vector3.
  798. Display
  799. =======
  800. **modes** () : table
  801. Returns an array of display modes. See `Display Mode`_.
  802. **set_mode** (id)
  803. Sets the display mode *id*.
  804. The initial display mode is automatically reset when the program terminates.
  805. Display Mode
  806. ------------
  807. Display mode is a lua table with 3 fields:
  808. * `id`: The id of the display mode.
  809. * `width`: The width of the display mode.
  810. * `height`: The height of the display mode.
  811. Window
  812. ======
  813. **show** ()
  814. Shows the window.
  815. **hide** ()
  816. Hides the window.
  817. **resize** (width, height)
  818. Resizes the window to *width* and *height*.
  819. **move** (x, y)
  820. Moves the window to *x* and *y*.
  821. **minimize** ()
  822. Minimizes the window.
  823. **restore** ()
  824. Restores the window.
  825. **title** () : string
  826. Returns the title of the window.
  827. **set_title** (title)
  828. Sets the title of the window.
  829. **show_cursor** (show)
  830. Sets whether to *show* the cursor.