#9 third wilt mechanism for nettle is implemented.
parent
188ac1b86d
commit
8a207ea962
|
@ -24,6 +24,7 @@ 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
|
||||
farming.min_light = 14
|
||||
|
||||
-- node type, where grain can be randomly found
|
||||
farming.change_soil = {}
|
||||
|
|
|
@ -1,5 +1,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,,,,,,
|
||||
default,1,,10,8,2,1,,,,,,,,,,,,,,,,,3,,,15,80,10,80,0,200,11,14,1E-05,0.001,0.0001,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,,,,,,,,,,,
|
||||
|
@ -13,7 +13,7 @@ culturewheat,1,,100,4,3,,1,,1,1,,2,1,,,,1,,1,3,,1,3,,2,25,,40,,,,10,,,,,100,5,fa
|
|||
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,,,,
|
||||
hemp,1,,10,8,2,,,,1,,,,,,,,1,,,,,,3,,2,,120,,,,,8,,,,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
|
||||
|
@ -25,7 +25,7 @@ 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,,,,
|
||||
nettle,1,,10,5,2,1,,,1,,,3,,1,,,1,,,2,,,3,1,3,5,150,0,100,,2000,8,,,,0.1,7,,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,,,
|
||||
|
|
18
init.lua
18
init.lua
|
@ -59,15 +59,24 @@ minetest.register_abm({
|
|||
return
|
||||
end
|
||||
local ptlight=minetest.get_node_light(ptabove)
|
||||
if ptlight < 5 then
|
||||
if ptlight < farming.min_light then
|
||||
return
|
||||
end
|
||||
local ptlight=minetest.get_node_light(ptabove,.5)
|
||||
if ptlight < farming.min_light then
|
||||
return
|
||||
end
|
||||
-- only for positions, where not too many plants are nearby
|
||||
-- first check if any crops are nearby, because the counting
|
||||
-- of nearby crops is time consuming
|
||||
if minetest.find_node_near(pos,4,"group:farming") ~= nil then
|
||||
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:farming") > 2 then
|
||||
-- print("ping")
|
||||
return
|
||||
end
|
||||
end
|
||||
if math.random(0,100) < 1 then
|
||||
local node_temp=minetest.get_heat(pos)
|
||||
local node_hum=minetest.get_humidity(pos)
|
||||
|
@ -76,15 +85,18 @@ minetest.register_abm({
|
|||
if line.temp_min<=node_temp and line.temp_max>=node_temp then
|
||||
if line.hum_min<=node_hum and line.hum_max>=node_hum then
|
||||
if line.y_min<=pos.y and line.y_max>=pos.y then
|
||||
for k=1,math.floor(math.log(line.base_rate)*(-2)) do
|
||||
if line.light_min<=ptlight and line.light_max >= ptlight then
|
||||
for k=1,math.floor(math.log(line.base_rate*1e10)) do
|
||||
table.insert(sc,1,line.name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if #sc > 0 then
|
||||
local rand_plant = math.random(1,#sc)
|
||||
-- print(sc[rand_plant])
|
||||
--[[
|
||||
local pdef = minetest.registered_nodes[ sc[rand_plant] ]
|
||||
local day_start=99999
|
||||
|
|
77
register.lua
77
register.lua
|
@ -96,7 +96,9 @@ farming.register_plant = function(def)
|
|||
local spread_def={name=def.step_name.."_1",
|
||||
temp_min=edef.temperature_min,temp_max=edef.temperature_max,
|
||||
hum_min=edef.humidity_min,hum_max=edef.humidity_max,
|
||||
y_min=edef.elevation_min,y_max=edef.elevation_max,base_rate = def.spread_rate}
|
||||
y_min=edef.elevation_min,y_max=edef.elevation_max,base_rate = def.spread_rate,
|
||||
light_min=edef.light_min,light_max=edef.light_max}
|
||||
farming.min_light = math.min(farming.min_light,edef.light_min)
|
||||
table.insert(farming.spreading_crops,1,spread_def)
|
||||
end
|
||||
|
||||
|
@ -228,6 +230,7 @@ farming.register_wilt=function(idef)
|
|||
selection_box = {type = "fixed",
|
||||
fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
on_timer = farming.wilt_on_timer,
|
||||
}
|
||||
if idef.straw ~= nil then
|
||||
wilt_def.drop={items={{items={idef.straw}}}}
|
||||
|
@ -238,6 +241,7 @@ farming.register_wilt=function(idef)
|
|||
|
||||
wilt_def.groups = {snappy = 3, attached_node = 1, flammable = 2,farming_wilt=1}
|
||||
wilt_def.groups["step"] = -1
|
||||
wilt_def.groups["wiltable"]=idef.groups.wiltable
|
||||
minetest.register_node(":" .. idef.wilt_name, wilt_def)
|
||||
end
|
||||
|
||||
|
@ -346,7 +350,7 @@ farming.register_steps = function(sdef)
|
|||
ndef[colu]=node_def[colu]
|
||||
end
|
||||
ndef.groups = {snappy = 3, flammable = 2,flora=1, plant = 1, not_in_creative_inventory = 1, attached_node = 1}
|
||||
for _,colu in ipairs({"infectable","snappy","seed_extractable","punchable","damage_per_second","liquid_viscosity"}) do
|
||||
for _,colu in ipairs({"infectable","snappy","seed_extractable","punchable","damage_per_second","liquid_viscosity","wiltable"}) do
|
||||
if sdef.groups[colu] then
|
||||
ndef.groups[colu] = sdef.groups[colu]
|
||||
end
|
||||
|
@ -413,12 +417,21 @@ farming.register_steps = function(sdef)
|
|||
ndef.on_dig = farming.harvest_on_dig
|
||||
if sdef.groups.wiltable ~= nil then
|
||||
print(sdef.wilt_name)
|
||||
if sdef.wilt_name then
|
||||
if sdef.groups.wiltable == 2 then
|
||||
ndef.next_step=sdef.wilt_name
|
||||
else
|
||||
end
|
||||
if sdef.groups.wiltable == 1 then
|
||||
ndef.next_step = sdef.step_name .. "_" .. (i - 1)
|
||||
end
|
||||
if sdef.groups.wiltable == 3 then
|
||||
ndef.pre_step = sdef.step_name .. "_" .. (i - 1)
|
||||
end
|
||||
print(sdef.wilt_name)
|
||||
ndef.on_timer = farming.step_on_timer
|
||||
if sdef.groups.wiltable == 3 then
|
||||
ndef.on_timer = farming.wilt_on_timer
|
||||
ndef.seed_name=sdef.seed_name
|
||||
end
|
||||
ndef.grow_time_min=sdef.wilt_time or 10
|
||||
ndef.grow_time_max=math.ceil(ndef.grow_time_min*1.1)
|
||||
end
|
||||
|
@ -881,6 +894,62 @@ farming.seed_on_timer = function(pos, elapsed)
|
|||
end
|
||||
end
|
||||
|
||||
-- actuall quite easy function to remove wilt plants
|
||||
farming.wilt_on_timer = function(pos, elapsed)
|
||||
local node = minetest.get_node(pos)
|
||||
local name = node.name
|
||||
local def = minetest.registered_nodes[name]
|
||||
-- print(dump(def))
|
||||
if def.groups.wiltable <= 2 then -- normal crop
|
||||
minetest.swap_node(pos, {name="air"})
|
||||
end
|
||||
if def.groups.wiltable == 3 then -- nettle or weed
|
||||
print("nettle")
|
||||
-- determine all nearby nodes with soil
|
||||
local pos0=vector.subtract(pos,2)
|
||||
local pos1=vector.add(pos,2)
|
||||
local neighb=minetest.find_nodes_in_area(pos0,pos1,"group:soil")
|
||||
-- print(dump(neighb))
|
||||
if neighb ~= nil then
|
||||
local freen={}
|
||||
-- get soil nodes with air above
|
||||
for j=1,#neighb do
|
||||
local jpos=neighb[j]
|
||||
-- print(dump(minetest.get_node({x=jpos.x,y=jpos.y+1,z=jpos.z})))
|
||||
if farming.has_value({"air","default:grass_1","default:grass_2","default:grass_3","default:grass_4","default:grass_5"},minetest.get_node({x=jpos.x,y=jpos.y+1,z=jpos.z}).name) then
|
||||
table.insert(freen,1,jpos)
|
||||
end
|
||||
end
|
||||
-- randomly pick one and spread
|
||||
if #freen >= 1 then
|
||||
print(#freen)
|
||||
local jpos=freen[math.random(1,#freen)]
|
||||
print(name.." spread "..dump(jpos))
|
||||
-- print(dump(def))
|
||||
minetest.add_node({x=jpos.x,y=jpos.y+1,z=jpos.z}, {name = def.seed_name, param2 = 1})
|
||||
minetest.get_node_timer({x=jpos.x,y=jpos.y+1,z=jpos.z}):start(def.grow_time_min or 10)
|
||||
end
|
||||
end
|
||||
-- after spreading the source has a one third change to be removed, to go one step back or stay
|
||||
local wran=math.random(1,3)
|
||||
if wran == 1 then
|
||||
print("remove")
|
||||
minetest.swap_node(pos, {name="air"})
|
||||
end
|
||||
if wran == 2 then
|
||||
print("try to go one step back")
|
||||
if def.pre_step ~= nil then
|
||||
print("done")
|
||||
minetest.swap_node(pos, {name=def.pre_step, param2=1})
|
||||
minetest.get_node_timer(pos):start(math.random(def.grow_time_min or 10,def.grow_time_max or 20))
|
||||
end
|
||||
end
|
||||
if wran == 3 then
|
||||
minetest.get_node_timer(pos):start(math.random(def.grow_time_min or 10,def.grow_time_max or 20))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
farming.seed_on_place = function(itemstack, placer, pointed_thing)
|
||||
local under = pointed_thing.under
|
||||
local node = minetest.get_node(under)
|
||||
|
|
Loading…
Reference in New Issue