load.lua 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. return {
  2. tag = 'callbacks',
  3. summary = 'Called once at startup.',
  4. description = [[
  5. This callback is called once when the app starts. It should be used to perform initial setup
  6. work, like loading resources and initializing classes and variables.
  7. ]],
  8. arguments = {
  9. {
  10. name = 'arg',
  11. type = 'table',
  12. description = 'The command line arguments provided to the program.'
  13. }
  14. },
  15. returns = {},
  16. example = [[
  17. function lovr.load(arg)
  18. model = lovr.graphics.newModel('sponza.gltf')
  19. texture = lovr.graphics.newTexture('cena.png')
  20. effects = lovr.graphics.newShader('vert.glsl', 'frag.glsl')
  21. loadLevel(1)
  22. end
  23. ]],
  24. notes = [[
  25. If the project was loaded from a restart using `lovr.event.restart`, the return value from the
  26. previously-run `lovr.restart` callback will be made available to this callback as the `restart`
  27. key in the `arg` table.
  28. The `arg` table follows the [Lua
  29. standard](https://en.wikibooks.org/wiki/Lua_Programming/command_line_parameter). The arguments
  30. passed in from the shell are put into a global table named `arg` and passed to `lovr.load`, but
  31. with indices offset such that the "script" (the project path) is at index 0. So all arguments
  32. (if any) intended for the project are at successive indices starting with 1, and the executable
  33. and its "internal" arguments are in normal order but stored in negative indices.
  34. ]],
  35. related = {
  36. 'lovr.quit'
  37. }
  38. }