correction of infects #4 ; new crops #1 #2 #3

master
ademant 2018-10-08 14:55:32 +02:00
parent a6e9b2a75a
commit 56f2334fe4
27 changed files with 521 additions and 184 deletions

View File

@ -5,7 +5,7 @@
world folder for map specific settings.
--]]
farming.crops = {"wheat","strawberry","potato"}
farming.crops = {"wheat","strawberry","potato","barley","blackberry","corn","coffee","raspberry","cocoa","spelt","mustard","cotton","tomato"}
for i,crop in ipairs(farming.crops) do
print(crop.." - "..farming.config:get_string(crop))
@ -53,6 +53,7 @@ for name,def in pairs(minetest.registered_biomes) do
table.insert(farming.possible_biomes,1,name)
end
end
--print(table.maxn(farming.possible_biomes))
-- register for crops, which are spreading by abm
farming.spreading_crops = {}

View File

@ -1,3 +1,4 @@
local S = farming.intllib
-- Barley
farming.register_plant("farming:barley", {
@ -5,18 +6,34 @@ farming.register_plant("farming:barley", {
paramtype2 = "meshoptions",
inventory_image = "farming_barley_seed.png",
steps = 7,
switch_drop_count = 5, -- at which stage more harvest
minlight = 13,
maxlight = default.LIGHT_MAX,
fertility = {"grassland"},
groups = {food_wheat = 1, flammable = 4},
groups = {food_wheat=1, grain = 1, flammable = 4, on_soil = 1,snappy=1,food=1,infectable=1},
place_param2 = 3,
min_temp=10,
max_temp=50,
min_humidity=10,
max_humidity=70,
spawnon = { spawnon = farming.change_soil or {"default:dirt_with_grass"},
spawn_min = 0,
spawn_max = 42,
spawnby = nil,
scale = 0.006, -- 0.006
spawn_num = -1}
spawn_num = -1},
eat_hp=1,
infect = {
base_rate = 10,
mono_rate = 5,
infect_rate = 5,
intervall = 50,
},
spread = {spreadon = farming.change_soil or {"default:dirt_with_grass"},
base_rate = 10,
spread = 5,
intervall = 12,
change = 0.0001, --part of soil, which get plants
},
max_harvest=2,
})

40
crops/beetroot.lua Normal file
View File

@ -0,0 +1,40 @@
-- Beetroot
local po_def={
description = "Beetroot",
paramtype2 = "meshoptions",
inventory_image = "farming_beetroot.png",
steps = 8,
max_harvest=4,
minlight = 13,
maxlight = default.LIGHT_MAX,
fertility = {"grassland"},
groups = {food_wheat = 1, flammable = 4,no_harvest=1, on_soil = 1,snappy=1,food=1},
place_param2 = 3,
spawnon = { spawnon = farming.change_soil or {"default:dirt_with_grass"},
spawn_min = 10,
spawn_max = 100,
spawnby = nil,
scale = 0.006, -- 0.006
spawn_num = -1},
infect = {
base_rate = 10,
mono_rate = 5,
infect_rate = 5,
intervall = 50,
},
spread = {spreadon = farming.change_soil or {"default:dirt_with_grass"},
base_rate = 10,
spread = 5,
intervall = 12,
change = 0.0001, --part of soil, which get plants
},
min_temp=10,
max_temp=50,
min_humidity=10,
max_humidity=70,
}
farming.register_plant("farming:beetroot", po_def)

View File

@ -1,22 +1,38 @@
local S = farming.intllib
-- Blacberry
farming.register_plant("farming:blackberry", {
description = "Blackberry",
local sdef={
paramtype2 = "meshoptions",
inventory_image = "farming_blackberry.png",
steps = 4,
switch_drop_count = 3, -- at which stage more harvest
minlight = 13,
steps = 4, -- steps till full-grown plant
mean_grow_time=20, -- mean time till next step
range_grow_time=3, -- plus/minus for random generator
max_harvest=2, -- max amount of harvesting item for full grown plant
-- eat_hp=1, -- set in config for eatable plants
minlight = 13,
maxlight = default.LIGHT_MAX,
fertility = {"grassland"},
groups = {food_wheat = 1, flammable = 4,no_seed=1},
groups = {food=1,grain = 1, flammable = 4,no_harvest=1 ,punchable = 1,snappy=1},
place_param2 = 3,
min_temp=15,
max_temp=55,
min_humidity=10,
max_humidity=70,
spawnon = { spawnon = farming.change_soil or {"default:dirt_with_grass"},
spawn_min = 0,
spawn_max = 42,
spawnby = nil,
scale = 0.006, -- 0.006
spawn_num = -1}
})
spawn_num = -1},
description = S("Blackberry"),
inventory_image = "farming_blackberry.png",
eat_hp=2,
spread = {spreadon = farming.change_soil or {"default:dirt_with_grass"},
base_rate = 100,
spread = 50,
intervall = 12,
change = 0.00001, --part of soil, which get plants
},
}
farming.register_plant("farming:blackberry", sdef)

