newCollider.lua 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. x = {
  7. type = 'number',
  8. default = '0',
  9. description = 'The x position of the Collider.'
  10. },
  11. y = {
  12. type = 'number',
  13. default = '0',
  14. description = 'The y position of the Collider.'
  15. },
  16. z = {
  17. type = 'number',
  18. default = '0',
  19. description = 'The z position of the Collider.'
  20. },
  21. position = {
  22. type = 'Vec3',
  23. description = 'The position of the Collider.'
  24. }
  25. },
  26. returns = {
  27. collider = {
  28. type = 'Collider',
  29. description = 'The new Collider.'
  30. }
  31. },
  32. variants = {
  33. {
  34. arguments = { 'x', 'y', 'z' },
  35. returns = { 'collider' }
  36. },
  37. {
  38. arguments = { 'position' },
  39. returns = { 'collider' }
  40. }
  41. },
  42. notes = [[
  43. This function creates a collider without any shapes attached to it, which means it won't collide
  44. with anything. To add a shape to the collider, use `Collider:addShape`, or use one of the
  45. following functions to create the collider:
  46. - `World:newBoxCollider`
  47. - `World:newCapsuleCollider`
  48. - `World:newCylinderCollider`
  49. - `World:newSphereCollider`
  50. ]],
  51. example = {
  52. description = [[
  53. Create a new world, add a collider to it, and update it, printing out the collider's position
  54. as it 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. related = {
  68. 'World:newBoxCollider',
  69. 'World:newCapsuleCollider',
  70. 'World:newCylinderCollider',
  71. 'World:newMeshCollider',
  72. 'World:newSphereCollider',
  73. 'World:newTerrainCollider',
  74. 'Collider',
  75. 'Shape'
  76. }
  77. }