bjorn 1 year ago
parent
commit
8182dd555a
40 changed files with 777 additions and 378 deletions
  1. 490 259
      api/init.lua
  2. 7 2
      api/lovr/callbacks/conf.lua
  3. 8 4
      api/lovr/callbacks/draw.lua
  4. 8 4
      api/lovr/callbacks/errhand.lua
  5. 7 2
      api/lovr/callbacks/focus.lua
  6. 9 6
      api/lovr/callbacks/keypressed.lua
  7. 8 4
      api/lovr/callbacks/keyreleased.lua
  8. 7 2
      api/lovr/callbacks/load.lua
  9. 9 6
      api/lovr/callbacks/log.lua
  10. 8 4
      api/lovr/callbacks/mirror.lua
  11. 10 8
      api/lovr/callbacks/mousemoved.lua
  12. 9 6
      api/lovr/callbacks/mousepressed.lua
  13. 9 6
      api/lovr/callbacks/mousereleased.lua
  14. 8 4
      api/lovr/callbacks/permission.lua
  15. 7 2
      api/lovr/callbacks/quit.lua
  16. 6 0
      api/lovr/callbacks/recenter.lua
  17. 8 4
      api/lovr/callbacks/resize.lua
  18. 7 2
      api/lovr/callbacks/restart.lua
  19. 7 2
      api/lovr/callbacks/run.lua
  20. 9 5
      api/lovr/callbacks/textinput.lua
  21. 8 4
      api/lovr/callbacks/threaderror.lua
  22. 7 2
      api/lovr/callbacks/update.lua
  23. 7 2
      api/lovr/callbacks/visible.lua
  24. 8 4
      api/lovr/callbacks/wheelmoved.lua
  25. 10 11
      api/lovr/physics/Collider/getInertia.lua
  26. 2 2
      api/lovr/physics/Collider/getTag.lua
  27. 1 0
      api/lovr/physics/Collider/setInertia.lua
  28. 4 0
      api/lovr/physics/ConeJoint/init.lua
  29. 1 1
      api/lovr/physics/ConvexShape/getPointCount.lua
  30. 4 0
      api/lovr/physics/ConvexShape/init.lua
  31. 1 1
      api/lovr/physics/HingeJoint/setLimits.lua
  32. 60 1
      api/lovr/physics/Shape/getInertia.lua
  33. 6 0
      api/lovr/physics/Shape/isDestroyed.lua
  34. 4 0
      api/lovr/physics/WeldJoint/init.lua
  35. 0 3
      api/lovr/physics/World/overlapShape.lua
  36. 2 2
      api/lovr/physics/World/raycast.lua
  37. 2 2
      api/lovr/physics/World/setCallbacks.lua
  38. 1 1
      api/lovr/physics/World/shapecast.lua
  39. 0 4
      api/lovr/physics/newWorld.lua
  40. 8 6
      api/main.lua

File diff suppressed because it is too large
+ 490 - 259
api/init.lua


+ 7 - 2
api/lovr/callbacks/conf.lua

