settings.lua 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. ---@meta
  2. ---Settings
  3. -----------
  4. -- Settings constructor.
  5. ---@param filename string
  6. ---@return mt.Settings
  7. function Settings(filename) end
  8. -- An interface to read config files in the format of `minetest.conf`.
  9. --
  10. -- It can be created via `Settings(filename)`.
  11. ---@class mt.Settings
  12. local SettingsClass
  13. -- Returns a value.
  14. ---@param key any
  15. ---@return any value
  16. function SettingsClass:get(key) end
  17. -- Returns `nil` if `key` is not found and `default` not specified.
  18. ---@param key any
  19. ---@param default any|nil The value returned if `key` is not found.
  20. ---@return boolean|nil
  21. function SettingsClass:get_bool(key, default) end
  22. ---@return mt.NoiseParams
  23. function SettingsClass:get_np_group(key) end
  24. -- Is currently limited to mapgen flags `mg_flags` and mapgen-specific flags
  25. -- like `mgv5_spflags`.
  26. ---@return mt.OreFlagsTable
  27. function SettingsClass:get_flags(key) end
  28. -- - Setting names can't contain whitespace or any of `="{}#`.
  29. -- - Setting values can't contain the sequence `\n"""`.
  30. -- - Setting names starting with "secure." can't be set on the main settings
  31. -- object (`minetest.settings`).
  32. ---@param key string
  33. ---@param value any
  34. function SettingsClass:set(key, value) end
  35. -- - Setting names can't contain whitespace or any of `="{}#`.
  36. -- - Setting values can't contain the sequence `\n"""`.
  37. -- - Setting names starting with "secure." can't be set on the main settings
  38. -- object (`minetest.settings`).
  39. ---@param key string
  40. ---@param value boolean
  41. function SettingsClass:set_bool(key, value) end
  42. -- - Setting names can't contain whitespace or any of `="{}#`.
  43. -- - Setting values can't contain the sequence `\n"""`.
  44. -- - Setting names starting with "secure." can't be set on the main settings
  45. -- object (`minetest.settings`).
  46. ---@param key string
  47. ---@param value mt.NoiseParams
  48. function SettingsClass:set_np_group(key, value) end
  49. -- Returns a boolean (`true` for success).
  50. ---@param key string
  51. ---@return boolean
  52. function SettingsClass:remove(key) end
  53. ---@return string[]
  54. function SettingsClass:get_names() end
  55. -- Writes changes to file.
  56. --
  57. -- Returns a boolean (`true` for success).
  58. ---@return boolean
  59. function SettingsClass:write() end
  60. ---@return mt.SettingsTable
  61. function SettingsClass:to_table() end
  62. --[[
  63. The settings have the format `key = value`. Example:
  64. foo = example text
  65. bar = """
  66. Multiline
  67. value
  68. """
  69. ]]
  70. ---@class mt.SettingsTable