From baf1b9ce6a9238d9669d28bebb5b6b222aad6b97 Mon Sep 17 00:00:00 2001 From: Auke Kok Date: Thu, 23 Apr 2015 22:51:27 -0700 Subject: Configuration - persistent config file This allows a server admin to tweak the mods growth rate, chance and required light level. For convenience I've made 3 sets of "easy", "normal" and "difficult" settings so that it's easy to understand what the difference is and what good starting values are. --- init.lua | 43 +++++++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 10 deletions(-) (limited to 'init.lua') diff --git a/init.lua b/init.lua index 204ee06..1e27f51 100644 --- a/init.lua +++ b/init.lua @@ -10,15 +10,38 @@ of the license, or (at your option) any later version. --]] -crops_interval = 30 -crops_chance = 8 - -dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/melon.lua") -dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/corn.lua") -dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/tomato.lua") -dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/potato.lua") -dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/polebean.lua") - -dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/cooking.lua") +crops = {} + +local worldpath = minetest.get_worldpath() +local modpath = minetest.get_modpath(minetest.get_current_modname()) + +dofile(modpath .. "/crops_settings.txt") + +if io.open(worldpath .. "/crops_settings.txt", "r") == nil then + io.input(modpath .. "/crops_settings.txt") + io.output(worldpath .. "/crops_settings.txt") + + local size = 4096 + while true do + local buf = io.read(size) + if not buf then + io.close() + break + end + io.write(buf) + end +else + dofile(worldpath .. "/crops_settings.txt") +end + +-- crop nodes, crafts, craftitems +dofile(modpath .. "/melon.lua") +dofile(modpath .. "/corn.lua") +dofile(modpath .. "/tomato.lua") +dofile(modpath .. "/potato.lua") +dofile(modpath .. "/polebean.lua") + +-- cooking recipes that mix craftitems +dofile(modpath .. "/cooking.lua") minetest.log("action", "[crops] loaded.") -- cgit v1.2.3