newWorld.lua 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. return {
  2. tag = 'world',
  3. summary = 'Create a new World.',
  4. description = [[
  5. Creates a new physics World, which tracks the overall physics simulation, holds collider
  6. objects, and resolves collisions between them.
  7. ]],
  8. arguments = {
  9. {
  10. name = 'xg',
  11. type = 'number',
  12. default = '0',
  13. description = 'The x component of the gravity force.'
  14. },
  15. {
  16. name = 'yg',
  17. type = 'number',
  18. default = '-9.81',
  19. description = 'The y component of the gravity force.'
  20. },
  21. {
  22. name = 'zg',
  23. type = 'number',
  24. default = '0',
  25. description = 'The z component of the gravity force.'
  26. },
  27. {
  28. name = 'allowSleep',
  29. type = 'boolean',
  30. default = 'true',
  31. description = 'Whether or not colliders will automatically be put to sleep.'
  32. },
  33. {
  34. name = 'tags',
  35. type = 'table',
  36. default = '{}',
  37. description = 'A list of collision tags colliders can be assigned to.'
  38. }
  39. },
  40. returns = {
  41. {
  42. name = 'world',
  43. type = 'World',
  44. description = 'A whole new World.'
  45. }
  46. },
  47. notes = [[
  48. A World must be updated with `World:update` in `lovr.update` for the physics simulation to
  49. advance.
  50. ]],
  51. example = {
  52. description = [[
  53. Create a new world, add a collider to it, and update it, printing out its position as it
  54. falls.
  55. ]],
  56. code = [[
  57. function lovr.load()
  58. world = lovr.physics.newWorld()
  59. box = world:newBoxCollider()
  60. end
  61. function lovr.update(dt)
  62. world:update(dt)
  63. print(box:getPosition())
  64. end
  65. ]]
  66. }
  67. }