options.lua 480 B

1234567891011121314151617181920212223242526
  1. local Options = class()
  2. Options.defaults = {
  3. fullscreen = false,
  4. borderless = true,
  5. windowWidth = 800,
  6. windowHeight = 600,
  7. vsync = false
  8. }
  9. local function safeLoad(file)
  10. local ok, chunk, result
  11. ok, chunk = pcall(love.filesystem.load, file)
  12. if not ok then return nil end
  13. ok, result = pcall(chunk)
  14. if not ok then return nil end
  15. return result
  16. end
  17. function Options:init()
  18. self.data = table.merge(safeLoad('options.lua'), self.defaults)
  19. end
  20. return Options