From 34f61731fa90275d479d8cd76943bc71e816445e Mon Sep 17 00:00:00 2001 From: TenPlus1 Date: Fri, 28 Apr 2017 18:40:57 +0100 Subject: [PATCH] Added farming.conf setting file check --- README.txt | 1 + farming.conf_example | 27 +++++++++++++++ init.lua | 80 +++++++++++++++++++++++++++++++++----------- mapgen.lua | 75 ++++++++++++++++++----------------------- 4 files changed, 121 insertions(+), 62 deletions(-) create mode 100644 farming.conf_example diff --git a/README.txt b/README.txt index 1457192..95c8154 100644 --- a/README.txt +++ b/README.txt @@ -13,6 +13,7 @@ This mod works by adding your new plant to the {growing=1} group and numbering t Changelog: +1.25 - Added check for farming.conf setting file to disable specific crops globally (inside mod folder) or world specific (inside world folder) 1.24 - Added Hemp which can be crafted into fibre, paper, string, rope and oil. 1.23 - Huge code tweak and tidy done and added barley seeds to be found in dry grass, barley can make flour for bread also. 1.22 - Added grape bushes at high climates which can be cultivated into grape vines using trellis (9 sticks). diff --git a/farming.conf_example b/farming.conf_example new file mode 100644 index 0000000..696d007 --- /dev/null +++ b/farming.conf_example @@ -0,0 +1,27 @@ + +--[[ + Farming settings can be changed here and kept inside mod folder + even after the mod has been updated, or you can place inside + world folder for map specific settings. +--]] + +-- true to enable crop/food in-game and on mapgen +farming.carrot = true +farming.potato = true +farming.tomato = true +farming.cucumber = true +farming.corn = true +farming.coffee = true +farming.coffee = true +farming.melon = true +farming.sugar = true +farming.pumpkin = true +farming.cocoa = true +farming.raspberry = true +farming.blueberry = true +farming.rhubarb = true +farming.beans = true +farming.grapes = true +farming.barley = true +farming.hemp = true +farming.donuts = true diff --git a/init.lua b/init.lua index 1a5eb8b..3380f6e 100644 --- a/init.lua +++ b/init.lua @@ -1,5 +1,5 @@ --[[ - Minetest Farming Redo Mod 1.24 (8th April 2017) + Minetest Farming Redo Mod 1.24 (28th April 2017) by TenPlus1 NEW growing routine by prestidigitator auto-refill by crabman77 @@ -689,31 +689,71 @@ farming.register_plant = function(name, def) return r end --- load crops +-- default settings +farming.carrot = true +farming.potato = true +farming.tomato = true +farming.cucumber = true +farming.corn = true +farming.coffee = true +farming.coffee = true +farming.melon = true +farming.sugar = true +farming.pumpkin = true +farming.cocoa = true +farming.raspberry = true +farming.blueberry = true +farming.rhubarb = true +farming.beans = true +farming.grapes = true +farming.barley = true +farming.hemp = true +farming.donuts = true + + +-- Load new global settings if found inside mod folder +local input = io.open(farming.path.."/farming.conf", "r") +if input then + dofile(farming.path .. "/farming.conf") + input:close() + input = nil +end + +-- load new world-specific settings if found inside world folder +local worldpath = minetest.get_worldpath() +local input = io.open(worldpath.."/farming.conf", "r") +if input then + dofile(worldpath .. "/farming.conf") + input:close() + input = nil +end + + +-- load crops dofile(farming.path.."/soil.lua") dofile(farming.path.."/hoes.lua") dofile(farming.path.."/grass.lua") dofile(farming.path.."/wheat.lua") dofile(farming.path.."/cotton.lua") -dofile(farming.path.."/carrot.lua") -dofile(farming.path.."/potato.lua") -dofile(farming.path.."/tomato.lua") -dofile(farming.path.."/cucumber.lua") -dofile(farming.path.."/corn.lua") -dofile(farming.path.."/coffee.lua") -dofile(farming.path.."/melon.lua") -dofile(farming.path.."/sugar.lua") -dofile(farming.path.."/pumpkin.lua") -dofile(farming.path.."/cocoa.lua") -dofile(farming.path.."/raspberry.lua") -dofile(farming.path.."/blueberry.lua") -dofile(farming.path.."/rhubarb.lua") -dofile(farming.path.."/beanpole.lua") -dofile(farming.path.."/grapes.lua") -dofile(farming.path.."/barley.lua") -dofile(farming.path.."/hemp.lua") -dofile(farming.path.."/donut.lua") +if farming.carrot then dofile(farming.path.."/carrot.lua") end +if farming.potato then dofile(farming.path.."/potato.lua") end +if farming.tomato then dofile(farming.path.."/tomato.lua") end +if farming.cucumber then dofile(farming.path.."/cucumber.lua") end +if farming.corn then dofile(farming.path.."/corn.lua") end +if farming.coffee then dofile(farming.path.."/coffee.lua") end +if farming.melon then dofile(farming.path.."/melon.lua") end +if farming.sugar then dofile(farming.path.."/sugar.lua") end +if farming.pumpkin then dofile(farming.path.."/pumpkin.lua") end +if farming.cocoa then dofile(farming.path.."/cocoa.lua") end +if farming.raspberry then dofile(farming.path.."/raspberry.lua") end +if farming.blueberry then dofile(farming.path.."/blueberry.lua") end +if farming.rhubarb then dofile(farming.path.."/rhubarb.lua") end +if farming.beans then dofile(farming.path.."/beanpole.lua") end +if farming.grapes then dofile(farming.path.."/grapes.lua") end +if farming.barley then dofile(farming.path.."/barley.lua") end +if farming.hemp then dofile(farming.path.."/hemp.lua") end +if farming.donuts then dofile(farming.path.."/donut.lua") end dofile(farming.path.."/mapgen.lua") dofile(farming.path.."/compatibility.lua") -- Farming Plus compatibility dofile(farming.path.."/lucky_block.lua") diff --git a/mapgen.lua b/mapgen.lua index 59a485e..090c193 100644 --- a/mapgen.lua +++ b/mapgen.lua @@ -1,5 +1,11 @@ + -- decoration function -local function register_plant(name, min, max, spawnby, num) +local function register_plant(name, min, max, spawnby, num, enabled) + + if enabled ~= true then + return + end + minetest.register_decoration({ deco_type = "simple", place_on = {"default:dirt_with_grass"}, @@ -20,41 +26,34 @@ local function register_plant(name, min, max, spawnby, num) }) end -function farming.register_mgv6_decorations() - register_plant("potato_3", 15, 40, "", -1) - register_plant("tomato_7", 5, 20, "", -1) - register_plant("carrot_8", 1, 30, "group:water", 1) - register_plant("cucumber_4", 1, 20, "group:water", 1) - register_plant("corn_7", 12, 22, "", -1) - register_plant("corn_8", 10, 20, "", -1) - register_plant("coffee_5", 20, 45, "", -1) - register_plant("melon_8", 1, 20, "group:water", 1) - register_plant("pumpkin_8", 1, 20, "group:water", 1) - register_plant("raspberry_4", 3, 10, "", -1) - register_plant("rhubarb_3", 3, 15, "", -1) - register_plant("blueberry_4", 3, 10, "", -1) - register_plant("beanbush", 18, 35, "", -1) - register_plant("grapebush", 25, 45, "", -1) -end - --- v7 maps have a beach so plants growing near water is limited to 6 high -function farming.register_mgv7_decorations() - register_plant("potato_3", 15, 40, "", -1) - register_plant("tomato_7", 5, 20, "", -1) - register_plant("carrot_8", 1, 6, "", -1) - register_plant("cucumber_4", 1, 6, "", -1) - register_plant("corn_7", 12, 22, "", -1) - register_plant("corn_8", 10, 20, "", -1) - register_plant("coffee_5", 20, 45, "", -1) - register_plant("melon_8", 1, 6, "", -1) - register_plant("pumpkin_8", 1, 6, "", -1) - register_plant("raspberry_4", 3, 10, "", -1) - register_plant("rhubarb_3", 3, 15, "", -1) - register_plant("blueberry_4", 3, 10, "", -1) - register_plant("beanbush", 18, 35, "", -1) - register_plant("grapebush", 25, 45, "", -1) + +-- add crops to mapgen +register_plant("potato_3", 15, 40, "", -1, farming.potato) +register_plant("tomato_7", 5, 20, "", -1, farming.tomato) +register_plant("corn_7", 12, 22, "", -1, farming.corn) +register_plant("coffee_5", 20, 45, "", -1, farming.coffee) +register_plant("raspberry_4", 3, 10, "", -1, farming.raspberry) +register_plant("rhubarb_3", 3, 15, "", -1, farming.rhubarb) +register_plant("blueberry_4", 3, 10, "", -1, farming.blueberry) +register_plant("beanbush", 18, 35, "", -1, farming.beans) +register_plant("grapebush", 25, 45, "", -1, farming.grapes) + + +if minetest.get_mapgen_params().mgname == "v6" then + + register_plant("carrot_8", 1, 30, "group:water", 1, farming.carrot) + register_plant("cucumber_4", 1, 20, "group:water", 1, farming.cucumber) + register_plant("melon_8", 1, 20, "group:water", 1, farming.melon) + register_plant("pumpkin_8", 1, 20, "group:water", 1, farming.pumpkin) +else + -- v7 maps have a beach so plants growing near water is limited to 6 high + register_plant("carrot_8", 1, 6, "", -1, farming.carrot) + register_plant("cucumber_4", 1, 6, "", -1, farming.cucumber) + register_plant("melon_8", 1, 6, "", -1, farming.melon) + register_plant("pumpkin_8", 1, 6, "", -1, farming.pumpkin) end +if farming.hemp then minetest.register_decoration({ deco_type = "simple", place_on = {"default:dirt_with_grass", "default:dirt_with_rainforest_litter"}, @@ -73,12 +72,4 @@ minetest.register_decoration({ spawn_by = "group:tree", num_spawn_by = 1, }) - --- detect mapgen -local mg_name = minetest.get_mapgen_params().mgname - -if mg_name == "v6" then - farming.register_mgv6_decorations() -else - farming.register_mgv7_decorations() end