diff options
Diffstat (limited to 'init.lua')
-rw-r--r-- | init.lua | 46 |
1 files changed, 33 insertions, 13 deletions
@@ -18,23 +18,43 @@ moretrees = {} -dofile(minetest.get_modpath("moretrees").."/settings.lua") -dofile(minetest.get_modpath("moretrees").."/node_defs.lua") -dofile(minetest.get_modpath("moretrees").."/tree_models.lua") -dofile(minetest.get_modpath("moretrees").."/biome_defs.lua") -dofile(minetest.get_modpath("moretrees").."/crafts.lua") -dofile(minetest.get_modpath("moretrees").."/leafdecay.lua") -dofile(minetest.get_modpath("moretrees").."/saplings.lua") - -if moretrees.enable_replace_default_trees then - minetest.register_alias("mapgen_tree", "air") - minetest.register_alias("mapgen_leaves", "air") - minetest.register_alias("mapgen_apple", "air") - plantslib:register_generate_plant(moretrees.beech_biome, moretrees.beech_model) +-- 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 + +else + dofile(worldpath.."/moretrees_settings.txt") end +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 +if moretrees.enable_beech then + plantslib:register_generate_plant(moretrees.beech_biome, moretrees.beech_model) +end + if moretrees.enable_apple_tree then plantslib:register_generate_plant(moretrees.apple_tree_biome, moretrees.apple_tree_model) end |