load.lua 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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 = 'args',
  11. type = 'table',
  12. description = 'The command line arguments provided to the program.'
  13. }
  14. },
  15. returns = {},
  16. example = [[
  17. function lovr.load(args)
  18. model = lovr.graphics.newModel('cena.gltf')
  19. texture = lovr.graphics.newTexture('cena.png')
  20. levelGeometry = lovr.graphics.newMesh(1000)
  21. effects = lovr.graphics.newShader('vert.glsl', 'frag.glsl')
  22. loadLevel(1)
  23. end
  24. ]],
  25. notes = [[
  26. If the project was loaded from a restart using `lovr.event.restart`, the return value from the
  27. previously-run `lovr.restart` callback will be made available to this callback as the `restart`
  28. key in the `args` table.
  29. The `args` table follows the [Lua
  30. standard](https://en.wikibooks.org/wiki/Lua_Programming/command_line_parameter). The arguments
  31. passed in from the shell are put into a global table named `arg` and passed to `lovr.load`, but
  32. with indices offset such that the "script" (the project path) is at index 0. So all arguments
  33. (if any) intended for the project are at successive indices starting with 1, and the executable
  34. and its "internal" arguments are in normal order but stored in negative indices.
  35. ]],
  36. related = {
  37. 'lovr.quit'
  38. }
  39. }