newCollider.lua 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. return {
  2. tag = 'colliders',
  3. summary = 'Add a Collider to the World.',
  4. description = 'Adds a new Collider to the World.',
  5. arguments = {
  6. {
  7. name = 'x',
  8. type = 'number',
  9. default = '0',
  10. description = 'The x position of the Collider.'
  11. },
  12. {
  13. name = 'y',
  14. type = 'number',
  15. default = '0',
  16. description = 'The y position of the Collider.'
  17. },
  18. {
  19. name = 'z',
  20. type = 'number',
  21. default = '0',
  22. description = 'The z position of the Collider.'
  23. }
  24. },
  25. returns = {
  26. {
  27. name = 'collider',
  28. type = 'Collider',
  29. description = 'The new Collider.'
  30. }
  31. },
  32. notes = [[
  33. This function creates a collider without any shapes attached to it, which means it won't collide
  34. with anything. To add a shape to the collider, use `Collider:addShape`, or use one of the
  35. following functions to create the collider:
  36. - `World:newBoxCollider`
  37. - `World:newCapsuleCollider`
  38. - `World:newCylinderCollider`
  39. - `World:newSphereCollider`
  40. ]],
  41. example = {
  42. description = [[
  43. Create a new world, add a collider to it, and update it, printing out the collider's position
  44. as it falls.
  45. ]],
  46. code = [[
  47. function lovr.load()
  48. world = lovr.physics.newWorld()
  49. box = world:newBoxCollider()
  50. end
  51. function lovr.update(dt)
  52. world:update(dt)
  53. print(box:getPosition())
  54. end
  55. ]]
  56. },
  57. related = {
  58. 'World:newBoxCollider',
  59. 'World:newCapsuleCollider',
  60. 'World:newCylinderCollider',
  61. 'World:newMeshCollider',
  62. 'World:newSphereCollider',
  63. 'Collider',
  64. 'Shape'
  65. }
  66. }