From ee0765804c0a21deeb2f33c22ac1a36cb0db5f43 Mon Sep 17 00:00:00 2001
From: ShadowNinja <noreply@gmail.com>
Date: Tue, 17 Sep 2013 22:37:56 +0200
Subject: [PATCH] Partial rewrite

---
 technic/config.lua |   38 ++++++++++----------------------------
 1 files changed, 10 insertions(+), 28 deletions(-)

diff --git a/technic/config.lua b/technic/config.lua
index f546cf6..159302f 100644
--- a/technic/config.lua
+++ b/technic/config.lua
@@ -1,8 +1,11 @@
-technic.config = {}
 
-technic.config.loaded = {}
+local worldpath = minetest.get_worldpath()
 
-technic.config.default = {
+technic.config = Settings(worldpath.."/technic.conf")
+
+local conf_table = technic.config:to_table()
+
+local defaults = {
 	enable_mining_drill = "true",
 	enable_mining_laser = "true",
 	enable_flashlight = "true",
@@ -10,33 +13,12 @@
 	enable_item_pickup = "true",
 	enable_rubber_tree_generation = "true",
 	enable_marble_generation = "true",
-	enable_granite_generation = "true"
+	enable_granite_generation = "true",
 }
 
-function technic.config:load(filename)
-	file, error = io.open(filename, "r")
-	if error then return end
-	local line = file:read("*l")
-	while line do
-		local found, _, setting, value = line:find("^([^#%s=]+)%s?=%s?([^%s#]+)")
-		if found then
-			self.loaded[setting] = value
-		end
-		line = file:read("*l")
-	end
-	file:close()
-end
-
-technic.config:load(minetest.get_worldpath().."/technic.conf")
-
-function technic.config:get(setting)
-	if self.loaded[setting] then
-		return self.loaded[setting]
-	else
-		return self.default[setting]
+for k, v in pairs(defaults) do
+	if conf_table[k] == nil then
+		technic.config:set(k, v)
 	end
 end
 
-function technic.config:getBool(setting)
-	return string.lower(self:get(setting)) == "true"
-end

--
Gitblit v1.8.0