lua_api.txt 28 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061
  1. .. contents::
  2. Math
  3. ====
  4. Vector3
  5. -------
  6. **Vector3** (x, y, z) : Vector3
  7. Returns a new vector from individual elements.
  8. **x** (v) : float
  9. Returns the x value of the vector.
  10. **y** (v) : float
  11. Returns the y value of the vector.
  12. **z** (v) : float
  13. Returns the z value of the vector.
  14. **.x** : float
  15. Returns/assigns the x value of the vector.
  16. **.y** : float
  17. Returns/assigns the y value of the vector.
  18. **.z** : float
  19. Returns/assigns the z value of the vector.
  20. **set_x** (v, x)
  21. Sets the value of the x value of the vector.
  22. **set_y** (v, y)
  23. Sets the value of the y value of the vector.
  24. **set_z** (v, z)
  25. Sets the value of the z value of the vector.
  26. **elements** (v) : float, float, float
  27. Returns the x, y and z elements of the vector.
  28. **add** (a, b) : Vector3
  29. Adds the vector *a* to *b* and returns the result.
  30. **subtract** (a, b) : Vector3
  31. Subtracts the vector *b* from *a* and returns the result.
  32. **multiply** (a, k) : Vector3
  33. Multiplies the vector *a* by the scalar *k* and returns the result.
  34. **dot** (a, b) : float
  35. Returns the dot product between the vectors *a* and *b*.
  36. **cross** (a, b) : Vector3
  37. Returns the cross product between the vectors *a* and *b*.
  38. **equal** (a, b) : bool
  39. Returns true whether the vectors *a* and *b* are equal.
  40. **length** (a) : float
  41. Returns the lenght of *a*.
  42. **length_squared** (a) : float
  43. Returns the squared length of *a*.
  44. **set_length** (a, len)
  45. Sets the lenght of *a* to *len*.
  46. **normalize** (a) : Vector3
  47. Normalizes *a* and returns the result.
  48. **distance** (a, b) : float
  49. Returns the distance between the points *a* and *b*.
  50. **distance_squared** (a, b) : float
  51. Returns the squared distance between the points *a* and *b*.
  52. **angle** (a, b) : float
  53. Returns the angle between the vectors *a* and *b*.
  54. **max** (a, b) : Vector3
  55. Returns a vector that contains the largest value for each element from *a* and *b*.
  56. **min** (a, b) : Vector3
  57. Returns a vector that contains the smallest value for each element from *a* and *b*.
  58. **lerp** (a, b, t) : Vector3
  59. Returns the linearly interpolated vector between *a* and *b* at time *t* in [0, 1].
  60. **forward** () : Vector3
  61. **backward** () : Vector3
  62. **left** () : Vector3
  63. **right** () : Vector3
  64. **up** () : Vector3
  65. **down** () : Vector3
  66. Returns the corresponding semantic axis.
  67. **zero** () : Vector3
  68. Returns a vector with all values set to zero.
  69. **to_string** (v) : string
  70. Returns a string representing the vector *v*.
  71. Vector3Box
  72. ----------
  73. **Vector3Box** () : Vector3Box
  74. Returns a new Vector3Box initialized with the zero vector.
  75. **Vector3Box** (v) : Vector3Box
  76. Returns a new Vector3Box from the Vector3 *v*.
  77. **Vector3Box** (x, y, z) : Vector3Box
  78. Returns a new Vector3Box from individual elements.
  79. **store** (v)
  80. Stores the Vector3 *v* in the box.
  81. **store** (x, y, z)
  82. Stores Vector3(x, y, z) in the box.
  83. **unbox** () : Vector3
  84. Returns the stored vector from the box.
  85. Quaternion
  86. ----------
  87. **Quaternion** (axis, angle) : Quaternion
  88. Returns a new quaternion from *axis* and *angle*.
  89. **negate** (q) : Quaternion
  90. Negates the quaternion *q* and returns the result.
  91. **identity** () : Quaternion
  92. Returns the identity quaternion.
  93. **multiply** (a, b) : Quaternion
  94. Multiplies the quaternions *a* and *b*. (i.e. rotates first by *a* then by *b*).
  95. **multiply_by_scalar** (a, k) : Quaternion
  96. Multiplies the quaternion *a* by the scalar *k*.
  97. **dot** (a, b) : float
  98. Returns the dot product between quaternions *a* and *b*.
  99. **length** (q) : float
  100. Returns the length of *q*.
  101. **normalize** (q) : Quaternion
  102. Normalizes the quaternion *q* and returns the result.
  103. **conjugate** (q) : Quaternion
  104. Returns the conjugate of quaternion *q*.
  105. **inverse** (q) : Quaternion
  106. Returns the inverse of quaternion *q*.
  107. **power** (q, exp) : Quaternion
  108. Returns the quaternion *q* raised to the power of *exp*.
  109. **elements** (q) : float, float, float, float
  110. Returns the x, y, z and w elements of the quaternion.
  111. **look** (dir, [up]) : Quaternion
  112. Returns the quaternion describing the rotation needed to face towards *dir*.
  113. If *up* is not specified, Vector3.up() is used.
  114. **right** (q) : Vector3
  115. Returns the right axis of the rotation described by *q*.
  116. **up** (q) : Vector3
  117. Returns the up axis of the rotation described by *q*.
  118. **forward** (q) : Vector3
  119. Returns the forward axis of the rotation described by *q*.
  120. **lerp** (a, b, t) : Quaternion
  121. Returns the linearly interpolated quaternion between *a* and *b* at time *t* in [0, 1].
  122. It uses NLerp.
  123. **to_string** (q) : string
  124. Returns a string representing the quaternion *q*.
  125. QuaternionBox
  126. -------------
  127. **QuaternionBox** () : QuaternionBox
  128. Returns a new QuaternionBox initialized with the identity quaternion.
  129. **QuaternionBox** (q) : QuaternionBox
  130. Returns a new QuaternionBox from the Quaternion *q*.
  131. **QuaternionBox** (x, y, z, w) : QuaternionBox
  132. Returns a new QuaternionBox from individual elements.
  133. **store** (q)
  134. Stores the Quaternion *q* in the box.
  135. **store** (x, y, z, w)
  136. Stores Quaternion(x, y, z, w) in the box.
  137. **unbox** () : Quaternion
  138. Returns the stored quaternion from the box.
  139. Matrix4x4
  140. ---------
  141. **Matrix4x4** (xx, xy, xz, xw, yx, yy, yz, yw, zx, zy, zz, zw, tx, ty, tz, tw) : Matrix4x4
  142. Returns a new matrix from individual elements.
  143. **from_quaternion** (q) : Matrix4x4
  144. Returns a new matrix from *q*.
  145. **from_translation** (t) : Matrix4x4
  146. Returns a new matrix from *t*.
  147. **from_quaternion_translation** (q, t) : Matrix4x4
  148. Returns a new matrix from *q* and *t*.
  149. **from_axes** (x, y, z, t) : Matrix4x4
  150. Returns a new matrix from *x*, *y*, *z* and *t*.
  151. **copy** (m) : Matrix4x4
  152. Returns a copy of the matrix *m*.
  153. **add** (a, b) : Matrix4x4
  154. Adds the matrix *a* to *b* and returns the result.
  155. **subtract** (a, b) : Matrix4x4
  156. Subtracts the matrix *b* from *a* and returns the result.
  157. **multiply** (a, b) : Matrix4x4
  158. Multiplies the matrix *a* by *b* and returns the result. (i.e. transforms first by *a* then by *b*)
  159. **transpose** (m) : Matrix4x4
  160. Transposes the matrix *m* and returns the result.
  161. **determinant** (m) : float
  162. Returns the determinant of the matrix *m*.
  163. **invert** (m) : Matrix4x4
  164. Inverts the matrix *m* and returns the result.
  165. **x** (m) : Vector3
  166. Returns the x axis of the matrix *m*.
  167. **y** (m) : Vector3
  168. Returns the y axis of the matrix *m*.
  169. **z** (m) : Vector3
  170. Returns the z axis of the matrix *m*.
  171. **set_x** (m, x)
  172. Sets the x axis of the matrix *m*.
  173. **set_y** (m, y)
  174. Sets the y axis of the matrix *m*.
  175. **set_z** (m, z)
  176. Sets the z axis of the matrix *m*.
  177. **rotation** (m) : Quaternion
  178. Returns the rotation portion of the matrix *m*.
  179. **set_rotation** (m, r)
  180. Sets the rotation portion of the matrix *m*.
  181. **translation** (m, a) : Vector3
  182. Returns the translation portion of the matrix *m*.
  183. **set_translation** (m, t)
  184. Sets the translation portion of the matrix *m*.
  185. **identity** ()
  186. Returns the identity matrix.
  187. **transform** (m, v) : Vector3
  188. Transforms the vector *v* by the matrix *m* and returns the result.
  189. **to_string** (m) : string
  190. Returns a string representing the matrix *m*.
  191. Matrix4x4Box
  192. ------------
  193. **Matrix4x4Box** () : Matrix4x4Box
  194. Returns a new Matrix4x4Box initialized with the identity matrix.
  195. **Matrix4x4Box** (m) : Matrix4x4Box
  196. Returns a new Matrix4x4Box from the Matrix4x4 *m*.
  197. **store** (m)
  198. Stores the Matrix4x4 *m* in the box.
  199. **unbox** () : Matrix4x4
  200. Returns the stored matrix from the box.
  201. Color4
  202. ------
  203. **Color4** (r, g, b, a) : Color4
  204. Returns a new Color4 from individual elements.
  205. **to_string** (c) : string
  206. Returns a string representing the color *c*.
  207. Math
  208. ----
  209. **ray_plane_intersection** (from, dir, point, normal) : float
  210. Returns the distance along ray (from, dir) to intersection point with plane defined by
  211. *point* and *normal* or -1.0 if no intersection.
  212. **ray_disc_intersection** (from, dir, center, radius, normal) : float
  213. Returns the distance along ray (from, dir) to intersection point with disc defined by
  214. *center*, *radius* and *normal* or -1.0 if no intersection.
  215. **ray_sphere_intersection** (from, dir, center, radius) : float
  216. Returns the distance along ray (from, dir) to intersection point with sphere defined by
  217. *center* and *radius* or -1.0 if no intersection.
  218. **ray_obb_intersection** (from, dir, tm, half_extents) : float
  219. Returns the distance along ray (from, dir) to intersection point with the oriented
  220. bounding box (tm, half_extents) or -1.0 if no intersection.
  221. UnitManager
  222. ===========
  223. **create** ([world]) : Unit
  224. Creates a new empty unit. If *world* is specified, the unit will be owned by
  225. that world.
  226. **destroy** (unit)
  227. Destroys the given *unit*.
  228. **alive** (unit) : bool
  229. Returns whether the unit is alive.
  230. World
  231. =====
  232. **spawn_unit** (world, name, [position, rotation]) : Unit
  233. Spawns a new instance of the unit *name* at the given *position* and *rotation*.
  234. **destroy_unit** (world, unit)
  235. Destroys the given *unit*.
  236. **num_units** (world) : int
  237. Returns the number of units in the *world*.
  238. **units** (world) : Table
  239. Returns all the the units in the world in a table.
  240. **update_animations** (world, dt)
  241. Update all animations with *dt*.
  242. **update_scene** (world, dt)
  243. Updates the scene with *dt*.
  244. **update** (world, dt)
  245. Updates the world with *dt*.
  246. **play_sound** (world, name, [loop, volume, position, range]) : SoundInstanceId
  247. Plays the sound with the given *name* at the given *position*, with the given
  248. *volume* and *range*. *loop* controls whether the sound must loop or not.
  249. **stop_sound** (world, id)
  250. Stops the sound with the given *id*.
  251. **link_sound** (world, id, unit, node)
  252. Links the sound *id* to the *node* of the given *unit*.
  253. After this call, the sound *id* will follow the unit *unit*.
  254. **set_listener_pose** (world, pose)
  255. Sets the *pose* of the listener.
  256. **set_sound_position** (world, position)
  257. Sets the *position* of the sound *id*.
  258. **set_sound_range** (world, range)
  259. Sets the *range* of the sound *id*.
  260. **set_sound_volume** (world, volume)
  261. Sets the *volume* of the sound *id*.
  262. **create_debug_line** (world, depth_test) : DebugLine
  263. Creates a new DebugLine. *depth_test* controls whether to
  264. enable depth test when rendering the lines.
  265. **destroy_debug_line** (world, line)
  266. Destroys the debug *line*.
  267. **load_level** (world, name, [pos, rot]) : Level
  268. Loads the level *name* into the world at the given *position* and *rotation*.
  269. **scene_graph** (world) : SceneGraph
  270. Returns the scene graph.
  271. **render_world** (world) : RenderWorld
  272. Returns the render sub-world.
  273. **physics_world** (world) : PhysicsWorld
  274. Returns the physics sub-world.
  275. **sound_world** (world) : SoundWorld
  276. Returns the sound sub-world.
  277. SceneGraph
  278. ----------
  279. **create** (sg, unit) : int
  280. Creates the transform for the *unit*.
  281. **destroy** (sg, id)
  282. Destroys the transform *id*.
  283. **transform_instances** (sg, unit) : Id
  284. Returns the transform of the *unit*.
  285. **local_position** (sg, id) : Vector3
  286. Returns the local position of the transform *id*.
  287. **local_rotation** (sg, id) : Quaternion
  288. Returns the local rotation of the transform *id*.
  289. **local_scale** (sg, id) : Vector3
  290. Returns the local scale of the transform *id*.
  291. **local_pose** (sg, id) : Matrix4x4
  292. Returns the local pose of the transform *id*.
  293. **world_position** (sg, id) : Vector3
  294. Returns the world position of the transform *id*.
  295. **world_rotation** (sg, id) : Quaternion
  296. Returns the world rotation of the transform *id*.
  297. **world_pose** (sg, id) : Matrix4x4
  298. Returns the world pose of the transform *id*.
  299. **set_local_position** (sg, id, position)
  300. Sets the local *position* of the transform *id*.
  301. **set_local_rotation** (sg, id, rotation)
  302. Sets the local *rotation* of the transform *id*.
  303. **set_local_scale** (sg, id, scale)
  304. Sets the local *scale* of the transform *id*.
  305. **set_local_pose** (sg, id, pose)
  306. Sets the local *pose* of the transform *id*.
  307. **link** (sg, child, parent)
  308. Links *child* transform to *parent* transform.
  309. **unlink** (sg, id)
  310. Unlinks *id* transform from its parent, if any.
  311. Material
  312. --------
  313. **set_float** (material, variable, value)
  314. Sets the material variable to the given value.
  315. **set_vector2** (material, variable, value)
  316. Sets the material variable to the given value.
  317. **set_vector3** (material, variable, value)
  318. Sets the material variable to the given value.
  319. Gui
  320. ---
  321. resolution
  322. TODO
  323. move
  324. TODO
  325. screen_to_gui
  326. TODO
  327. draw_rectangle
  328. TODO
  329. draw_image
  330. TODO
  331. draw_image_uv
  332. TODO
  333. draw_text
  334. TODO
  335. RenderWorld
  336. ===========
  337. **enable_debug_drawing** (rw, enable)
  338. Sets whether to *enable* debug drawing.
  339. Mesh
  340. ----
  341. **create_mesh** (rw, unit, mesh_resource, mesh_name, material_resource, visible) : Id
  342. Creates a new mesh instance for *unit* and returns its id.
  343. **destroy_mesh** (rw, id)
  344. Destroys the mesh *id*.
  345. **mesh_instances** (rw, unit) : table
  346. Returns all the mesh instances of the *unit*.
  347. Sprite
  348. ------
  349. **create_sprite** (rw, unit, sprite_resource, material_resource, visible) : Id
  350. Creates a new sprite instance for *unit* and returns its id.
  351. **destroy_sprite** (rw, id)
  352. Destroys the sprite *id*.
  353. **sprite_instances** (rw, unit) : table
  354. Returns all the sprites of the *unit*.
  355. Light
  356. -----
  357. **create_light** (rw, unit) : Id
  358. Creates a new light for *unit* and returns its id.
  359. **destroy_light** (rw, id)
  360. Destroys the light *id*.
  361. **light_instances** (rw, unit) : Id
  362. Returns the light of the *unit*.
  363. **light_type** (rw, id) : string
  364. Returns the type of the light *id*.
  365. It can be either ``directional``, ``omni`` or ``spot``.
  366. **light_color** (rw, id) : Color4
  367. Returns the color of the light *id*.
  368. **light_range** (rw, id) : float
  369. Returns the range of the light *id*.
  370. **light_intensity** (rw, id) : float
  371. Returns the intensity of the light *id*.
  372. **light_spot_angle** (rw, id) : float
  373. Returns the spot angle of the light *id*.
  374. **set_light_type** (rw, id, type)
  375. Sets the *type* of the light *id*.
  376. **set_light_color** (rw, id, color)
  377. Sets the *color* of the light *id*.
  378. **set_light_range** (rw, id, range)
  379. Sets the *range* of the light *id*.
  380. **set_light_intensity** (rw, id, intensity)
  381. Sets the *intensity* of the light *id*.
  382. **set_light_spot_angle** (rw, id, angle)
  383. Sets the spot *angle* of the light *id*.
  384. PhysicsWorld
  385. =============
  386. **gravity** (pw) : Vector3
  387. Returns the gravity.
  388. **set_gravity** (pw, gravity)
  389. Sets the gravity.
  390. **raycast** (pw, from, dir, length, mode) : table
  391. Returns the actors which intersects the raycast.
  392. Mode can be either ``closest`` or ``all``.
  393. **enable_debug_drawing** (pw, enable)
  394. Sets whether to *enable* debug drawing.
  395. Actor
  396. -----
  397. **actor_instances** (pw, unit) : Id
  398. Returns the actor of the *unit*.
  399. **actor_world_position** (pw, actor) : Vector3
  400. Returns the world position of the actor.
  401. **actor_world_rotation** (pw, actor) : Quaternion
  402. Returns the world rotation of the actor.
  403. **actor_world_pose** (pw, actor) : Matrix4x4
  404. Returns the world pose of the actor.
  405. **teleport_actor_world_position** (pw, actor, position)
  406. Teleports the actor to the given world position.
  407. **teleport_actor_world_rotation** (pw, actor, rotation)
  408. Teleports the actor to the given world rotation.
  409. **teleport_actor_world_pose** (pw, actor, pose)
  410. Teleports the actor to the given world pose.
  411. **actor_center_of_mass** (pw, actor) : Vector3
  412. Returns the center of mass of the actor.
  413. **enable_actor_gravity** (pw, actor)
  414. Enables gravity for the actor.
  415. **disable_actor_gravity** (pw, actor)
  416. Disables gravity for the actor.
  417. **enable_actor_collision** (pw, actor)
  418. Enables collision detection for the actor.
  419. **disable_actor_collision** (pw, actor)
  420. Disables collision detection for the actor.
  421. **set_actor_collision_filter** (pw, actor, name)
  422. Sets the collision filter of the actor.
  423. **set_actor_kinematic** (pw, actor, kinematic)
  424. Sets whether the actor is kinematic or not.
  425. Note that this call has no effect on static actors.
  426. **move_actor** (pw, actor, position)
  427. Moves the actor to *pos*
  428. Note that this call only affects nonkinematic actors.
  429. **is_static** (pw, actor) : bool
  430. Returns whether the actor is static.
  431. **is_dynamic** (pw, actor) bool
  432. Returns whether the actor is dynamic.
  433. **is_kinematic** (pw, actor) : bool
  434. Returns whether the actor is kinematic (keyframed).
  435. **is_nonkinematic** (pw, actor) : bool
  436. Returns whether the actor is nonkinematic (i.e. dynamic and not kinematic).
  437. **actor_linear_damping** (pw, actor) : float
  438. Returns the linear damping of the actor.
  439. **set_actor_linear_damping** (pw, actor, damping)
  440. Sets the linear damping of the actor.
  441. **actor_angular_damping** (pw, actor) : float
  442. Returns the angular damping of the actor.
  443. **set_actor_angular_damping** (pw, actor, rate)
  444. Sets the angular damping of the actor.
  445. **actor_linear_velocity** (pw, actor) : Vector3
  446. Returns the linear velocity of the actor.
  447. **set_actor_linear_velocity** (pw, actor, velocity)
  448. Sets the linear velocity of the actor.
  449. Note that this call only affects nonkinematic actors.
  450. **actor_angular_velocity** (pw, actor) : Vector3
  451. Returns the angular velocity of the actor.
  452. **set_actor_angular_velocity** (pw, actor, velocity)
  453. Sets the angular velocity of the actor.
  454. Note that this call only affects nonkinematic actors.
  455. **add_actor_impulse** (pw, actor, impulse)
  456. Adds a linear impulse (acting along the center of mass) to the actor.
  457. Note that this call only affects nonkinematic actors.
  458. **add_actor_impulse_at** (pw, actor, impulse, position)
  459. Adds a linear impulse (acting along the world position *pos*) to the actor.
  460. Note that this call only affects nonkinematic actors.
  461. **add_actor_torque_impulse** (pw, actor, impulse)
  462. Adds a torque impulse to the actor.
  463. **push_actor** (pw, actor, velocity, mass)
  464. Pushes the actor as if it was hit by a point object with the given *mass*
  465. travelling at the given *velocity*.
  466. Note that this call only affects nonkinematic actors.
  467. **push_actor_at** (pw, actor, velocity, mass, position)
  468. Like push() but applies the force at the world position *pos*.
  469. Note that this call only affects nonkinematic actors.
  470. **is_sleeping** (pw, actor) : bool
  471. Returns whether the actor is sleeping.
  472. **wake_up** (pw, actor)
  473. Wakes the actor up.
  474. SoundWorld
  475. ===========
  476. **stop_all** (sound_world)
  477. Stops all the sounds in the world.
  478. **pause_all** (sound_world)
  479. Pauses all the sounds in the world
  480. **resume_all** (sound_world)
  481. Resumes all previously paused sounds in the world.
  482. **is_playing** (sound_world, id) : bool
  483. Returns whether the sound *id* is playing.
  484. ResourcePackage
  485. ================
  486. **load** (package)
  487. Loads all the resources in the package.
  488. Note that the resources are not immediately available after the call is made,
  489. instead, you have to poll for completion with has_loaded().
  490. **unload** (package)
  491. Unloads all the resources in the package.
  492. **flush** (package)
  493. Waits until the package has been loaded.
  494. **has_loaded** (package) : bool
  495. Returns whether the package has been loaded.
  496. Device
  497. ======
  498. **platform** () : string
  499. Returns a string identifying what platform the engine is running on.
  500. It can be either ``android``, ``linux`` or ``windows``
  501. **architecture** () : string
  502. Returns a string identifying what architecture the engine is running on.
  503. **version** () : string
  504. Returns a string identifying the engine version.
  505. **last_delta_time** () : float
  506. Returns the time in seconds needed to render the last frame
  507. **quit** ()
  508. Quits the application.
  509. **resolution** () : Table
  510. Returns the main window resolution.
  511. **create_world** () : World
  512. Creates a new world.
  513. **destroy_world** (world)
  514. Destroys the given *world*.
  515. **render_world** (world, camera)
  516. Renders the given *world* from the point of view of the given *camera*.
  517. **create_resource_package** (name) : ResourcePackage
  518. Returns the resource package with the given *package_name* name.
  519. **destroy_resource_package** (package)
  520. Destroy a previously created resource *package*.
  521. Note that to unload the resources loaded by the package, you have to call
  522. ResourcePackage.unload() first.
  523. **console_send** (table)
  524. Sends the given lua *table* to clients connected to the engine.
  525. Note that the current version only supports explicitly escaped strings as key/value pairs.
  526. **can_get** (type, name) : bool
  527. Returns whether the resource (type, name) is loaded.
  528. When resource autoload is enabled it always returns true.
  529. **enable_resource_autoload** (enable)
  530. Sets whether resources should be automatically loaded when accessed.
  531. DebugLine
  532. =========
  533. **add_line** (debug_line, start, end, color)
  534. Adds a line from *start* to *end* with the given *color*.
  535. **add_axes** (debug_line, tm, length)
  536. Adds lines for each axis with the given *length*.
  537. **add_circle** (debug_line, center, radius, normal, color, [segments = 36])
  538. Adds a circle at *center* with the given *radius* and *normal* vector.
  539. **add_cone** (debug_line, from, to, radius, color, [segments = 36])
  540. Adds a cone with the base centered at *from* and the tip at *to*.
  541. **add_sphere** (debug_line, center, radius, color, [segments = 36])
  542. Adds a sphere at *center* with the given *radius*.
  543. **add_obb** (debug_line, tm, half_extents, color)
  544. Adds an orientd bounding box. *tm* describes the position and orientation of
  545. the box. *half_extents* describes the size of the box along the axis.
  546. **reset** (debug_line)
  547. Resets all the lines.
  548. **submit** (debug_line)
  549. Submits the lines to renderer for drawing.
  550. Input
  551. =====
  552. Keyboard
  553. --------
  554. **name** () : string
  555. Returns the name of the input device.
  556. **connected** () : bool
  557. Returns whether the input device is connected and functioning.
  558. **num_buttons** () : int
  559. Returns the number of buttons of the input device.
  560. **num_axes** () : int
  561. Returns the number of axes of the input device.
  562. **pressed** (id) : bool
  563. Returns whether the button *id* is pressed in the current frame.
  564. **released** (id) : bool
  565. Returns whether the button *id* is released in the current frame.
  566. **any_pressed** () : bool
  567. Returns whether any button is pressed in the current frame.
  568. **any_released** () : bool
  569. Returns whether any button is released in the current frame.
  570. **button_name** (id) : string
  571. Returns the name of the button *id*.
  572. **button_id** (name) : int
  573. Returns the *id* of the button *name*.
  574. Keyboard Button Names
  575. ~~~~~~~~~~~~~~~~~~~~~
  576. * ``tab``, ``enter``, ``escape``, ``space``, ``backspace``
  577. * ``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``
  578. * ``f1``, ``f2``, ``f3``, ``f4``, ``f5``, ``f6``, ``f7``, ``f8``, ``f9``, ``f10``, ``f11``, ``f12``
  579. * ``home``, ``left``, ``up``, ``right``, ``down``, ``page_up``, ``page_down``, ``delete``, ``end``
  580. * ``left_ctrl``, ``right_ctrl``, ``left_shift``, ``right_shift``, ``caps_lock``, ``left_alt``, ``right_alt``, ``left_super``, ``right_super``
  581. * ``0``, ``1``, ``2``, ``3``, ``4``, ``5``, ``6``, ``7``, ``8``, ``9``
  582. * ``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``
  583. Keyboard Axis Names
  584. ~~~~~~~~~~~~~~~~~~~
  585. None.
  586. Mouse
  587. -----
  588. **name** () : string
  589. Returns the name of the input device.
  590. **connected** () : bool
  591. Returns whether the input device is connected and functioning.
  592. **num_buttons** () : int
  593. Returns the number of buttons of the input device.
  594. **num_axes** () : int
  595. Returns the number of axes of the input device.
  596. **pressed** (id) : bool
  597. Returns whether the button *id* is pressed in the current frame.
  598. **released** (id) : bool
  599. Returns whether the button *id* is released in the current frame.
  600. **any_pressed** () : bool
  601. Returns whether any button is pressed in the current frame.
  602. **any_released** () : bool
  603. Returns whether any button is released in the current frame.
  604. **axis** (id) : Vector3
  605. Returns the value of the axis *id*.
  606. **button_name** (id) : string
  607. Returns the name of the button *id*.
  608. **axis_name** (id) : string
  609. Returns the name of the axis *id*.
  610. **button_id** (name) : int
  611. Returns the *id* of the button *name*.
  612. **axis_id** (name) : int
  613. Returns the *id* of the axis *name*.
  614. Mouse Button Names
  615. ~~~~~~~~~~~~~~~~~~
  616. ``left``, ``middle``, ``right``, ``extra_1``, ``extra_2``
  617. Mouse Axis Names
  618. ~~~~~~~~~~~~~~~~
  619. * ``cursor``: Returns the cursor position (x, y) in screen coordinates.
  620. * ``cursor_delta``: Returns the delta of the cursor position (x, y) since last frame.
  621. * ``wheel``: Returns the movement of the mouse wheel in the y axis. Positive values of y mean upward scrolling, negative values mean downward scrolling.
  622. Touch
  623. -----
  624. **name** () : string
  625. Returns the name of the input device.
  626. **connected** () : bool
  627. Returns whether the input device is connected and functioning.
  628. **num_buttons** () : int
  629. Returns the number of buttons of the input device.
  630. **num_axes** () : int
  631. Returns the number of axes of the input device.
  632. **pressed** (id) : bool
  633. Returns whether the button *id* is pressed in the current frame.
  634. **released** (id) : bool
  635. Returns whether the button *id* is released in the current frame.
  636. **any_pressed** () : bool
  637. Returns whether any button is pressed in the current frame.
  638. **any_released** () : bool
  639. Returns whether any button is released in the current frame.
  640. **axis** (id) : Vector3
  641. Returns the value of the axis *id*.
  642. **button_name** (id) : string
  643. Returns the name of the button *id*.
  644. **axis_name** (id) : string
  645. Returns the name of the axis *id*.
  646. **button_id** (name) : int
  647. Returns the *id* of the button *name*.
  648. **axis_id** (name) : int
  649. Returns the *id* of the axis *name*.
  650. Pad1, Pad2, Pad3, Pad4
  651. ----------------------
  652. **name** () : string
  653. Returns the name of the input device.
  654. **connected** () : bool
  655. Returns whether the input device is connected and functioning.
  656. **num_buttons** () : int
  657. Returns the number of buttons of the input device.
  658. **num_axes** () : int
  659. Returns the number of axes of the input device.
  660. **pressed** (id) : bool
  661. Returns whether the button *id* is pressed in the current frame.
  662. **released** (id) : bool
  663. Returns whether the button *id* is released in the current frame.
  664. **any_pressed** () : bool
  665. Returns whether any button is pressed in the current frame.
  666. **any_released** () : bool
  667. Returns whether any button is released in the current frame.
  668. **axis** (id) : Vector3
  669. Returns the value of the axis *id*.
  670. **button_name** (id) : string
  671. Returns the name of the button *id*.
  672. **axis_name** (id) : string
  673. Returns the name of the axis *id*.
  674. **button_id** (name) : int
  675. Returns the *id* of the button *name*.
  676. **axis_id** (name) : int
  677. Returns the *id* of the axis *name*.
  678. Pad Button Names
  679. ~~~~~~~~~~~~~~~~
  680. * ``up``, ``down``, ``left``, ``right``
  681. * ``start``, ``back``, ``guide``
  682. * ``left_thumb``, ``right_thumb``
  683. * ``left_shoulder``, ``right_shoulder``
  684. * ``a``, ``b``, ``x``, ``y``
  685. Pad Axis Names
  686. ~~~~~~~~~~~~~~
  687. * ``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].
  688. Profiler
  689. ========
  690. **enter_scope** (name)
  691. Starts a new profile scope with the given *name*.
  692. **leave_scope** ()
  693. Ends the last profile scope.
  694. **record** (name, value)
  695. Rectords *value* with the given *name*. Value can be either number or Vector3.
  696. Window
  697. ======
  698. **show** ()
  699. Shows the window.
  700. **hide** ()
  701. Hides the window.
  702. **resize** (width, height)
  703. Resizes the window to *width* and *height*.
  704. **move** (x, y)
  705. Moves the window to *x* and *y*.
  706. **minimize** ()
  707. Minimizes the window.
  708. **restore** ()
  709. Restores the window.
  710. **is_resizable** () : bool
  711. Returns whether the window is resizable.
  712. **set_resizable** (resizable)
  713. Sets whether the window is resizable.
  714. **title** () : string
  715. Returns the title of the window.
  716. **set_title** (title)
  717. Sets the title of the window.