#9 ; added 2 different wilt mechanism for grain and berries. wilt for nettles has to come.
parent
5817a81e8d
commit
d8e05f98c7
23
config.lua
23
config.lua
|
@ -5,30 +5,25 @@
|
|||
world folder for map specific settings.
|
||||
--]]
|
||||
|
||||
farming.crops = {"wheat","strawberry","potato","barley","blackberry","corn","coffee","raspberry","cocoa","spelt","mustard","cotton","tomato"}
|
||||
local viscosity=1
|
||||
local wilt_removal_time=20
|
||||
|
||||
for i,crop in ipairs(farming.crops) do
|
||||
-- print(crop.." - "..farming.config:get_string(crop))
|
||||
if farming.config:get_string(crop) == "" then
|
||||
farming.config:set_int(crop,1)
|
||||
end
|
||||
if minetest.settings:get("farming."..crop) ~= nil then
|
||||
if minetest.settings:get_bool("farming."..crop) then
|
||||
farming.config:set_int(crop,1)
|
||||
else
|
||||
farming.config:set_int(crop,0)
|
||||
end
|
||||
end
|
||||
end
|
||||
if minetest.settings:get("farming.rarety") then
|
||||
farming.config:set_float("rarety",minetest.settings:get("farming.rarety"))
|
||||
end
|
||||
if minetest.settings:get("farming.viscosity") then
|
||||
farming.config:set_int("viscosity",minetest.settings:get("farming.viscosity"))
|
||||
else
|
||||
farming.config:set_int("viscosity",viscosity)
|
||||
end
|
||||
|
||||
-- rarety of crops on map, default is 0.001 (higher number = more crops)
|
||||
farming.rarety = farming.config:get_float("rarety") or 0.002
|
||||
-- random waiting time for growing
|
||||
farming.wait_min = farming.config:get_int("wati_min") or 40
|
||||
farming.wait_max = farming.config:get_int("wati_max") or 80
|
||||
farming.wilt_removal_time = wilt_removal_time or 60
|
||||
farming.wilt_time = 5
|
||||
|
||||
-- node type, where grain can be randomly found
|
||||
farming.change_soil = {}
|
||||
|
|
10
crops.lua
10
crops.lua
|
@ -28,6 +28,11 @@ Actual columns:
|
|||
infectable void
|
||||
any value the plant can be infected, where the crop does not give any seed or harvest
|
||||
and may infect other crops nearby
|
||||
wiltable void
|
||||
1 Wilt is going one step back, like Berries: They loose the fruits, but grow again
|
||||
2 Plant wilt and remove itself after time. During wilt you can harvest straw if defined.
|
||||
For grain
|
||||
3 crop is spreading seed around and go one step back or dies like nettles
|
||||
infection_defense
|
||||
any value can protect nearby crop against infection. value give range of protection
|
||||
seed_extractable
|
||||
|
@ -64,6 +69,7 @@ Actual columns:
|
|||
infect_rate_monoculture Infect rate if many crops are standing nearby.
|
||||
spread_rate Full grown crops can spread to neighbor block
|
||||
grow_time_mean mean grow time to next step
|
||||
wilt_time Time for wilt of a crop
|
||||
straw text extension for using flail: item name of fibre to craft out of harvest beside seeds
|
||||
culture_rate rate to get cultured variant out of wild form.
|
||||
seed_drop name of seed you get from plant: grapes drops seed which normally lead to wild wine.
|
||||
|
@ -80,10 +86,10 @@ local crop_cols={
|
|||
col_num={"rarety","steps","harvest_max","eat_hp",
|
||||
"temperature_min","temperature_max","humidity_min","humidity_max",
|
||||
"elevation_min","elevation_max","light_min","light_max",
|
||||
"infect_rate_base","infect_rate_monoculture","spread_rate","grow_time_mean","roast_time"},
|
||||
"infect_rate_base","infect_rate_monoculture","spread_rate","grow_time_mean","roast_time","wilt_time"},
|
||||
groups_num={"to_culture","to_dig","has_harvest","on_soil","punchable","infectable",
|
||||
"seed_extractable","use_flail","use_trellis","snappy","infection_defence","seed_roastable",
|
||||
"seed_grindable","for_flour","for_coffee","damage_per_second","liquid_viscosity"}}
|
||||
"seed_grindable","for_flour","for_coffee","damage_per_second","liquid_viscosity","wiltable"}}
|
||||
local crop_definition = farming.import_csv(farming.path.."/crops.txt",crop_cols)
|
||||
|
||||
--print(dump(crop_definition))
|
||||
|
|
62
crops.txt
62
crops.txt
|
@ -1,31 +1,31 @@
|
|||
name,enabled,next_plant,rarety,steps,harvest_max,eat_hp,to_culture,to_dig,has_harvest,on_soil,punchable,infectable,infection_defence,seed_extractable,no_seed,use_flail,use_trellis,for_coffee,seed_roastable,seed_grindable,for_flour,snappy,damage_per_second,liquid_viscosity,temperature_min,temperature_max,humidity_min,humidity_max,elevation_min,elevation_max,light_min,light_max,infect_rate_base,infect_rate_monoculture,spread_rate,grow_time_mean,wilt_time,straw,culture_rate,seed_drop,grind,roast
|
||||
default,1,,10,8,2,1,,,,,,,,,,,,,,,,3,,,15,80,10,80,0,200,11,14,1E-05,0.001,0.001,12,20,,,,,
|
||||
barley,1,,10,7,2,,,,1,1,,1,,,,1,,1,3,,1,3,,2,25,,30,,,,,,,,,,,farming:straw,,,farming:flour,
|
||||
beetroot,1,,10,5,2,2,,1,,1,,,,,,,,,,,,3,,,35,,30,,,,9,,,,,,,,,,,
|
||||
blackberry,1,,10,4,2,1,,,,,1,,,,,,,,,,,3,1,5,,90,20,,,,9,,,,,,,,,,,
|
||||
blueberry,1,,10,4,2,1,,,,,1,,,,,,,,,,,3,,,45,90,40,90,,,9,,,,,,,,,,,
|
||||
carrot,1,,10,8,2,2,,1,,1,,,,,,,,,2,,,3,,,45,,30,90,,,8,,,,,,,,,,,farming:carrot_baked
|
||||
chili,1,,20,8,2,1,,,,,1,,,,,,,,,,,3,,,45,90,,,,1000,,,,,,,,,,,,
|
||||
coffee,1,,20,5,2,1,,,,,1,,,,,,,1,4,,,3,,,50,120,50,150,,1000,12,,,,,,,,,,,
|
||||
corn,1,,10,8,2,2,,,,1,,1,,,,,,,4,1,,3,,2,35,90,30,,,,,,,,,,,,,,,farming:corn_cob
|
||||
cotton,1,,10,8,2,,,,1,1,,1,,,,1,,,,,,3,,2,45,90,20,,,,12,,,,,,,,,,,
|
||||
culturewheat,1,,100,4,3,,1,,1,1,,1,,,,1,,1,3,,1,3,,2,25,,40,,,,10,,,,,100,,farming:straw,,,farming:flour,
|
||||
flax,,,10,7,2,,,,1,1,,1,,,,1,,,,,,3,,,25,,30,,,,,,,,,,,farming:flaw,,,,
|
||||
garlic,,,10,5,2,1,,1,,1,,,,,,,,,3,,,3,,,,,,,,,,,,,,,,,,,,
|
||||
grapes,1,,10,8,3,2,1,,,1,1,1,,,,,1,,,,,3,,3,,,,,,,,,,,,,,,,farming:seed_wildgrapes,,
|
||||
hemp,1,,10,8,2,,,,1,,,,,,,1,,,,,,3,,2,,120,,,,,6,,,,1E-05,9,,farming:hemp_fibre,,,,
|
||||
hop,1,,10,7,3,1,1,,,1,1,1,,,,,1,,4,,,3,,,,,,,,,,,,,,,,,,farming:seed_wildhop,,
|
||||
mustard,1,,10,5,2,,,,,,,1,,,,,,,,2,,3,,,,,,,,,,,,,,,,,,,,
|
||||
potato,1,,10,4,2,2,,,,1,,1,,,,,,,4,1,,3,,,,,,,,,,,,,,,,,,,,farming:potato_baked
|
||||
raspberry,1,,10,4,2,1,,,,,1,,,,,,,,,,,3,1,5,,,,,,,9,,,,,,,,,,,
|
||||
rhubarb,1,,10,3,2,2,,1,,1,,,,,,,,,,,,3,,,,,,,,,9,,,,,,,,,,,
|
||||
spelt,1,,10,7,2,,,,1,1,,1,,,,1,,,3,,1,3,,2,,,,,,,,,,,,,,farming:straw,,,farming:flour,
|
||||
strawberry,1,,10,4,2,1,,,,,1,,,,,,,,,,,3,,,,,,,,,9,,,,,,,,,,,
|
||||
sugarbeet,1,,10,5,2,2,,1,,1,,,,,,,,,,,,3,,,35,,30,,,,9,,,,,,,,,,,
|
||||
tea,,,20,5,2,1,,,,,1,,,1,,,,,4,,,3,,,30,70,30,70,,,,,,,,,,,,,,
|
||||
tobaco,1,,10,8,2,,,,1,1,1,,2,,,,,,4,,,3,,,,,,,,,,,,,,,,,,,,
|
||||
tomato,,,10,8,2,1,,,1,1,1,1,,,,,1,,,,,3,,,,,,,,,,,,,,,,,,,,
|
||||
nettle,1,,10,5,2,1,,,1,,,,1,,,1,,,2,,,3,1,3,5,150,,100,,2000,6,,,,,8,,farming:nettle_fibre,,,,
|
||||
wheat,1,farming:culturewheat,10,8,2,,,,1,1,,1,,,,1,,1,3,,1,3,,2,,,,,,,,,,,,,,farming:straw,10,,farming:flour,
|
||||
wildhop,1,hop,10,6,2,,,,,,,,,,1,,,,4,,,3,,,,,,,,,,,,,,,,,5,,,
|
||||
wildgrapes,1,,10,4,2,1,,,,,,,,,1,,,,,,,3,,,,,,,,,,,,,,,,,5,,,
|
||||
name,enabled,next_plant,rarety,steps,harvest_max,eat_hp,to_culture,to_dig,has_harvest,on_soil,punchable,wiltable,infectable,infection_defence,seed_extractable,no_seed,use_flail,use_trellis,for_coffee,seed_roastable,seed_grindable,for_flour,snappy,damage_per_second,liquid_viscosity,temperature_min,temperature_max,humidity_min,humidity_max,elevation_min,elevation_max,light_min,light_max,infect_rate_base,infect_rate_monoculture,spread_rate,grow_time_mean,wilt_time,straw,culture_rate,seed_drop,grind,roast
|
||||
default,1,,10,8,2,1,,,,,,,,,,,,,,,,,3,,,15,80,10,80,0,200,11,14,1E-05,0.001,0.001,12,,,,,,
|
||||
barley,1,,10,7,2,,,,1,1,,2,1,,,,1,,1,3,,1,3,,2,25,,30,,,,,,,,,,,farming:straw,,,farming:flour,
|
||||
beetroot,1,,10,5,2,2,,1,,1,,,,,,,,,,,,,3,,,35,,30,,,,9,,,,,,,,,,,
|
||||
blackberry,1,,10,4,2,1,,,,,1,1,,,,,,,,,,,3,1,5,,90,20,,,,9,,,,,,,,,,,
|
||||
blueberry,1,,10,4,2,1,,,,,1,1,,,,,,,,,,,3,,,45,90,40,90,,,9,,,,,,,,,,,
|
||||
carrot,1,,10,8,2,2,,1,,1,,,,,,,,,,2,,,3,,,45,,30,90,,,8,,,,,,,,,,,farming:carrot_baked
|
||||
chili,1,,20,8,2,1,,,,,1,,,,,,,,,,,,3,,,45,90,,,,1000,,,,,,,,,,,,
|
||||
coffee,1,,20,5,2,1,,,,,1,,,,,,,,1,4,,,3,,,50,120,50,150,,1000,12,,,,,,,,,,,
|
||||
corn,1,,10,8,2,2,,,,1,,2,1,,,,,,,4,1,,3,,2,35,90,30,,,,,,,,,,,,,,,farming:corn_cob
|
||||
cotton,1,,10,8,2,,,,1,1,,,1,,,,1,,,,,,3,,2,45,90,20,,,,12,,,,,,,,,,,
|
||||
culturewheat,1,,100,4,3,,1,,1,1,,2,1,,,,1,,1,3,,1,3,,2,25,,40,,,,10,,,,,100,5,farming:straw,,,farming:flour,
|
||||
flax,,,10,7,2,,,,1,1,,,1,,,,1,,,,,,3,,,25,,30,,,,,,,,,,,farming:flaw,,,,
|
||||
garlic,,,10,5,2,1,,1,,1,,,,,,,,,,3,,,3,,,,,,,,,,,,,,,,,,,,
|
||||
grapes,1,,10,8,3,2,1,,,1,1,,1,,,,,1,,,,,3,,3,,,,,,,,,,,,,,,,farming:seed_wildgrapes,,
|
||||
hemp,1,,10,8,2,,,,1,,,,,,,,1,,,,,,3,,2,,120,,,,,6,,,,1E-05,9,,farming:hemp_fibre,,,,
|
||||
hop,1,,10,7,3,1,1,,,1,1,2,1,,,,,1,,4,,,3,,,,,,,,,,,,,,,,,,farming:seed_wildhop,,
|
||||
mustard,1,,10,5,2,,,,,,,,1,,,,,,,,2,,3,,,,,,,,,,,,,,,,,,,,
|
||||
potato,1,,10,4,2,2,,,,1,,2,1,,,,,,,4,1,,3,,,,,,,,,,,,,,,,,,,,farming:potato_baked
|
||||
raspberry,1,,10,4,2,1,,,,,1,1,,,,,,,,,,,3,1,5,,,,,,,9,,,,,,,,,,,
|
||||
rhubarb,1,,10,3,2,2,,1,,1,,,,,,,,,,,,,3,,,,,,,,,9,,,,,,,,,,,
|
||||
spelt,1,,10,7,2,,,,1,1,,2,1,,,,1,,,3,,1,3,,2,,,,,,,,,,,,,,farming:straw,,,farming:flour,
|
||||
strawberry,1,,10,4,2,1,,,,,1,1,,,,,,,,,,,3,,,,,,,,,9,,,,,,,,,,,
|
||||
sugarbeet,1,,10,5,2,2,,1,,1,,,,,,,,,,,,,3,,,35,,30,,,,9,,,,,,,,,,,
|
||||
tea,,,20,5,2,1,,,,,1,,,,1,,,,,4,,,3,,,30,70,30,70,,,,,,,,,,,,,,
|
||||
tobaco,1,,10,8,2,,,,1,1,1,,,2,,,,,,4,,,3,,,,,,,,,,,,,,,,,,,,
|
||||
tomato,,,10,8,2,1,,,1,1,1,1,1,,,,,1,,,,,3,,,,,,,,,,,,,,,,,,,,
|
||||
nettle,1,,10,5,2,1,,,1,,,3,,1,,,1,,,2,,,3,1,3,5,150,,100,,2000,6,,,,,8,,farming:nettle_fibre,,,,
|
||||
wheat,1,farming:culturewheat,10,8,2,,,,1,1,,2,1,,,,1,,1,3,,1,3,,2,,,,,,,,,,,,,5,farming:straw,10,,farming:flour,
|
||||
wildhop,1,hop,10,6,2,,,,,,,1,,,,1,,,,4,,,3,,,,,,,,,,,,,,,,,5,,,
|
||||
wildgrapes,1,,10,4,2,1,,,,,,,,,,1,,,,,,,3,,,,,,,,,,,,,,,,,5,,,
|
||||
|
|
57
register.lua
57
register.lua
|
@ -45,6 +45,11 @@ local register_plant_check_def = function(def)
|
|||
end
|
||||
def.groups["has_harvest"] = 1
|
||||
end
|
||||
if def.groups["wiltable"] ~= nil then
|
||||
if def.wilt_time == nil then
|
||||
def.wilt_time = farming.wilt_time
|
||||
end
|
||||
end
|
||||
def.grow_time_min=math.floor(def.grow_time_mean*0.75)
|
||||
def.grow_time_max=math.floor(def.grow_time_mean*1.2)
|
||||
return def
|
||||
|
@ -75,6 +80,11 @@ farming.register_plant = function(def)
|
|||
def.harvest_name=def.seed_name
|
||||
end
|
||||
|
||||
if def.groups["wiltable"] == 2 then
|
||||
def.wilt_name=def.mod_name..":wilt_"..def.name
|
||||
print(def.wilt_name)
|
||||
farming.register_wilt(def)
|
||||
end
|
||||
farming.registered_plants[def.name] = def
|
||||
|
||||
farming.register_seed(def)
|
||||
|
@ -203,6 +213,33 @@ farming.register_infect=function(idef)
|
|||
infect_def.groups["step"] = -1
|
||||
minetest.register_node(":" .. idef.name.."_infected", infect_def)
|
||||
end
|
||||
farming.register_wilt=function(idef)
|
||||
if idef.wilt_name == nil then
|
||||
return
|
||||
end
|
||||
local wilt_def={
|
||||
description = S(idef.description:gsub("^%l", string.upper).." wilted"),
|
||||
tiles = {idef.mod_name.."_"..idef.name.."_wilt.png"},
|
||||
drawtype = "plantlike",
|
||||
waving = 1,
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
selection_box = {type = "fixed",
|
||||
fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
}
|
||||
if idef.straw ~= nil then
|
||||
wilt_def.drop={items={{items={idef.straw}}}}
|
||||
end
|
||||
for _,coln in ipairs({"name","seed_name","step_name","place_param2","fertility","description"}) do
|
||||
wilt_def[coln] = idef[coln]
|
||||
end
|
||||
|
||||
wilt_def.groups = {snappy = 3, attached_node = 1, flammable = 2,farming_wilt=1}
|
||||
wilt_def.groups["step"] = -1
|
||||
minetest.register_node(":" .. idef.wilt_name, wilt_def)
|
||||
end
|
||||
|
||||
|
||||
farming.register_seed=function(sdef)
|
||||
|
@ -346,11 +383,14 @@ farming.register_steps = function(sdef)
|
|||
end
|
||||
end
|
||||
-- for some crops you should walk slowly through like a wheat field
|
||||
if ndef.groups["liquid_viscosity"] then
|
||||
if ndef.groups["liquid_viscosity"] and farming.config:get_int("viscosity") > 0 then
|
||||
-- if ndef.groups["liquid_viscosity"] then
|
||||
local step_viscosity=math.ceil(ndef.groups["liquid_viscosity"]*i/sdef.steps)
|
||||
if step_viscosity > 0 then
|
||||
ndef.liquid_viscosity= step_viscosity
|
||||
ndef.liquidtype="source"
|
||||
ndef.liquid_alternative_source=ndef.description
|
||||
ndef.liquid_alternative_flowing=ndef.description
|
||||
ndef.liquid_renewable=false
|
||||
ndef.liquid_range=0
|
||||
end
|
||||
|
@ -371,6 +411,17 @@ farming.register_steps = function(sdef)
|
|||
if i == sdef.steps then
|
||||
ndef.groups["farming_fullgrown"]=1
|
||||
ndef.on_dig = farming.harvest_on_dig
|
||||
if sdef.groups.wiltable ~= nil then
|
||||
print(sdef.wilt_name)
|
||||
if sdef.wilt_name then
|
||||
ndef.next_step=sdef.wilt_name
|
||||
else
|
||||
ndef.next_step = sdef.step_name .. "_" .. (i - 1)
|
||||
end
|
||||
ndef.on_timer = farming.step_on_timer
|
||||
ndef.grow_time_min=sdef.wilt_time or 10
|
||||
ndef.grow_time_max=math.ceil(ndef.grow_time_min*1.1)
|
||||
end
|
||||
end
|
||||
-- at the end stage you can harvest by change a cultured seed (if defined)
|
||||
if (i == sdef.steps and sdef.next_plant ~= nil) then
|
||||
|
@ -383,7 +434,7 @@ farming.register_steps = function(sdef)
|
|||
ndef.on_punch = farming.step_on_punch
|
||||
end
|
||||
-- print(dump(ndef))
|
||||
minetest.register_node(":" .. sdef.step_name .. "_" .. i, ndef)
|
||||
minetest.register_node(":" .. ndef.description, ndef)
|
||||
end
|
||||
-- farming.register_lbm(lbm_nodes,sdef)
|
||||
end
|
||||
|
@ -674,6 +725,7 @@ farming.step_on_timer = function(pos, elapsed)
|
|||
if def.place_param2 then
|
||||
placenode.param2 = def.place_param2
|
||||
end
|
||||
-- minetest.set_node(pos, {name = def.next_step, param2 = 1})
|
||||
minetest.swap_node(pos, placenode)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_int("farming:step",def.groups.step)
|
||||
|
@ -767,7 +819,6 @@ farming.place_seed = function(itemstack, placer, pointed_thing, plantname)
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- add the node and remove 1 item from the itemstack
|
||||
minetest.add_node(pt.above, {name = plantname, param2 = 1})
|
||||
local wait_min=farming.wait_min or 120
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 244 B |
Binary file not shown.
After Width: | Height: | Size: 244 B |
Loading…
Reference in New Issue