View File

@ -1,22 +1,40 @@
-- Carrot
farming.register_plant("farming:carrot", {
local po_def={
description = "Carrot",
paramtype2 = "meshoptions",
inventory_image = "farming_carrot.png",
steps = 8,
switch_drop_count = 6, -- at which stage more harvest
max_harvest=4,
minlight = 13,
maxlight = default.LIGHT_MAX,
fertility = {"grassland"},
groups = {food_wheat = 1, flammable = 4,no_seed=1},
groups = {food_wheat = 1, flammable = 4,no_harvest=1, on_soil = 1,snappy=1,food=1,infectable=1},
place_param2 = 3,
spawnon = { spawnon = {"default:dirt","default:dirt_with_grass"},
spawn_min = 0,
spawn_max = 42,
spawnon = { spawnon = farming.change_soil or {"default:dirt_with_grass"},
spawn_min = 10,
spawn_max = 100,
spawnby = nil,
scale = 0.006, -- 0.006
spawn_num = -1}
})
spawn_num = -1},
infect = {
base_rate = 10,
mono_rate = 5,
infect_rate = 5,
intervall = 50,
},
spread = {spreadon = farming.change_soil or {"default:dirt_with_grass"},
base_rate = 10,
spread = 5,
intervall = 12,
change = 0.0001, --part of soil, which get plants
},
min_temp=10,
max_temp=50,
min_humidity=10,
max_humidity=70,
}
farming.register_plant("farming:carrot", po_def)

View File

@ -1,22 +1,37 @@
local S = farming.intllib
-- Cocoa !!!!
farming.register_plant("farming:cocoa", {
description = "Cocoa Seed",
local sdef={
paramtype2 = "meshoptions",
inventory_image = "farming_cocoa_seed.png",
steps = 4,
switch_drop_count = 3, -- at which stage more harvest
minlight = 13,
steps = 4, -- steps till full-grown plant
mean_grow_time=20, -- mean time till next step
range_grow_time=3, -- plus/minus for random generator
max_harvest=2, -- max amount of harvesting item for full grown plant
-- eat_hp=1, -- set in config for eatable plants
minlight = 13,
maxlight = default.LIGHT_MAX,
fertility = {"grassland"},
groups = {food_wheat = 1, flammable = 4},
groups = {food=1,grain = 1, flammable = 4,no_harvest=1 ,punchable = 1,snappy=1},
place_param2 = 3,
min_temp=30,
max_temp=80,
min_humidity=40,
max_humidity=100,
spawnon = { spawnon = farming.change_soil or {"default:dirt_with_grass"},
spawn_min = 0,
spawn_max = 42,
spawn_min = 100,
spawn_max = 200,
spawnby = nil,
scale = 0.006, -- 0.006
spawn_num = -1}
})
spawn_num = -1},
description = S("Cocoa"),
inventory_image = "farming_cocoa.png",
spread = {spreadon = farming.change_soil or {"default:dirt_with_grass"},
base_rate = 100,
spread = 50,
intervall = 12,
change = 0.00001, --part of soil, which get plants
},
}
farming.register_plant("farming:coffee", sdef)

View File

