summaryrefslogtreecommitdiff
path: root/init.lua
diff options
context:
space:
mode:
authorAuke Kok <auke-jan.h.kok@intel.com>2015-04-23 22:51:27 -0700
committerAuke Kok <auke-jan.h.kok@intel.com>2015-04-23 22:51:27 -0700
commitbaf1b9ce6a9238d9669d28bebb5b6b222aad6b97 (patch)
tree021fca8ee782fbe9075eb85106cbcc42848f80e9 /init.lua
parent9e2f05283caa9223af6c069715fe8eeb36f0c496 (diff)
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.
Diffstat (limited to 'init.lua')
-rw-r--r--init.lua43
1 files changed, 33 insertions, 10 deletions
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.")