1
0
mirror of https://github.com/mt-mods/pipeworks.git synced 2024-12-24 18:00:22 +01:00

always read default_settings.txt before reading the world-folder's settings file

also close the file after copying.
This commit is contained in:
Vanessa Ezekowitz 2013-08-05 04:36:50 -04:00
parent 10d49abb2b
commit 6323a923e0

View File

@ -6,22 +6,25 @@
-- 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")
if io.open(worldpath.."/pipeworks_settings.txt","r") == nil then
io.input(modpath.."/default_settings.txt")
io.output(worldpath.."/pipeworks_settings.txt")
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