@ -1,22 +1,35 @@
local S = farming.intllib
-- Coffee !!!!
farming.register_plant("farming:coffee", {
description = "Coffee Seed",
local sdef={
paramtype2 = "meshoptions",
inventory_image = "farming_coffee_seed.png",
steps = 5,
switch_drop_count = 4, -- at which stage more harvest
minlight = 13,
steps = 5, -- steps till full-grown plant
mean_grow_time=20, -- mean time till next step
range_grow_time=3, -- plus/minus for random generator
max_harvest=2, -- max amount of harvesting item for full grown plant
-- eat_hp=1, -- set in config for eatable plants
minlight = 13,
maxlight = default.LIGHT_MAX,
fertility = {"grassland"},
groups = {food_wheat = 1, flammable = 4},
groups = {food=1,grain = 1, flammable = 4,no_harvest=1 ,punchable = 1,snappy=1},
place_param2 = 3,
min_temp=30,
max_temp=80,
min_humidity=40,
max_humidity=100,
spawnon = { spawnon = farming.change_soil or {"default:dirt_with_grass"},
spawn_min = 0,
spawn_max = 42,
spawn_min = 100,
spawn_max = 200,
spawnby = nil,
scale = 0.006, -- 0.006
spawn_num = -1}
})
spawn_num = -1},
description = S("Coffee"),
inventory_image = "farming_coffee.png",
spread = {spreadon = farming.change_soil or {"default:dirt_with_grass"},
base_rate = 100,
spread = 50,
intervall = 12,
change = 0.00001, --part of soil, which get plants
},
}
farming.register_plant("farming:coffee", sdef)

View File

@ -1,22 +1,33 @@
local S = farming.intllib
-- Corn
farming.register_plant("farming:corn", {
local po_def={
description = "Corn",
paramtype2 = "meshoptions",
inventory_image = "farming_corn.png",
steps = 8,
switch_drop_count = 6, -- at which stage more harvest
max_harvest=4,
minlight = 13,
maxlight = default.LIGHT_MAX,
fertility = {"grassland"},
groups = {food_wheat = 1, flammable = 4,no_seed=1},
groups = {food_wheat = 1, flammable = 4,no_harvest=1, on_soil = 1,snappy=1,food=1},
place_param2 = 3,
spawnon = { spawnon = farming.change_soil or {"default:dirt_with_grass"},
spawn_min = 0,
spawn_max = 42,
spawn_min = 10,
spawn_max = 100,
spawnby = nil,
scale = 0.006, -- 0.006
spawn_num = -1}
})
spawn_num = -1},
spread = {spreadon = farming.change_soil or {"default:dirt_with_grass"},
base_rate = 10,
spread = 5,
intervall = 12,
change = 0.0001, --part of soil, which get plants
},
min_temp=20,
max_temp=60,
min_humidity=10,
max_humidity=70,
}
farming.register_plant("farming:corn", po_def)

View File