@@ -7,8 +7,7 @@ return {
     file that's loaded before the rest of the framework initializes.
   ]],
   arguments = {
-    {
-      name = 't',
+    t = {
       type = 'table',
       description = 'The table to edit the configuration settings on.',
       table = {
@@ -252,6 +251,12 @@ return {
     }
   },
   returns = {},
+  variants = {
+    {
+      arguments = { 't' },
+      returns = {}
+    }
+  },
   notes = [[
     Disabling unused modules can improve startup time.
 

+ 8 - 4
api/lovr/callbacks/draw.lua

@@ -7,19 +7,23 @@ return {
     the headset display, otherwise it will render to the desktop window.
   ]],
   arguments = {
-    {
-      name = 'pass',
+    pass = {
       type = 'Pass',
       description = 'A render pass targeting the main display (headset or window).'
     }
   },
   returns = {
-    {
-      name = 'skip',
+    skip = {
       type = 'boolean',
       description = 'If truthy, the input Pass will not be submitted to the GPU.'
     }
   },
+  variants = {
+    {
+      arguments = { 'pass' },
+      returns = { 'skip' }
+    }
+  },
   notes = [[
     To render to the desktop window when a VR headset is connected, use the `lovr.mirror` callback.
 

+ 8 - 4
api/lovr/callbacks/errhand.lua

@@ -16,15 +16,13 @@ return {
     to the window.
   ]],
   arguments = {
-    {
-      name = 'message',
+    message = {
       type = 'string',
       description = 'The error message.'
     }
   },
   returns = {
-    {
-      name = 'handler',
+    handler = {
       type = 'function',
       arguments = {},
       returns = {
@@ -39,6 +37,12 @@ return {
       ]]
     }
   },
+  variants = {
+    {
+      arguments = { 'message' },
+      returns = { 'handler' }
+    }
+  },
   example = {
     description = 'The default error handler.',
     code = [[

+ 7 - 2
api/lovr/callbacks/focus.lua

@@ -8,13 +8,18 @@ return {
     make sense to pause the game or reduce visual fidelity when the application loses focus.
   ]],
   arguments = {
-    {
-      name = 'focused',
+    focused = {
       type = 'boolean',
       description = 'Whether the program is now focused.'
     }
   },
   returns = {},
+  variants = {
+    {
+      arguments = { 'focused' },
+      returns = {}
+    }
+  },
   related = {
     'lovr.headset.isFocused',
     'lovr.visible'

+ 9 - 6
api/lovr/callbacks/keypressed.lua

@@ -3,23 +3,26 @@ return {
   summary = 'Called when a key is pressed.',
   description = 'This callback is called when a key is pressed.',
   arguments = {
-    {
-      name = 'key',
+    key = {
       type = 'KeyCode',
       description = 'The key that was pressed.'
     },
-    {
-      name = 'scancode',
+    scancode = {
       type = 'number',
       description = 'The id of the key (ignores keyboard layout, may vary between keyboards).'
     },
-    {
-      name = 'repeating',
+    ['repeat'] = {
       type = 'boolean',
       description = 'Whether the event is the result of a key repeat instead of an actual press.'
     }
   },
   returns = {},
+  variants = {
+    {
+      arguments = { 'key', 'scancode', 'repeat' },
+      returns = {}
+    }
+  },
   related = {
     'lovr.system.wasKeyPressed',
     'lovr.keyreleased',

+ 8 - 4
api/lovr/callbacks/keyreleased.lua

@@ -3,18 +3,22 @@ return {
   summary = 'Called when a key is released.',
   description = 'This callback is called when a key is released.',
   arguments = {
-    {
-      name = 'key',
+    key = {
       type = 'KeyCode',
       description = 'The key that was released.'
     },
-    {
-      name = 'scancode',
+    scancode = {
       type = 'number',
       description = 'The id of the key (ignores keyboard layout, may vary between keyboards).'
     }
   },
   returns = {},
+  variants = {
+    {
+      arguments = { 'key', 'scancode' },
+      returns = {}
+    }
+  },
   related = {
     'lovr.system.wasKeyReleased',
     'lovr.keypressed',

+ 7 - 2
api/lovr/callbacks/load.lua

@@ -6,13 +6,18 @@ return {
     work, like loading resources and initializing classes and variables.
   ]],
   arguments = {
-    {
-      name = 'arg',
+    arg = {
       type = 'table',
       description = 'The command line arguments provided to the program.'
     }
   },
   returns = {},
+  variants = {
+    {
+      arguments = { 'arg' },
+      returns = {}
+    }
+  },
   example = [[
     function lovr.load(arg)
       model = lovr.graphics.newModel('sponza.gltf')

+ 9 - 6
api/lovr/callbacks/log.lua

@@ -14,23 +14,26 @@ return {
     by calling the callback.
   ]],
   arguments = {
-    {
-      name = 'message',
+    message = {
       type = 'string',
       description = 'The log message.  It may end in a newline.'
     },
-    {
-      name = 'level',
+    level = {
       type = 'string',
       description = 'The log level (`debug`, `info`, `warn`, or `error`).'
     },
-    {
-      name = 'tag',
+    tag = {
       type = 'string',
       description = 'The log tag.'
     }
   },
   returns = {},
+  variants = {
+    {
+      arguments = { 'message', 'level', 'tag' },
+      returns = {}
+    }
+  },
   related = {
     'Pass:text'
   }

+ 8 - 4
api/lovr/callbacks/mirror.lua

@@ -8,19 +8,23 @@ return {
     HUD could be rendered.
   ]],
   arguments = {
-    {
-      name = 'pass',
+    pass = {
       type = 'Pass',
       description = 'A render pass targeting the window.'
     }
   },
   returns = {
-    {
-      name = 'skip',
+    skip = {
       type = 'boolean',
       description = 'If truthy, the input Pass will not be submitted to the GPU.'
     }
   },
+  variants = {
+    {
+      arguments = { 'pass' },
+      returns = { 'skip' }
+    }
+  },
   example = {
     description = [[
       The default `lovr.mirror` implementation draws the headset mirror texture to the window if

+ 10 - 8
api/lovr/callbacks/mousemoved.lua

@@ -3,28 +3,30 @@ return {
   summary = 'Called when the mouse is moved.',
   description = 'This callback is called when the mouse is moved.',
   arguments = {
-    {
-      name = 'x',
+    x = {
       type = 'number',
       description = 'The new x position of the mouse.'
     },
-    {
-      name = 'y',
+    y = {
       type = 'number',
       description = 'The new y position of the mouse.'
     },
-    {
-      name = 'dx',
+    dx = {
       type = 'number',
       description = 'The movement on the x axis since the last mousemove event.'
     },
-    {
-      name = 'dy',
+    dy = {
       type = 'number',
       description = 'The movement on the y axis since the last mousemove event.'
     }
   },
   returns = {},
+  variants = {
+    {
+      arguments = { 'x', 'y', 'dx', 'dy' },
+      returns = {}
+    }
+  },
   related = {
     'lovr.mousepressed',
     'lovr.mousereleased',

+ 9 - 6
api/lovr/callbacks/mousepressed.lua

@@ -3,18 +3,15 @@ return {
   summary = 'Called when a mouse button is pressed.',
   description = 'This callback is called when a mouse button is pressed.',
   arguments = {
-    {
-      name = 'x',
+    x = {
       type = 'number',
       description = 'The x position of the mouse when the button was pressed.'
     },
-    {
-      name = 'y',
+    y = {
       type = 'number',
       description = 'The y position of the mouse when the button was pressed.'
     },
-    {
-      name = 'button',
+    button = {
       type = 'number',
       description = [[
         The button that was pressed.  Will be 1 for the primary button, 2 for the secondary button,
@@ -23,6 +20,12 @@ return {
     }
   },
   returns = {},
+  variants = {
+    {
+      arguments = { 'x', 'y', 'button' },
+      returns = {}
+    }
+  },
   related = {
     'lovr.mousereleased',
     'lovr.mousemoved',

+ 9 - 6
api/lovr/callbacks/mousereleased.lua

@@ -3,18 +3,15 @@ return {
   summary = 'Called when a mouse button is released.',
   description = 'This callback is called when a mouse button is released.',
   arguments = {
-    {
-      name = 'x',
+    x = {
       type = 'number',
       description = 'The x position of the mouse when the button was released.'
     },
-    {
-      name = 'y',
+    y = {
       type = 'number',
       description = 'The y position of the mouse when the button was released.'
     },
-    {
-      name = 'button',
+    button = {
       type = 'number',
       description = [[
         The button that was released.  Will be 1 for the primary button, 2 for the secondary button,
@@ -23,6 +20,12 @@ return {
     }
   },
   returns = {},
+  variants = {
+    {
+      arguments = { 'x', 'y', 'button' },
+      returns = {}
+    }
+  },
   related = {
     'lovr.mousepressed',
     'lovr.mousemoved',

+ 8 - 4
api/lovr/callbacks/permission.lua

@@ -7,18 +7,22 @@ return {
     granted or denied.
   ]],
   arguments = {
-    {
-      name = 'permission',
+    permission = {
       type = 'Permission',
       description = 'The type of permission.'
     },
-    {
-      name = 'granted',
+    granted = {
       type = 'boolean',
       description = 'Whether permission was granted or denied.'
     }
   },
   returns = {},
+  variants = {
+    {
+      arguments = { 'permission', 'granted' },
+      returns = {}
+    }
+  },
   related = {
     'lovr.system.requestPermission'
   }

+ 7 - 2
api/lovr/callbacks/quit.lua

@@ -7,12 +7,17 @@ return {
   ]],
   arguments = {},
   returns = {
-    {
+    abort = {
       type = 'boolean',
-      name = 'abort',
       description = 'Whether quitting should be aborted.'
     }
   },
+  variants = {
+    {
+      arguments = {},
+      returns = { 'abort' }
+    }
+  },
   example = [[
     function lovr.quit()
       if shouldQuit() then

+ 6 - 0
api/lovr/callbacks/recenter.lua

@@ -10,6 +10,12 @@ return {
   ]],
   arguments = {},
   returns = {},
+  variants = {
+    {
+      arguments = {},
+      returns = {}
+    }
+  },
   notes = [[
     Note that the pose of the `floor` device will not always be at the origin of the coordinate
     space.  It uses a fixed position on the floor in the real world, usually the center of the

+ 8 - 4
api/lovr/callbacks/resize.lua

@@ -3,18 +3,22 @@ return {
   summary = 'Called when the window is resized.',
   description = 'This callback is called when the desktop window is resized.',
   arguments = {
-    {
-      name = 'width',
+    width = {
       type = 'number',
       description = 'The new width of the window.'
     },
-    {
-      name = 'height',
+    height = {
       type = 'number',
       description = 'The new height of the window.'
     }
   },
   returns = {},
+  variants = {
+    {
+      arguments = { 'width', 'height' },
+      returns = {}
+    }
+  },
   related = {
     'Pass:getDimensions',
     'Pass:getWidth',

+ 7 - 2
api/lovr/callbacks/restart.lua

@@ -9,12 +9,17 @@ return {
   ]],
   arguments = {},
   returns = {
-    {
+    cookie = {
       type = '*',
-      name = 'cookie',
       description = 'The value to send to the next `lovr.load`.'
     }
   },
+  variants = {
+    {
+      arguments = {},
+      returns = { 'cookie' }
+    }
+  },
   notes = [[
     Only nil, booleans, numbers, and strings are supported types for the return value.
   ]],

+ 7 - 2
api/lovr/callbacks/run.lua

@@ -7,8 +7,7 @@ return {
   ]],
   arguments = {},
   returns = {
-    {
-      name = 'loop',
+    loop = {
       type = 'function',
       arguments = {},
       returns = {
@@ -20,6 +19,12 @@ return {
       description = 'The main loop function.'
     }
   },
+  variants = {
+    {
+      arguments = {},
+      returns = { 'loop' }
+    }
+  },
   notes = [[
     The main loop function can return one of the following values:
 

+ 9 - 5
api/lovr/callbacks/textinput.lua

@@ -8,24 +8,28 @@ return {
     called with `!`.
   ]],
   arguments = {
-    {
-      name = 'text',
+    text = {
       type = 'string',
       description = 'The UTF-8 encoded character.'
     },
-    {
-      name = 'code',
+    code = {
       type = 'number',
       description = 'The integer codepoint of the character.'
     }
   },
+  returns = {},
+  variants = {
+    {
+      arguments = { 'text', 'code' },
+      returns = {}
+    }
+  },
   notes = [[
     Some characters in UTF-8 unicode take multiple bytes to encode.  Due to the way Lua works, the
     length of these strings will be bigger than 1 even though they are just a single character.  The
     `utf8` library included with LÖVR can be used to manipulate UTF-8 strings.  `Pass:text` will
     also correctly handle UTF-8.
   ]],
-  returns = {},
   related = {
     'lovr.keypressed',
     'lovr.keyreleased'

+ 8 - 4
api/lovr/callbacks/threaderror.lua

@@ -8,18 +8,22 @@ return {
     The default implementation of this callback will call `lovr.errhand` with the error.
   ]],
   arguments = {
-    {
-      name = 'thread',
+    thread = {
       type = 'Thread',
       description = 'The Thread that errored.'
     },
-    {
-      name = 'message',
+    message = {
       type = 'string',
       description = 'The error message.'
     }
   },
   returns = {},
+  variants = {
+    {
+      arguments = { 'thread', 'message' },
+      returns = {}
+    }
+  },
   related = {
     'Thread',
     'Thread:getError',

+ 7 - 2
api/lovr/callbacks/update.lua

@@ -8,13 +8,18 @@ return {
     speed.
   ]],
   arguments = {
-    {
-      name = 'dt',
+    dt = {
       type = 'number',
       description = 'The number of seconds elapsed since the last update.'
     }
   },
   returns = {},
+  variants = {
+    {
+      arguments = { 'dt' },
+      returns = {}
+    }
+  },
   example = [[
     function lovr.update(dt)
       ball.vy = ball.vy + ball.gravity * dt

+ 7 - 2
api/lovr/callbacks/visible.lua

@@ -8,13 +8,18 @@ return {
     stop calling `lovr.draw`.
   ]],
   arguments = {
-    {
-      name = 'visible',
+    visible = {
       type = 'boolean',
       description = 'Whether the application is visible in the headset display.'
     }
   },
   returns = {},
+  variants = {
+    {
+      arguments = { 'visible' },
+      returns = {}
+    }
+  },
   related = {
     'lovr.headset.isVisible',
     'lovr.focus'

+ 8 - 4
api/lovr/callbacks/wheelmoved.lua

@@ -3,18 +3,22 @@ return {
   summary = 'Called when a mouse wheel is moved.',
   description = 'This callback is called on scroll action, from a mouse wheel or a touchpad',
   arguments = {
-    {
-      name = 'deltaX',
+    dx = {
       type = 'number',
       description = 'The relative horizontal motion; rightward movement resuts in positive values.'
     },
-    {
-      name = 'deltaY',
+    dy = {
       type = 'number',
       description = 'The relative vertical motion; upward movement results in positive values.'
     }
   },
   returns = {},
+  variants = {
+    {
+      arguments = { 'dx', 'dy' },
+      returns = {}
+    }
+  },
   related = {
     'lovr.mousepressed',
     'lovr.mousereleased',

+ 10 - 11
api/lovr/physics/Collider/getInertia.lua

@@ -28,27 +28,27 @@ return {
       type = 'number',
       description = 'The z component of the diagonal matrix.'
     },
-    qx = {
+    angle = {
       type = 'number',
-      description = 'The x component of the inertia rotation quaternion.'
+      description = 'The angle of the inertia rotation.'
     },
-    qy = {
+    ax = {
       type = 'number',
-      description = 'The y component of the inertia rotation quaternion.'
+      description = 'The x component of the inertia rotation axis.'
     },
-    qz = {
+    ay = {
       type = 'number',
-      description = 'The z component of the inertia rotation quaternion.'
+      description = 'The y component of the inertia rotation axis.'
     },
-    qw = {
+    az = {
       type = 'number',
-      description = 'The w component of the inertia rotation quaternion.'
+      description = 'The z component of the inertia rotation axis.'
     }
   },
   variants = {
     {
       arguments = {},
-      returns = { 'dx', 'dy', 'dz', 'qx', 'qy', 'qz', 'qw' }
+      returns = { 'dx', 'dy', 'dz', 'angle', 'ax', 'ay', 'az' }
     }
   },
   notes = [[
@@ -58,8 +58,7 @@ return {
     Use `Collider:resetMassData` to reset the inertia and other mass properties based on the
     Collider's shapes.
 
-    If the Collider is kinematic or all rotation axes are disabled, this returns 0 for the diagonal
-    and an identity quaternion for the rotation.
+    If the Collider is kinematic or all rotation axes are disabled, this returns zeroes.
   ]],
   related = {
     'Collider:getMass',

+ 2 - 2
api/lovr/physics/Collider/getTag.lua

@@ -18,8 +18,8 @@ return {
   },
   variants = {
     {
-      arguments = {}
-      returns = { 'tag' },
+      arguments = {},
+      returns = { 'tag' }
     }
   },
   related = {

+ 1 - 0
api/lovr/physics/Collider/setInertia.lua

@@ -52,6 +52,7 @@ return {
       description = 'The inertia rotation.'
     }
   },
+  returns = {},
   variants = {
     {
       arguments = { 'dx', 'dy', 'dz', 'angle', 'ax', 'ay', 'az' },

+ 4 - 0
api/lovr/physics/ConeJoint/init.lua

@@ -0,0 +1,4 @@
+return {
+  summary = 'TODO',
+  description = 'TODO'
+}

+ 1 - 1
api/lovr/physics/ConvexShape/getPointCount.lua

@@ -17,7 +17,7 @@ return {
   notes = [[
     This isn't necessarily the same as the number of points or vertices that were used to create the
     shape, since points inside the hull will be discarded.
-  ]]
+  ]],
   related = {
     'ConvexShape:getPoint'
   }

+ 4 - 0
api/lovr/physics/ConvexShape/init.lua

@@ -0,0 +1,4 @@
+return {
+  summary = 'TODO',
+  description = 'TODO'
+}

+ 1 - 1
api/lovr/physics/HingeJoint/setLimits.lua

@@ -17,7 +17,7 @@ return {
   returns = {},
   variants = {
     {
-      arguments = { 'lower', 'upper' },
+      arguments = { 'min', 'max' },
       returns = {}
     },
     {

+ 60 - 1
api/lovr/physics/Shape/getInertia.lua

@@ -1,4 +1,63 @@
 return {
   summary = 'Get the inertia of the Shape.',
-  description = 'Returns the inertia of the Shape.'
+  description = [[
+    Returns the inertia of the Shape.
+
+    Inertia is kind of like "angular mass".  Regular mass determines how resistant a Collider is to
+    linear forces (movement), whereas inertia determines how resistant the Collider is to torque
+    (rotation).  Colliders with less inertia are more spinny.
+
+    In 3D, inertia is represented by a 3x3 matrix, called a tensor.  To make calculations easier,
+    the physics engine stores the inertia using eigenvalue decomposition, splitting the matrix into
+    a diagonal matrix and a rotation.  It's complicated!
+
+    In a realistic simulation, mass and inertia follow a linear relationship.  If the mass of an
+    object increases, the diagonal part of its inertia should increase proportionally.
+  ]],
+  arguments = {},
+  returns = {
+    dx = {
+      type = 'number',
+      description = 'The x component of the diagonal matrix.'
+    },
+    dy = {
+      type = 'number',
+      description = 'The y component of the diagonal matrix.'
+    },
+    dz = {
+      type = 'number',
+      description = 'The z component of the diagonal matrix.'
+    },
+    angle = {
+      type = 'number',
+      description = 'The angle of the inertia rotation.'
+    },
+    ax = {
+      type = 'number',
+      description = 'The x component of the inertia rotation axis.'
+    },
+    ay = {
+      type = 'number',
+      description = 'The y component of the inertia rotation axis.'
+    },
+    az = {
+      type = 'number',
+      description = 'The z component of the inertia rotation axis.'
+    }
+  },
+  variants = {
+    {
+      arguments = {},
+      returns = { 'dx', 'dy', 'dz', 'angle', 'ax', 'ay', 'az' }
+    }
+  },
+  notes = [[
+    `MeshShape` and `TerrainShape` do not have mass or volue, and for those shapes this function
+    returns zeroes.
+  ]],
+  related = {
+    'Shape:getMass',
+    'Shape:getCenterOfMass',
+    'Collider:getInertia'
+  }
 }

+ 6 - 0
api/lovr/physics/Shape/isDestroyed.lua

@@ -10,6 +10,12 @@ return {
       description = 'Whether the Shape has been destroyed.'
     }
   },
+  variants = {
+    {
+      arguments = {},
+      returns = { 'destroyed' }
+    }
+  },
   related = {
     'Shape:destroy',
     'Collider:isDestroyed',

+ 4 - 0
api/lovr/physics/WeldJoint/init.lua

@@ -0,0 +1,4 @@
+return {
+  summary = 'TODO',
+  description = 'TODO'
+}

+ 0 - 3
api/lovr/physics/World/overlapShape.lua

@@ -128,9 +128,6 @@ return {
       returns = { 'collider', 'shape', 'x', 'y', 'z', 'nx', 'ny', 'nz' }
     }
   },
-  example = {
-    -- Show an example of colliding a sphere and getting all the stuff it touches
-  },
   related = {
     'World:shapecast',
     'World:raycast',

+ 2 - 2
api/lovr/physics/World/raycast.lua

@@ -137,7 +137,7 @@ return {
       returns = {}
     },
     {
-      arguments = { 'start', 'end', 'filter', 'callback' },
+      arguments = { 'origin', 'endpoint', 'filter', 'callback' },
       returns = {}
     },
     {
@@ -145,7 +145,7 @@ return {
       returns = { 'collider', 'shape', 'x', 'y', 'z', 'nx', 'ny', 'nz' }
     },
     {
-      arguments = { 'start', 'end', 'filter' },
+      arguments = { 'origin', 'endpoint', 'filter' },
       returns = { 'collider', 'shape', 'x', 'y', 'z', 'nx', 'ny', 'nz' }
     }
   },

+ 2 - 2
api/lovr/physics/World/setCallbacks.lua

@@ -41,8 +41,8 @@ return {
   returns = {},
   variants = {
     {
-      arguments = { 'callbacks' }
-      returns = {},
+      arguments = { 'callbacks' },
+      returns = {}
     }
   }
 }

+ 1 - 1
api/lovr/physics/World/shapecast.lua

@@ -56,7 +56,7 @@ return {
       type = 'Vec3',
       description = 'The position to start at.'
     },
-    endpoint = {
+    destination = {
       type = 'Vec3',
       description = 'The position to move the shape to.'
     },

+ 0 - 4
api/lovr/physics/newWorld.lua

@@ -157,9 +157,5 @@ return {
       arguments = { 'settings' },
       returns = { 'world' }
     }
-  },
-  example = {
-    -- show creating the world with default settings, so you can copy-paste
-    -- maybe another one with a bouncing sphere
   }
 }

+ 8 - 6
api/main.lua

@@ -58,12 +58,13 @@ local function warnIf(cond, ...)
 end
 
 -- Processors
-local function processExample(example)
+local function processExample(example, key)
   if type(example) == 'string' then
     return {
       code = unindent(example)
     }
   else
+    assert(example.code, string.format('%s example is missing code', key))
     example.description = unwrap(example.description)
     example.code = unindent(example.code)
   end
@@ -99,7 +100,7 @@ local function processFunction(path, parent)
   fn.examples = pluralify(fn, 'example')
 
   for k, example in ipairs(fn.examples or {}) do
-    fn.examples[k] = processExample(example)
+    fn.examples[k] = processExample(example, fn.key)
   end
 
   assert(fn.variants, string.format('Function %q is missing variants', fn.key))
@@ -163,6 +164,7 @@ end
 
 local function processObject(path, parent)
   local object = require(path .. '.init')
+  assert(type(object) == 'table', string.format('%s/init.lua did not return a table', path))
 
   object.key = path:match('[^/]+$')
   object.name = object.key
@@ -210,7 +212,7 @@ local function processObject(path, parent)
   end
 
   for k, example in ipairs(object.examples or {}) do
-    object.examples[k] = processExample(example)
+    object.examples[k] = processExample(example, object.key)
   end
 
   track(object)
@@ -236,7 +238,7 @@ local function processModule(path)
 
   module.examples = pluralify(module, 'example')
   for k, example in ipairs(module.examples or {}) do
-    module.examples[k] = processExample(example)
+    module.examples[k] = processExample(example, module.key)
   end
 
   for _, file in ipairs(lovr.filesystem.getDirectoryItems(path)) do
@@ -296,12 +298,12 @@ local function validateFunction(fn)
   for _, variant in ipairs(fn.variants) do
     for _, arg in ipairs(variant.arguments) do
       warnIf(not arg or not arg.name, 'Invalid argument for variant of %s', fn.key)
-      warnIf(not arg.type or (arg.type:match('^[A-Z]') and not lookup[arg.type]), 'Invalid or missing argument type %s in %s', arg.type, fn.key)
+      warnIf(not arg.type or (arg.type:match('^[A-Z]') and not lookup[arg.type]), 'Invalid or missing argument type in %s', fn.key)
     end
 
     for _, ret in ipairs(variant.returns) do
       warnIf(not ret or not ret.name, 'Invalid return for variant of %s', fn.key)
-      warnIf(not ret.type or (ret.type:match('^[A-Z]') and not lookup[ret.type]), 'Invalid or missing return type %s for %s variant', ret.type, fn.key)
+      warnIf(not ret.type or (ret.type:match('^[A-Z]') and not lookup[ret.type]), 'Invalid or missing return type in %s', fn.key)
     end
   end
 

Some files were not shown because too many files changed in this diff