summaryrefslogtreecommitdiff
path: root/init.lua
diff options
context:
space:
mode:
authorVanessa Ezekowitz <vanessaezekowitz@gmail.com>2013-08-05 04:58:08 -0400
committerVanessa Ezekowitz <vanessaezekowitz@gmail.com>2013-08-05 04:58:08 -0400
commitdbf775808a63013ef7fd45faadab7f4d289c44a4 (patch)
tree2f2b5a46f9c2f37e16a563f0e002e19f55fd8063 /init.lua
parentd32993e355355d196fb40a9b2bc2305486084e81 (diff)
always read default_settings.txt before reading the world-folder's settings file
also close the file after copying.
Diffstat (limited to 'init.lua')
-rw-r--r--init.lua12
1 files changed, 7 insertions, 5 deletions
diff --git a/init.lua b/init.lua
index c0a2aaa..39fd4ab 100644
--- a/init.lua
+++ b/init.lua
@@ -18,15 +18,14 @@
moretrees = {}
--- If the config file is not found in the world directory, copy the default
--- settings to that location and read them in.
+-- Read the default config file (and if necessary, copy it to the world folder).
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")
- dofile(modpath.."/default_settings.txt")
+if io.open(worldpath.."/moretrees_settings.txt","r") == nil then
io.input(modpath.."/default_settings.txt")
io.output(worldpath.."/moretrees_settings.txt")
@@ -34,7 +33,10 @@ if io.open(worldpath.."/moretrees_settings.txt","r") == nil then
local size = 2^13 -- good buffer size (8K)
while true do
local block = io.read(size)
- if not block then break end
+ if not block then
+ io.close()
+ break
+ end
io.write(block)
end