Added farming.conf setting file check

This commit is contained in:
TenPlus1 2017-04-28 18:40:57 +01:00
parent bd3ac972e7
commit 34f61731fa
4 changed files with 121 additions and 62 deletions

View File

@ -13,6 +13,7 @@ This mod works by adding your new plant to the {growing=1} group and numbering t
Changelog: 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.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.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). 1.22 - Added grape bushes at high climates which can be cultivated into grape vines using trellis (9 sticks).

27
farming.conf_example Normal file
View File

@ -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

View File

@ -1,5 +1,5 @@
--[[ --[[
Minetest Farming Redo Mod 1.24 (8th April 2017) Minetest Farming Redo Mod 1.24 (28th April 2017)
by TenPlus1 by TenPlus1
NEW growing routine by prestidigitator NEW growing routine by prestidigitator
auto-refill by crabman77 auto-refill by crabman77
@ -689,31 +689,71 @@ farming.register_plant = function(name, def)
return r return r
end 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.."/soil.lua")
dofile(farming.path.."/hoes.lua") dofile(farming.path.."/hoes.lua")
dofile(farming.path.."/grass.lua") dofile(farming.path.."/grass.lua")
dofile(farming.path.."/wheat.lua") dofile(farming.path.."/wheat.lua")
dofile(farming.path.."/cotton.lua") dofile(farming.path.."/cotton.lua")
dofile(farming.path.."/carrot.lua") if farming.carrot then dofile(farming.path.."/carrot.lua") end
dofile(farming.path.."/potato.lua") if farming.potato then dofile(farming.path.."/potato.lua") end
dofile(farming.path.."/tomato.lua") if farming.tomato then dofile(farming.path.."/tomato.lua") end
dofile(farming.path.."/cucumber.lua") if farming.cucumber then dofile(farming.path.."/cucumber.lua") end
dofile(farming.path.."/corn.lua") if farming.corn then dofile(farming.path.."/corn.lua") end
dofile(farming.path.."/coffee.lua") if farming.coffee then dofile(farming.path.."/coffee.lua") end
dofile(farming.path.."/melon.lua") if farming.melon then dofile(farming.path.."/melon.lua") end
dofile(farming.path.."/sugar.lua") if farming.sugar then dofile(farming.path.."/sugar.lua") end
dofile(farming.path.."/pumpkin.lua") if farming.pumpkin then dofile(farming.path.."/pumpkin.lua") end
dofile(farming.path.."/cocoa.lua") if farming.cocoa then dofile(farming.path.."/cocoa.lua") end
dofile(farming.path.."/raspberry.lua") if farming.raspberry then dofile(farming.path.."/raspberry.lua") end
dofile(farming.path.."/blueberry.lua") if farming.blueberry then dofile(farming.path.."/blueberry.lua") end
dofile(farming.path.."/rhubarb.lua") if farming.rhubarb then dofile(farming.path.."/rhubarb.lua") end
dofile(farming.path.."/beanpole.lua") if farming.beans then dofile(farming.path.."/beanpole.lua") end
dofile(farming.path.."/grapes.lua") if farming.grapes then dofile(farming.path.."/grapes.lua") end
dofile(farming.path.."/barley.lua") if farming.barley then dofile(farming.path.."/barley.lua") end
dofile(farming.path.."/hemp.lua") if farming.hemp then dofile(farming.path.."/hemp.lua") end
dofile(farming.path.."/donut.lua") if farming.donuts then dofile(farming.path.."/donut.lua") end
dofile(farming.path.."/mapgen.lua") dofile(farming.path.."/mapgen.lua")
dofile(farming.path.."/compatibility.lua") -- Farming Plus compatibility dofile(farming.path.."/compatibility.lua") -- Farming Plus compatibility
dofile(farming.path.."/lucky_block.lua") dofile(farming.path.."/lucky_block.lua")

View File

@ -1,5 +1,11 @@
-- decoration function -- 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({ minetest.register_decoration({
deco_type = "simple", deco_type = "simple",
place_on = {"default:dirt_with_grass"}, place_on = {"default:dirt_with_grass"},
@ -20,41 +26,34 @@ local function register_plant(name, min, max, spawnby, num)
}) })
end end
function farming.register_mgv6_decorations()
register_plant("potato_3", 15, 40, "", -1) -- add crops to mapgen
register_plant("tomato_7", 5, 20, "", -1) register_plant("potato_3", 15, 40, "", -1, farming.potato)
register_plant("carrot_8", 1, 30, "group:water", 1) register_plant("tomato_7", 5, 20, "", -1, farming.tomato)
register_plant("cucumber_4", 1, 20, "group:water", 1) register_plant("corn_7", 12, 22, "", -1, farming.corn)
register_plant("corn_7", 12, 22, "", -1) register_plant("coffee_5", 20, 45, "", -1, farming.coffee)
register_plant("corn_8", 10, 20, "", -1) register_plant("raspberry_4", 3, 10, "", -1, farming.raspberry)
register_plant("coffee_5", 20, 45, "", -1) register_plant("rhubarb_3", 3, 15, "", -1, farming.rhubarb)
register_plant("melon_8", 1, 20, "group:water", 1) register_plant("blueberry_4", 3, 10, "", -1, farming.blueberry)
register_plant("pumpkin_8", 1, 20, "group:water", 1) register_plant("beanbush", 18, 35, "", -1, farming.beans)
register_plant("raspberry_4", 3, 10, "", -1) register_plant("grapebush", 25, 45, "", -1, farming.grapes)
register_plant("rhubarb_3", 3, 15, "", -1)
register_plant("blueberry_4", 3, 10, "", -1)
register_plant("beanbush", 18, 35, "", -1) if minetest.get_mapgen_params().mgname == "v6" then
register_plant("grapebush", 25, 45, "", -1)
end register_plant("carrot_8", 1, 30, "group:water", 1, farming.carrot)
register_plant("cucumber_4", 1, 20, "group:water", 1, farming.cucumber)
-- v7 maps have a beach so plants growing near water is limited to 6 high register_plant("melon_8", 1, 20, "group:water", 1, farming.melon)
function farming.register_mgv7_decorations() register_plant("pumpkin_8", 1, 20, "group:water", 1, farming.pumpkin)
register_plant("potato_3", 15, 40, "", -1) else
register_plant("tomato_7", 5, 20, "", -1) -- v7 maps have a beach so plants growing near water is limited to 6 high
register_plant("carrot_8", 1, 6, "", -1) register_plant("carrot_8", 1, 6, "", -1, farming.carrot)
register_plant("cucumber_4", 1, 6, "", -1) register_plant("cucumber_4", 1, 6, "", -1, farming.cucumber)
register_plant("corn_7", 12, 22, "", -1) register_plant("melon_8", 1, 6, "", -1, farming.melon)
register_plant("corn_8", 10, 20, "", -1) register_plant("pumpkin_8", 1, 6, "", -1, farming.pumpkin)
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)
end end
if farming.hemp then
minetest.register_decoration({ minetest.register_decoration({
deco_type = "simple", deco_type = "simple",
place_on = {"default:dirt_with_grass", "default:dirt_with_rainforest_litter"}, place_on = {"default:dirt_with_grass", "default:dirt_with_rainforest_litter"},
@ -73,12 +72,4 @@ minetest.register_decoration({
spawn_by = "group:tree", spawn_by = "group:tree",
num_spawn_by = 1, 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 end