changed spreading of crops
parent
56f2334fe4
commit
db6c0693cc
|
@ -26,7 +26,7 @@ local sdef={
|
|||
inventory_image = "farming_blackberry.png",
|
||||
eat_hp=2,
|
||||
spread = {spreadon = farming.change_soil or {"default:dirt_with_grass"},
|
||||
base_rate = 100,
|
||||
base_rate = 1,
|
||||
spread = 50,
|
||||
intervall = 12,
|
||||
change = 0.00001, --part of soil, which get plants
|
||||
|
|
|
@ -25,7 +25,7 @@ local sdef={
|
|||
description = S("Cocoa"),
|
||||
inventory_image = "farming_cocoa.png",
|
||||
spread = {spreadon = farming.change_soil or {"default:dirt_with_grass"},
|
||||
base_rate = 100,
|
||||
base_rate = 1,
|
||||
spread = 50,
|
||||
intervall = 12,
|
||||
change = 0.00001, --part of soil, which get plants
|
||||
|
|
|
@ -24,7 +24,7 @@ local sdef={
|
|||
description = S("Coffee"),
|
||||
inventory_image = "farming_coffee.png",
|
||||
spread = {spreadon = farming.change_soil or {"default:dirt_with_grass"},
|
||||
base_rate = 100,
|
||||
base_rate = 1,
|
||||
spread = 50,
|
||||
intervall = 12,
|
||||
change = 0.00001, --part of soil, which get plants
|
||||
|
|
|
@ -26,7 +26,7 @@ local sdef={
|
|||
inventory_image = "farming_raspberry.png",
|
||||
eat_hp=2,
|
||||
spread = {spreadon = farming.change_soil or {"default:dirt_with_grass"},
|
||||
base_rate = 100,
|
||||
base_rate = 1,
|
||||
spread = 50,
|
||||
intervall = 12,
|
||||
change = 0.00001, --part of soil, which get plants
|
||||
|
|
|
@ -26,7 +26,7 @@ local sdef={
|
|||
inventory_image = "farming_strawberry.png",
|
||||
eat_hp=2,
|
||||
spread = {spreadon = farming.change_soil or {"default:dirt_with_grass"},
|
||||
base_rate = 100,
|
||||
base_rate = 1,
|
||||
spread = 50,
|
||||
intervall = 12,
|
||||
change = 0.00001, --part of soil, which get plants
|
||||
|
|
54
init.lua
54
init.lua
|
@ -41,5 +41,59 @@ minetest.register_abm({
|
|||
})
|
||||
]]
|
||||
|
||||
-- replacement LBM for pre-nodetimer plants
|
||||
minetest.register_lbm({
|
||||
name = ":farming:start_nodetimer_",
|
||||
nodenames = "groups:farming",
|
||||
action = function(pos, node)
|
||||
minetest.get_node_timer(pos):start(math.random(farming.wait_min,farming.wait_max))
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = farming.change_soil,
|
||||
neighbors = {"air"},
|
||||
interval = 5+math.random(-1,1), -- little noise
|
||||
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
|
||||
local ptlight=minetest.get_node_light(ptabove)
|
||||
if ptlight < 5 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:farming") > 2 then
|
||||
return
|
||||
end
|
||||
if math.random(0,10) < 1 then
|
||||
local node_temp=minetest.get_heat(pos)
|
||||
local node_hum=minetest.get_humidity(pos)
|
||||
local sc={}
|
||||
for _,line in ipairs(farming.spreading_crops) do
|
||||
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,line.base_rate do
|
||||
table.insert(sc,1,line.name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if #sc > 0 then
|
||||
local rand_plant = math.random(1,#sc)
|
||||
minetest.add_node(ptabove, {name=sc[rand_plant],param2=1})
|
||||
minetest.get_node_timer(ptabove):start(math.random(10, 15))
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
minetest.log("action", "[MOD]"..minetest.get_current_modname().." -- loaded ")
|
||||
|
|
32
register.lua
32
register.lua
|
@ -237,7 +237,6 @@ farming.register_seed=function(sdef)
|
|||
minetest.register_node(":" .. sdef.seed_name, seed_def)
|
||||
end
|
||||
|
||||
|
||||
farming.register_steps = function(pname,sdef)
|
||||
-- check if plant gives harvest, where seed can be extractet or gives directly seed
|
||||
local has_harvest = true
|
||||
|
@ -285,15 +284,15 @@ farming.register_steps = function(pname,sdef)
|
|||
"walkable","buildable_to","seed_name","plant_name","harvest_name"}) do
|
||||
ndef[colu]=node_def[colu]
|
||||
end
|
||||
ndef.groups = {snappy = 3, flammable = 2,flora=1, plant = 1, not_in_creative_inventory = 1, attached_node = 1}
|
||||
ndef.groups = {snappy = 3, flammable = 2,flora=1, plant = 1, not_in_creative_inventory = 1, attached_node = 1, farming = 1}
|
||||
if sdef["snappy"] then
|
||||
ndef.groups["snappy"] = sdef["snappy"]
|
||||
end
|
||||
ndef.groups[pname] = i
|
||||
ndef.tiles={sdef.mod_name.."_"..sdef.plant_name.."_"..i..".png"}
|
||||
if i < sdef.steps then
|
||||
ndef.next_step=sdef.harvest_name .. "_" .. (i + 1)
|
||||
lbm_nodes[#lbm_nodes + 1] = sdef.harvest_name .. "_" .. i
|
||||
ndef.next_step=sdef.step_name .. "_" .. (i + 1)
|
||||
lbm_nodes[#lbm_nodes + 1] = sdef.step_name .. "_" .. i
|
||||
ndef.on_timer = farming.step_on_timer
|
||||
end
|
||||
local base_rarity = 1
|
||||
|
@ -323,11 +322,11 @@ farming.register_steps = function(pname,sdef)
|
|||
table.insert(ndef.drop.items,1,{items={sdef.next_plant},rarity=sdef.next_plant_rarity})
|
||||
end
|
||||
if i == sdef.steps and is_punchable then
|
||||
ndef.pre_step = sdef.harvest_name .. "_" .. (i - 1)
|
||||
ndef.pre_step = sdef.step_name .. "_" .. (i - 1)
|
||||
ndef.on_punch = farming.step_on_punch
|
||||
end
|
||||
-- print(dump(ndef))
|
||||
minetest.register_node(":" .. sdef.harvest_name .. "_" .. i, ndef)
|
||||
minetest.register_node(":" .. sdef.step_name .. "_" .. i, ndef)
|
||||
end
|
||||
farming.register_lbm(lbm_nodes,sdef)
|
||||
end
|
||||
|
@ -436,7 +435,7 @@ farming.register_mapgen = function(mdef)
|
|||
},
|
||||
y_min = mdef.spawnon.spawn_min,
|
||||
y_max = mdef.spawnon.spawn_max,
|
||||
decoration = mdef.wildname or mdef.harvest_name.."_"..mdef.steps,
|
||||
decoration = mdef.wildname or mdef.step_name.."_"..mdef.steps,
|
||||
spawn_by = mdef.spawnon.spawnby,
|
||||
num_spawn_by = mdef.spawnon.spawn_num,
|
||||
-- biomes = farming.get_biomes(def)
|
||||
|
@ -459,6 +458,7 @@ farming.register_plant = function(name, def)
|
|||
def.mod_name = name:split(":")[1]
|
||||
def.plant_name = name:split(":")[2]
|
||||
def.harvest_name=def.mod_name..":"..def.plant_name
|
||||
def.step_name=def.mod_name..":"..def.plant_name
|
||||
def.seed_name=def.mod_name..":seed_"..def.plant_name
|
||||
|
||||
-- check if plant gives harvest, where seed can be extractet or gives directly seed
|
||||
|
@ -497,13 +497,19 @@ farming.register_plant = function(name, def)
|
|||
|
||||
farming.register_steps(def.plant_name,def)
|
||||
|
||||
if (def.spawnon) then
|
||||
farming.register_mapgen(def)
|
||||
end
|
||||
if (def.spread) then
|
||||
for i=1,def.spread.base_rate do
|
||||
table.insert(farming.spreading_crops,1,{def.harvest_name.."_1"})
|
||||
-- if (def.spawnon) then
|
||||
-- farming.register_mapgen(def)
|
||||
-- end
|
||||
if (def.spread) and (not def.groups["no_spawn"]) then
|
||||
local spread_def={name=def.step_name.."_1",
|
||||
temp_min=def.min_temp,temp_max=def.max_temp,
|
||||
hum_min=def.min_humidity,hum_max=def.max_humidity,
|
||||
y_min=0,y_max=31000,base_rate = def.spread.base_rate}
|
||||
if (def.spawnon) then
|
||||
spread_def.y_min=def.spawnon.spawn_min
|
||||
spread_def.y_max=def.spawnon.spawn_max
|
||||
end
|
||||
table.insert(farming.spreading_crops,1,spread_def)
|
||||
end
|
||||
|
||||
if is_infectable then
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 244 B |
Binary file not shown.
Before Width: | Height: | Size: 356 B After Width: | Height: | Size: 356 B |
Before Width: | Height: | Size: 145 B After Width: | Height: | Size: 145 B |
Binary file not shown.
After Width: | Height: | Size: 149 B |
Loading…
Reference in New Issue