From 187015e0733e5e0bfa5efba215319c7d9d86f072 Mon Sep 17 00:00:00 2001 From: ShadowNinja <noreply@gmail.com> Date: Sat, 13 Jul 2013 01:23:29 +0200 Subject: [PATCH] Fix coding style of nuclear reactor --- technic/config.lua | 51 ++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 42 insertions(+), 9 deletions(-) diff --git a/technic/config.lua b/technic/config.lua index c921981..f546cf6 100644 --- a/technic/config.lua +++ b/technic/config.lua @@ -1,9 +1,42 @@ -enable_item_drop=false -enable_item_pickup=true -enable_technic_inventory=true -enable_mining_drill=true -enable_mining_laser=true -enable_flashlight=true -enable_rubber_tree_generation=true -enable_marble_generation=true -enable_granite_generation=true +technic.config = {} + +technic.config.loaded = {} + +technic.config.default = { + enable_mining_drill = "true", + enable_mining_laser = "true", + enable_flashlight = "true", + enable_item_drop = "true", + enable_item_pickup = "true", + enable_rubber_tree_generation = "true", + enable_marble_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] + end +end + +function technic.config:getBool(setting) + return string.lower(self:get(setting)) == "true" +end -- Gitblit v1.8.0