commit | author | age
|
8e03d7
|
1 |
technic.config = {} |
R |
2 |
|
|
3 |
technic.config.loaded = {} |
|
4 |
|
|
5 |
technic.config.default = { |
|
6 |
enable_mining_drill = "true", |
|
7 |
enable_mining_laser = "true", |
|
8 |
enable_flashlight = "true", |
|
9 |
enable_item_drop = "true", |
|
10 |
enable_item_pickup = "true", |
|
11 |
enable_rubber_tree_generation = "true", |
|
12 |
enable_marble_generation = "true", |
|
13 |
enable_granite_generation = "true" |
|
14 |
} |
|
15 |
|
|
16 |
function technic.config:load(filename) |
|
17 |
file, error = io.open(filename, "r") |
|
18 |
if error then return end |
|
19 |
local line = file:read("*l") |
|
20 |
while line do |
|
21 |
local found, _, setting, value = line:find("^([^#%s=]+)%s?=%s?([^%s#]+)") |
|
22 |
if found then |
|
23 |
self.loaded[setting] = value |
|
24 |
end |
|
25 |
line = file:read("*l") |
|
26 |
end |
|
27 |
file:close() |
|
28 |
end |
|
29 |
|
|
30 |
technic.config:load(minetest.get_worldpath().."/technic.conf") |
|
31 |
|
|
32 |
function technic.config:get(setting) |
|
33 |
if self.loaded[setting] then |
|
34 |
return self.loaded[setting] |
|
35 |
else |
|
36 |
return self.default[setting] |
|
37 |
end |
|
38 |
end |
|
39 |
|
|
40 |
function technic.config:getBool(setting) |
|
41 |
return string.lower(self:get(setting)) == "true" |
|
42 |
end |