summaryrefslogtreecommitdiff
path: root/init.lua
diff options
context:
space:
mode:
authorVanessa Ezekowitz <vanessaezekowitz@gmail.com>2013-08-05 04:36:50 -0400
committerVanessa Ezekowitz <vanessaezekowitz@gmail.com>2013-08-05 04:36:50 -0400
commit6323a923e0cfa76f2bc958429f790a8f2e35b4c6 (patch)
treee36f14470403919e1a5d2fe3b8af0566f34ea52a /init.lua
parent10d49abb2b151ea73c1474133d6f8a51528274aa (diff)
downloadpipeworks-6323a923e0cfa76f2bc958429f790a8f2e35b4c6.tar
pipeworks-6323a923e0cfa76f2bc958429f790a8f2e35b4c6.tar.gz
pipeworks-6323a923e0cfa76f2bc958429f790a8f2e35b4c6.tar.bz2
pipeworks-6323a923e0cfa76f2bc958429f790a8f2e35b4c6.tar.xz
pipeworks-6323a923e0cfa76f2bc958429f790a8f2e35b4c6.zip
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.lua11
1 files changed, 7 insertions, 4 deletions
diff --git a/init.lua b/init.lua
index 020db12..306f64c 100644
--- a/init.lua
+++ b/init.lua
@@ -6,14 +6,14 @@
-- License: WTFPL
--
--- Copy and/or read the config file
+-- Read (and if necessary, copy) the config file
local worldpath = minetest.get_worldpath()
local modpath = minetest.get_modpath("pipeworks")
-if io.open(worldpath.."/pipeworks_settings.txt","r") == nil then
+dofile(modpath.."/default_settings.txt")
- dofile(modpath.."/default_settings.txt")
+if io.open(worldpath.."/pipeworks_settings.txt","r") == nil then
io.input(modpath.."/default_settings.txt")
io.output(worldpath.."/pipeworks_settings.txt")
@@ -21,7 +21,10 @@ if io.open(worldpath.."/pipeworks_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