settings.lua 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. local world_path = minetest.get_worldpath()
  2. areas.config = {}
  3. local function setting(tp, name, default)
  4. local full_name = "areas."..name
  5. local value
  6. if tp == "boolean" then
  7. value = minetest.settings:get_bool(full_name)
  8. elseif tp == "string" then
  9. value = minetest.settings:get(full_name)
  10. elseif tp == "position" then
  11. value = minetest.setting_get_pos(full_name)
  12. elseif tp == "number" then
  13. value = tonumber(minetest.settings:get(full_name))
  14. else
  15. error("Invalid setting type!")
  16. end
  17. if value == nil then
  18. value = default
  19. end
  20. areas.config[name] = value
  21. end
  22. --------------
  23. -- Settings --
  24. --------------
  25. setting("string", "filename", world_path.."/areas.dat")
  26. -- Allow players with a privilege create their own areas
  27. -- within the maximum size and number.
  28. setting("boolean", "self_protection", true)
  29. setting("string", "self_protection_privilege", "interact")
  30. setting("position", "self_protection_max_size", {x=64, y=128, z=64})
  31. setting("number", "self_protection_max_areas", 4)
  32. -- For players with the areas_high_limit privilege.
  33. setting("position", "self_protection_max_size_high", {x=512, y=512, z=512})
  34. setting("number", "self_protection_max_areas_high", 32)
  35. -- legacy_table (owner_defs) compatibility. Untested and has known issues.
  36. setting("boolean", "legacy_table", false)