@ -1,13 +1,5 @@
-- Cotton
local S = farming.intllib
--[[
local possible_biomes={}
for name,def in pairs(minetest.registered_biomes) do
if def.heat_point > 20 and def.heat_point < 60 and def.humidity_point > 20 and def.humidity_point < 70 then
table.insert(possible_biomes,1,name)
end
end
]]
local cdef={
paramtype2 = "meshoptions",
steps = 8, -- steps till full-grown plant
@ -17,11 +9,11 @@ local cdef={
minlight = 13,
maxlight = default.LIGHT_MAX,
fertility = {"grassland"},
groups = {cotton = 1, flammable = 4},
groups = {cotton = 1, flammable = 4,no_harvest=1,punchable=1},
place_param2 = 3,
min_temp=10,
min_temp=25,
max_temp=50,
min_humidity=10,
min_humidity=30,
max_humidity=70,
spawnon = { spawnon = farming.change_soil or {"default:dirt_with_grass"},
spawn_min = 0,
@ -31,32 +23,6 @@ local cdef={
description = S("Cotton Seed"),
inventory_image = "farming_cotton_seed.png",
}
--[[
local def={
description = S("Cotton Seed"),
paramtype2 = "meshoptions",
inventory_image = "farming_cotton_seed.png",
steps = 8,
max_harvest=2,
eat_hp=0,
minlight = 13,
maxlight = default.LIGHT_MAX,
fertility = {"grassland"},
groups = {food_wheat = 1, grain = 1, flammable = 4},
place_param2 = 3,
spawnon = { spawnon = farming.change_soil or {"default:dirt_with_grass"},
spawn_min = 0,
spawn_max = 42,
spawnby = nil,
scale = 0.006, -- 0.006
spawn_num = -1}
}
]]
--if(table.getn(possible_biomes)>0) then
-- cdef.biomes=possible_biomes
--end
--print("cotton")
--print(dump(cdef))
farming.register_plant("farming:cotton", cdef)

26
crops/hop.lua Normal file
View File

@ -0,0 +1,26 @@
local S = farming.intllib
-- Hops
farming.register_plant("farming:hops", {
description = "Hops",
paramtype2 = "meshoptions",
inventory_image = "farming_hops_seed.png",
steps = 8,
minlight = 13,
maxlight = default.LIGHT_MAX,
fertility = {"grassland"},
groups = {food_wheat=1, grain = 1, flammable = 4, on_soil = 1,snappy=1,food=1,punchable=1},
place_param2 = 3,
min_temp=20,
max_temp=50,
min_humidity=20,
max_humidity=70,
spawnon = { spawnon = farming.change_soil or {"default:dirt_with_grass"},
spawn_min = 0,
spawn_max = 42,
spawnby = nil,
spawn_num = -1},
eat_hp=1,
max_harvest=2,
})

View File

@ -1,22 +1,31 @@
local S = farming.intllib
-- Mustard
farming.register_plant("farming:mustart", {
description = "Mustart",
farming.register_plant("farming:mustard", {
description = "Mustard Seed",
paramtype2 = "meshoptions",
inventory_image = "farming_mustard.png",
inventory_image = "farming_mustard_seed.png",
steps = 5,
switch_drop_count = 3, -- at which stage more harvest
minlight = 13,
maxlight = default.LIGHT_MAX,
fertility = {"grassland"},
groups = {food_wheat = 1, flammable = 4,no_seed=1},
groups = {food_mustard=1, grain = 1, flammable = 4, snappy=1,food=1,no_harvest=1},
place_param2 = 3,
min_temp=10,
max_temp=50,
min_humidity=10,
max_humidity=70,
spawnon = { spawnon = farming.change_soil or {"default:dirt_with_grass"},
spawn_min = 0,
spawn_max = 42,
spawnby = nil,
scale = 0.006, -- 0.006
spawn_num = -1}
spawn_num = -1},
spread = {spreadon = farming.change_soil or {"default:dirt_with_grass"},
base_rate = 10,
spread = 5,
intervall = 12,
change = 0.0001, --part of soil, which get plants
},
max_harvest=2,
})

View File

@ -1,3 +1,4 @@
local S = farming.intllib
-- Potato
local po_def={
@ -9,14 +10,30 @@ local po_def={
minlight = 13,
maxlight = default.LIGHT_MAX,
fertility = {"grassland"},
groups = {food_wheat = 1, flammable = 4,no_harvest=1, on_soil = 1,snappy=1},
groups = {food_wheat = 1, flammable = 4,no_harvest=1, on_soil = 1,snappy=1,food=1,infectable=1},
place_param2 = 3,
spawnon = { spawnon = farming.change_soil or {"default:dirt_with_grass"},
spawn_min = 0,
spawn_max = 42,
spawn_min = 10,
spawn_max = 100,
spawnby = nil,
scale = 0.006, -- 0.006
spawn_num = -1}
spawn_num = -1},
infect = {
base_rate = 10,
mono_rate = 5,
infect_rate = 5,
intervall = 50,
},
spread = {spreadon = farming.change_soil or {"default:dirt_with_grass"},
base_rate = 10,
spread = 5,
intervall = 12,
change = 0.0001, --part of soil, which get plants
},
min_temp=10,
max_temp=50,
min_humidity=10,
max_humidity=70,
}
farming.register_plant("farming:potato", po_def)

View File

@ -1,22 +1,38 @@
local S = farming.intllib
-- Raspberry
farming.register_plant("farming:raspberry", {
description = "Raspberry",
local sdef={
paramtype2 = "meshoptions",
inventory_image = "farming_raspberry.png",
steps = 4,
switch_drop_count = 3, -- at which stage more harvest
minlight = 13,
steps = 4, -- steps till full-grown plant
mean_grow_time=20, -- mean time till next step
range_grow_time=3, -- plus/minus for random generator
max_harvest=2, -- max amount of harvesting item for full grown plant
-- eat_hp=1, -- set in config for eatable plants
minlight = 13,
maxlight = default.LIGHT_MAX,
fertility = {"grassland"},
groups = {food_wheat = 1, flammable = 4,no_seed=1},
groups = {food=1,grain = 1, flammable = 4,no_harvest=1 ,punchable = 1,snappy=1},
place_param2 = 3,
min_temp=10,
max_temp=50,
min_humidity=10,
max_humidity=70,
spawnon = { spawnon = farming.change_soil or {"default:dirt_with_grass"},
spawn_min = 0,
spawn_max = 42,
spawnby = nil,
scale = 0.006, -- 0.006
spawn_num = -1}
})
spawn_num = -1},
description = S("Raspberry"),
inventory_image = "farming_raspberry.png",
eat_hp=2,
spread = {spreadon = farming.change_soil or {"default:dirt_with_grass"},
base_rate = 100,
spread = 50,
intervall = 12,
change = 0.00001, --part of soil, which get plants
},
}
farming.register_plant("farming:raspberry", sdef)

View File

@ -1,22 +1,32 @@
local S = farming.intllib
-- Spelt
farming.register_plant("farming:spelt", {
description = "Spelt Seed",
paramtype2 = "meshoptions",
inventory_image = "farming_wheat_spelt.png",
inventory_image = "farming_spelt_seed.png",
steps = 7,
switch_drop_count = 6, -- at which stage more harvest
minlight = 13,
maxlight = default.LIGHT_MAX,
fertility = {"grassland"},
groups = {food_wheat = 1, flammable = 4},
groups = {food_wheat=1, grain = 1, flammable = 4, on_soil = 1,snappy=1,food=1},
place_param2 = 3,
min_temp=00,
max_temp=60,
min_humidity=10,
max_humidity=50,
spawnon = { spawnon = farming.change_soil or {"default:dirt_with_grass"},
spawn_min = 0,
spawn_max = 42,
spawn_max = 100,
spawnby = nil,
scale = 0.006, -- 0.006
spawn_num = -1}
spawn_num = -1},
spread = {spreadon = farming.change_soil or {"default:dirt_with_grass"},
base_rate = 10,
spread = 5,
intervall = 12,
change = 0.0001, --part of soil, which get plants
},
max_harvest=2,
})

View File

@ -1,12 +1,6 @@
-- Strawberry
local S = farming.intllib
local possible_biomes={}
for name,def in pairs(minetest.registered_biomes) do
if def.heat_point > 12 and def.heat_point < 40 and def.humidity_point > 10 and def.humidity_point < 50 then
table.insert(possible_biomes,1,name)
end
end
local sdef={
paramtype2 = "meshoptions",
steps = 4, -- steps till full-grown plant
@ -30,14 +24,15 @@ local sdef={
spawn_num = -1},
description = S("Strawberry"),
inventory_image = "farming_strawberry.png",
eat_hp=4,
eat_hp=2,
spread = {spreadon = farming.change_soil or {"default:dirt_with_grass"},
base_rate = 100,
spread = 50,
intervall = 12,
change = 0.00001, --part of soil, which get plants
},
}
--if(table.getn(possible_biomes)>0) then
-- def.biomes=possible_biomes
--end
--print("strawberry")
--print(dump(sdef))
farming.register_plant("farming:strawberry", sdef)

View File

@ -1,22 +1,26 @@
local S = farming.intllib
-- Tomato
farming.register_plant("farming:tomato", {
description = "Tomato",
paramtype2 = "meshoptions",
inventory_image = "farming_tomato.png",
inventory_image = "farming_tomato_seed.png",
steps = 8,
switch_drop_count = 6, -- at which stage more harvest
minlight = 13,
maxlight = default.LIGHT_MAX,
fertility = {"grassland"},
groups = {food_wheat = 1, flammable = 4,no_seed=1},
groups = {food_wheat=1, grain = 1, flammable = 4, on_soil = 1,snappy=1,food=1,punchable=1},
place_param2 = 3,
spawnon = { spawnon = {"default:dirt","default:dirt_with_grass"},
min_temp=10,
max_temp=50,
min_humidity=10,
max_humidity=70,
spawnon = { spawnon = farming.change_soil or {"default:dirt_with_grass"},
spawn_min = 0,
spawn_max = 42,
spawnby = nil,
scale = 0.006, -- 0.006
spawn_num = -1}
spawn_num = -1},
eat_hp=1,
max_harvest=2,
})

View File

@ -27,6 +27,18 @@ local w1def={
eat_hp=1,
next_plant="farming:culturewheat",
next_plant_rarity=12,
infect = {
base_rate = 10,
mono_rate = 5,
infect_rate = 5,
intervall = 50,
},
spread = {spreadon = farming.change_soil or {"default:dirt_with_grass"},
base_rate = 10,
spread = 5,
intervall = 12,
change = 0.0001, --part of soil, which get plants
},
}
--print(dump(w1def))
--if(table.getn(farming.possible_biomes)>0) then
@ -53,7 +65,18 @@ local wdef={
eat_hp=1,
mean_grow_time=20,
range_grow_time=5,
abm={change = 20}, -- change that randomly new wheat is created
infect = {
base_rate = 10,
mono_rate = 5,
infect_rate = 2,
intervall = 50,
},
spread = {spreadon = farming.change_soil or {"default:dirt_with_grass"},
base_rate = 100,
spread = 50,
intervall = 360,
change = 0.00001, --part of soil, which get plants
},
}
farming.register_plant("farming:culturewheat", wdef)

View File

@ -21,19 +21,68 @@ msgstr ""
msgid "Spelt"
msgstr "Dinkel"
#: spelt.lua
msgid "Spelt Seed"
msgstr "Dinkelkörner"
#: spelt.lua
msgid "Roasted Spelt"
msgstr "Gerösteter Dinkel"
#: spelt.lua
msgid "Spelt Coffee"
msgstr "Dinkelkaffee"
#: spelt.lua
msgid "Cup of Spelt Coffee"
msgstr "Tasse Dinkelkaffee"
msgid "Wheat"
msgstr "Weizen"
msgid "Barley"
msgstr "Gerste"
msgid "Coffee"
msgstr "Kaffee"
msgid "Cocoa"
msgstr "Cacao"
msgid "Potato"
msgstr "Kartoffel"
msgid "Beetroot"
msgstr "Rote Beete"
msgid "Blackberry"
msgstr "Brombeere"
msgid "Raspberry"
msgstr "Himbeere"
msgid "Strawberry"
msgstr "Erdbeere"
msgid "Blueberry"
msgstr "Heidelbeere"
msgid "Carrot"
msgstr "Karotte"
msgid "Corn"
msgstr "Mais"
msgid "Cotton"
msgstr "Baumwolle"
msgid "Garlic"
msgstr "Knoblauch"
msgid "Mustard"
msgstr "Senf"
msgid "Rhubarb"
msgstr "Rhabarber"
msgid "Tomatoe"
msgstr "Tomate"
msgid "Hops"
msgstr "Hopfen"

View File

@ -53,6 +53,7 @@ local register_plant_check_def = function(def)
if not def.inventory_image then
def.inventory_image = "unknown_item.png"
end
-- minimum of light needed for growing
if not def.minlight then
def.minlight = 1
end
@ -66,10 +67,10 @@ local register_plant_check_def = function(def)
def.max_harvest = 2
end
if not def.mean_grow_time then
def.mean_grow_time=math.random(170,220)
def.mean_grow_time=math.random(farming.wait_min,farming.wait_max)
end
if not def.range_grow_time then
def.range_grow_time=math.random(15,25)
def.range_grow_time=math.random(0,farming.wait_max-farming.wait_min)
end
if def.range_grow_time > def.mean_grow_time then
def.range_grow_time = math.floor(def.mean_grow_time / 2)
@ -79,7 +80,13 @@ local register_plant_check_def = function(def)
-- if not def.eat_hp then
-- def.eat_hp = 1
-- end
if def.spawnon then
local spawn = true
if (not def.spawnon) or (def.groups["no_spawn"]) then
def.spawnon = nil
def.groups["no_spawn"] = 1
spawn = false
end
if def.spawnon and spawn then
def.spawnon.spawnon=def.spawnon.spawnon or {"default:dirt_with_grass"}
def.spawnon.spawn_min = def.spawnon.spawn_min or 0
def.spawnon.spawn_max = def.spawnon.spawn_max or 42
@ -88,6 +95,25 @@ local register_plant_check_def = function(def)
def.spawnon.offset = def.spawnon.offset or 0.02
def.spawnon.spawn_num = def.spawnon.spawn_num or -1
end
if def.spread then
def.spread.spreadon = def.spread.spreadon or {"default:dirt_with_grass"}
def.spread.base_rate = def.spread.base_rate or 10
def.spread.spread = def.spread.spread or 5
def.spread.intervall = def.spread.intervall or 120
def.spread.change = def.spread.change or 0.00001
def.spread.inv_change = math.ceil(1/def.spread.change)
end
local infect = false
if (def.infect) or (def.groups["infectable"]) then
def.infect = {}
def.groups["infectable"] = 1
end
if def.infect then
def.infect.base_rate = def.infect.base_rate or 10
def.infect.mono_rate = def.infect.mono_rate or 10
def.infect.infect_rate = def.infect.infect_rate or 10
def.infect.intervall = def.infect.intervall or 120
end
return def
end
@ -136,10 +162,19 @@ farming.register_infect=function(idef)
print(dump(infect_def))
local abm_def = {
nodenames = {"group:"..idef.plant_name},
intervall = math.random(10,20),
change = 1,
intervall = idef.infect.intervall + math.random(-1,1), -- little noise
change = idef.infect.base_rate,
action = function(pos)
if math.random(0,5)<1 then
local base_rate = minetest.get_node_light(pos,0.5) -- get light at midday
local infected_neighbours = #minetest.find_nodes_in_area(vector.subtract(pos,4),vector.add(pos,4),"group:ill")
local mono_rate = #minetest.find_nodes_in_area(vector.subtract(pos,4),vector.add(pos,4),"group:"..idef.plant_name)
local test_rate = idef.infect.base_rate / infected_neighbours
if mono_rate > 2 then
test_rate = test_rate * idef.infect.mono_rate
else
test_rate = test_rate * idef.infect.base_rate
end
if math.random(0,test_rate)<1 then
minetest.add_node(pos,{name=idef.harvest_name.."_infected"})
end
end,
@ -147,11 +182,14 @@ farming.register_infect=function(idef)
minetest.register_abm(abm_def)
local abm_def = {
nodenames = {"group:"..idef.plant_name},
neighbors = {"group:"..idef.plant_name},
intervall = math.random(30,40),
neighbors = {"group:ill"},
intervall = idef.infect.intervall + math.random(-1,1),
change = 1,
action = function(pos)
if math.random(0,50)<1 then
local base_rate = minetest.get_node_light(pos,0.5) -- get light at midday
local infected_neighbours = #minetest.find_nodes_in_area(vector.subtract(pos,4),vector.add(pos,4),"group:ill")
local test_rate = idef.infect.infect_rate * #minetest.find_nodes_in_area(vector.subtract(pos,4),vector.add(pos,4),"group:"..idef.plant_name)
if math.random(0,test_rate)<1 then
minetest.add_node(pos,{name=idef.harvest_name.."_infected"})
end
end,
@ -217,6 +255,7 @@ farming.register_steps = function(pname,sdef)
has_next_plant = true
end
-- base configuration of each step
local node_def = {
drawtype = "plantlike",
waving = 1,
@ -227,12 +266,15 @@ farming.register_steps = function(pname,sdef)
fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},},
sounds = default.node_sound_leaves_defaults(),
}
-- copy some plant definition into definition of this steps
for _,colu in ipairs({"paramtype2","place_param2","minlight","maxlight","seed_name","plant_name","harvest_name"}) do
if sdef[colu] then
node_def[colu] = sdef[colu]
end
end
-- define drop item: normal drop the seed
local drop_item = sdef.seed_name
-- if plant has to be harvested, drop harvest instead
if has_harvest then
drop_item = sdef.harvest_name
end
@ -303,29 +345,79 @@ end
farming.register_abm = function(mdef)
local rand_change = 50
if mdef.abm then
if mdef.abm.change then
rand_change = mdef.abm.change
if mdef.spread then
if mdef.spread.base_rate then
rand_change = mdef.spread.base_rate
end
end
minetest.register_abm({
nodenames = mdef.spawnon.spawnon,
interval = math.random(10,16),
chance = 1,
action = function(pos)
local ptabove={x=pos.x,y=pos.y+1,z=pos.z}
local above = minetest.get_node(ptabove)
if above.name ~= "air" then
return
end
if (ptabove.y < mdef.spawnon.spawn_min or ptabove.y > mdef.spawnon.spawn_max ) then
return
end
if math.random(0,rand_change) < 1 then
minetest.add_node(ptabove, {name=mdef.harvest_name.."_"..mdef.steps})
end
end,
})
if mdef.spread then
-- random spread of plant on surface.
minetest.register_abm({
nodenames = mdef.spread.spreadon,
neighbors = {"air"},
interval = mdef.spread.intervall+math.random(-1,1), -- little noise
chance = rand_change,
action = function(pos)
local ptabove={x=pos.x,y=pos.y+1,z=pos.z}
local above = minetest.get_node(ptabove)
if above.name ~= "air" then
return
end
if minetest.get_node_light(ptabove) < mdef.minlight then
return
end
local ymin=0
local ymax=31000
if mdef.spawnon then
ymin=mdef.spawnon.spawn_min or 0
ymax=mdef.spawnon.spawn_max or 31000
end
if (ptabove.y < ymin or ptabove.y > ymax ) then
return
end
local pos0 = vector.subtract(pos,4)
local pos1 = vector.add(pos,4)
-- only for positions, where not too many plants are nearby
if #minetest.find_nodes_in_area(pos0,pos1,"group:"..mdef.plant_name) > 2 then
return
end
if math.random(0,mdef.spread.inv_change) < 1 then
minetest.add_node(ptabove, {name=mdef.harvest_name.."_1"})
minetest.get_node_timer(pos):start(math.random(mdef.min_grow_time or 100, mdef.max_grow_time or 200))
end
end,
})
-- spread for full-grown plant
minetest.register_abm({
nodenames =mdef.spread.spreadon ,
neighbours=mdef.harvest_name.."_"..mdef.steps,
interval = mdef.spread.intervall + math.random(-1,1), --little noise
chance = mdef.spread.spread,
action = function(pos)
local ptabove={x=pos.x,y=pos.y+1,z=pos.z}
local above = minetest.get_node(ptabove)
if above.name ~= "air" then
return
end
if minetest.get_node_light(ptabove) < mdef.minlight then
return
end
local ymin=0
local ymax=31000
if mdef.spawnon then
ymin=mdef.spawnon.spawn_min or 0
ymax=mdef.spawnon.spawn_max or 31000
end
if (ptabove.y < ymin or ptabove.y > ymax ) then
return
end
if math.random(0,mdef.spread.inv_change) < 1 then
minetest.add_node(ptabove, {name=mdef.harvest_name.."_1"})
minetest.get_node_timer(pos):start(math.random(mdef.min_grow_time or 100, mdef.max_grow_time or 200))
end
end,
})
end
end
farming.register_mapgen = function(mdef)
-- register mapgen
@ -390,10 +482,6 @@ farming.register_plant = function(name, def)
has_next_plant = true
end
local spawns = true
if (not def.spawnon) or (def.groups["no_spawn"]) then
def.spawnon = nil
def.groups["no_spawn"] = 1
end
-- if plant has harvest then registering
if has_harvest then
@ -411,7 +499,11 @@ farming.register_plant = function(name, def)
if (def.spawnon) then
farming.register_mapgen(def)
farming.register_abm(def)
end
if (def.spread) then
for i=1,def.spread.base_rate do
table.insert(farming.spreading_crops,1,{def.harvest_name.."_1"})
end
end
if is_infectable then
@ -528,14 +620,13 @@ farming.step_on_timer = function(pos, elapsed)
local node = minetest.get_node(pos)
local name = node.name
local def = minetest.registered_nodes[name]
-- check if on wet soil and enough light
-- check for enough light
local below = minetest.get_node({x = pos.x, y = pos.y - 1, z = pos.z})
local light = minetest.get_node_light(pos)
if not def.next_step then
return
end
if ((minetest.get_item_group(below.name, "soil") < 3) and (minetest.get_item_group(node,"on_soil") >= 1))or
not light or light < def.minlight or light > def.maxlight then
if not light or light < def.minlight or light > def.maxlight then
minetest.get_node_timer(pos):start(math.random(farming.wait_min, farming.wait_max))
return
end

BIN
textures/farming_hop_1.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 B

BIN
textures/farming_hop_2.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 B

BIN
textures/farming_hop_3.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 B

BIN
textures/farming_hop_4.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 B

BIN
textures/farming_hop_5.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 B

BIN
textures/farming_hop_6.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 184 B

BIN
textures/farming_hop_7.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 184 B

BIN
textures/farming_hop_ill.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 189 B