saver.lua 415 B

12345678910111213141516171819
  1. local Saver = class()
  2. function Saver:keypressed(key)
  3. if key == 's' and love.keyboard.isDown('lctrl') then
  4. self:save()
  5. end
  6. end
  7. function Saver:save()
  8. local str = 'return {'
  9. table.each(ctx.map.props, function(p)
  10. str = str .. p
  11. end)
  12. str = str .. '}'
  13. love.filesystem.createDirectory('maps/' .. ctx.map.code)
  14. love.filesystem.write('maps/' .. ctx.map.code .. '/props.lua', str)
  15. end
  16. return Saver