A rewrite of the node_ownership Minetest mod with many new features. https://content.minetest.net/packages/ShadowNinja/areas/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.2KB

  1. local world_path = minetest.get_worldpath()
  2. areas.config = {}
  3. local function setting(name, tp, default)
  4. local full_name = "areas." .. name
  5. local value
  6. if tp == "bool" then
  7. value = minetest.settings:get_bool(full_name)
  8. default = value == nil and minetest.is_yes(default)
  9. elseif tp == "string" then
  10. value = minetest.settings:get(full_name)
  11. elseif tp == "v3f" then
  12. value = minetest.setting_get_pos(full_name)
  13. default = value == nil and minetest.string_to_pos(default)
  14. elseif tp == "float" or tp == "int" then
  15. value = tonumber(minetest.settings:get(full_name))
  16. local v, other = default:match("^(%S+) (.+)")
  17. default = value == nil and tonumber(other and v or default)
  18. else
  19. error("Cannot parse setting type " .. tp)
  20. end
  21. if value == nil then
  22. value = default
  23. assert(default ~= nil, "Cannot parse default for " .. full_name)
  24. end
  25. --print("add", name, default, value)
  26. areas.config[name] = value
  27. end
  28. local file = io.open(areas.modpath .. "/settingtypes.txt", "r")
  29. for line in file:lines() do
  30. local name, tp, value = line:match("^areas%.(%S+) %(.*%) (%S+) (.*)")
  31. if value then
  32. setting(name, tp, value)
  33. end
  34. end
  35. file:close()
  36. --------------
  37. -- Settings --
  38. --------------
  39. setting("filename", "string", world_path.."/areas.dat")