2
0

write.lua 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. return {
  2. tag = 'filesystem-files',
  3. summary = 'Write to a file.',
  4. description = 'Write to a file in the save directory.',
  5. arguments = {
  6. filename = {
  7. type = 'string',
  8. description = 'The file to write to.'
  9. },
  10. content = {
  11. type = 'string',
  12. description = 'A string to write to the file.'
  13. },
  14. blob = {
  15. type = 'Blob',
  16. description = 'A Blob containing data to write to the file.'
  17. }
  18. },
  19. returns = {
  20. success = {
  21. type = 'boolean',
  22. description = 'Whether the write was successful.'
  23. }
  24. },
  25. variants = {
  26. {
  27. arguments = { 'filename', 'content' },
  28. returns = { 'success' }
  29. },
  30. {
  31. arguments = { 'filename', 'blob' },
  32. returns = { 'success' }
  33. }
  34. },
  35. notes = [[
  36. If the file does not exist, it is created.
  37. If the file already has data in it, it will be replaced with the new content.
  38. If the path contains subdirectories, all of the parent directories need to exist first or the
  39. write will fail. Use `lovr.filesystem.createDirectory` to make sure they're created first.
  40. ]],
  41. related = {
  42. 'lovr.filesystem.append',
  43. 'lovr.filesystem.getSaveDirectory',
  44. 'lovr.filesystem.read'
  45. }
  46. }