summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVanessa Ezekowitz <vanessaezekowitz@gmail.com>2013-04-09 00:15:24 -0400
committerVanessa Ezekowitz <vanessaezekowitz@gmail.com>2013-04-09 00:15:24 -0400
commit8a1ebec9513535f6f8f4488599eb7ca5560ead96 (patch)
treeca996ba6f89f1485b04e45e677c8c60de2e70578
parent4184caa64134fae63c31d3699b55dd4c150f3f8a (diff)
Made settings world-specific - look for moretrees_settings.txt in your world
folder. If it isn't found, the mod will create it with the contents of default_settings.txt and then read those default settings and use them. Otherwise, it will read its settings from the world folder.
-rw-r--r--default_settings.txt (renamed from settings.lua)0
-rw-r--r--init.lua36
2 files changed, 29 insertions, 7 deletions
diff --git a/settings.lua b/default_settings.txt
index 766d193..766d193 100644
--- a/settings.lua
+++ b/default_settings.txt
diff --git a/init.lua b/init.lua
index 6773e41..d36baf4 100644
--- a/init.lua
+++ b/init.lua
@@ -18,13 +18,35 @@
moretrees = {}
-dofile(minetest.get_modpath("moretrees").."/settings.lua")
-dofile(minetest.get_modpath("moretrees").."/tree_models.lua")
-dofile(minetest.get_modpath("moretrees").."/biome_defs.lua")
-dofile(minetest.get_modpath("moretrees").."/node_defs.lua")
-dofile(minetest.get_modpath("moretrees").."/saplings.lua")
-dofile(minetest.get_modpath("moretrees").."/crafts.lua")
-dofile(minetest.get_modpath("moretrees").."/leafdecay.lua")
+-- If the config file is not found in the world directory, copy the default
+-- settings to that location and read them in.
+
+local worldpath=minetest.get_worldpath()
+local modpath=minetest.get_modpath("moretrees")
+
+if io.open(worldpath.."/moretrees_settings.txt","r") == nil then
+
+ dofile(modpath.."/default_settings.txt")
+
+ io.input(modpath.."/default_settings.txt")
+ io.output(worldpath.."/moretrees_settings.txt")
+
+ local size = 2^13 -- good buffer size (8K)
+ while true do
+ local block = io.read(size)
+ if not block then break end
+ io.write(block)
+ end
+end
+
+dofile(worldpath.."/moretrees_settings.txt")
+
+dofile(modpath.."/tree_models.lua")
+dofile(modpath.."/biome_defs.lua")
+dofile(modpath.."/node_defs.lua")
+dofile(modpath.."/saplings.lua")
+dofile(modpath.."/crafts.lua")
+dofile(modpath.."/leafdecay.lua")
-- tree spawning setup