Skip to content

Commit

Permalink
add strawberry and wild onion to farming.registered_crops (thanks nix…
Browse files Browse the repository at this point in the history
…noxus)
  • Loading branch information
tenplus1 committed Feb 22, 2022
1 parent bba8bc3 commit d22d8a3
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 64 deletions.
75 changes: 45 additions & 30 deletions onion.lua
Original file line number Diff line number Diff line change
Expand Up @@ -65,40 +65,55 @@ crop_def.drop = {
}
minetest.register_node("ethereal:onion_5", table.copy(crop_def))


-- growing routine if farming redo isn't present
if not farming or not farming.mod or farming.mod ~= "redo" then

minetest.register_abm({
label = "Ethereal grow onion",
nodenames = {"ethereal:onion_1", "ethereal:onion_2", "ethereal:onion_3", "ethereal:onion_4"},
neighbors = {"farming:soil_wet"},
interval = 11,
chance = 20,
catch_up = false,
action = function(pos, node)

-- are we on wet soil?
pos.y = pos.y - 1
if minetest.get_item_group(minetest.get_node(pos).name, "soil") < 3 then
return
end
pos.y = pos.y + 1
if farming and farming.mod and farming.mod == "redo" then

-- add to registered_plants
farming.registered_plants["ethereal:wild_onion_plant"] = {
crop = "ethereal:onion",
seed = "ethereal:wild_onion_plant",
minlight = farming.min_light,
maxlight = farming.max_light,
steps = 5
}

-- do we have enough light?
local light = minetest.get_node_light(pos)
else

if not light
or light < 13 then
return
end
minetest.register_abm({
label = "Ethereal grow onion",
nodenames = {
"ethereal:onion_1", "ethereal:onion_2", "ethereal:onion_3",
"ethereal:onion_4"
},
neighbors = {"farming:soil_wet"},
interval = 11,
chance = 20,
catch_up = false,
action = function(pos, node)

-- grow to next stage
local num = node.name:split("_")[2]
-- are we on wet soil?
pos.y = pos.y - 1

node.name = "ethereal:onion_" .. tonumber(num + 1)
if minetest.get_item_group(minetest.get_node(pos).name, "soil") < 3 then
return
end

minetest.swap_node(pos, node)
end
})
pos.y = pos.y + 1

end -- END IF
-- do we have enough light?
local light = minetest.get_node_light(pos)

if not light or light < 13 then
return
end

-- grow to next stage
local num = node.name:split("_")[2]

node.name = "ethereal:onion_" .. tonumber(num + 1)

minetest.swap_node(pos, node)
end
})
end
80 changes: 46 additions & 34 deletions strawberry.lua
Original file line number Diff line number Diff line change
Expand Up @@ -84,44 +84,56 @@ crop_def.drop = {
}
minetest.register_node("ethereal:strawberry_8", table.copy(crop_def))


-- growing routine if farming redo isn't present
if not farming or not farming.mod or farming.mod ~= "redo" then

minetest.register_abm({
label = "Ethereal grow strawberry",
nodenames = {
"ethereal:strawberry_1", "ethereal:strawberry_2", "ethereal:strawberry_3",
"ethereal:strawberry_4", "ethereal:strawberry_5", "ethereal:strawberry_6",
"ethereal:strawberry_7"
},
neighbors = {"farming:soil_wet"},
interval = 9,
chance = 20,
catch_up = false,
action = function(pos, node)

-- are we on wet soil?
pos.y = pos.y - 1
if minetest.get_item_group(minetest.get_node(pos).name, "soil") < 3 then
return
end
pos.y = pos.y + 1
if farming and farming.mod and farming.mod == "redo" then

-- add to registered_plants
farming.registered_plants["ethereal:strawberry"] = {
crop = "ethereal:strawberry",
seed = "ethereal:strawberry",
minlight = farming.min_light,
maxlight = farming.max_light,
steps = 8
}

-- do we have enough light?
local light = minetest.get_node_light(pos)
else

if not light
or light < 13 then
return
end
minetest.register_abm({
label = "Ethereal grow strawberry",
nodenames = {
"ethereal:strawberry_1", "ethereal:strawberry_2", "ethereal:strawberry_3",
"ethereal:strawberry_4", "ethereal:strawberry_5", "ethereal:strawberry_6",
"ethereal:strawberry_7"
},
neighbors = {"farming:soil_wet"},
interval = 9,
chance = 20,
catch_up = false,
action = function(pos, node)

-- grow to next stage
local num = node.name:split("_")[2]
-- are we on wet soil?
pos.y = pos.y - 1

node.name = "ethereal:strawberry_" .. tonumber(num + 1)
if minetest.get_item_group(minetest.get_node(pos).name, "soil") < 3 then
return
end

minetest.swap_node(pos, node)
end
})
pos.y = pos.y + 1

end -- END IF
-- do we have enough light?
local light = minetest.get_node_light(pos)

if not light or light < 13 then
return
end

-- grow to next stage
local num = node.name:split("_")[2]

node.name = "ethereal:strawberry_" .. tonumber(num + 1)

minetest.swap_node(pos, node)
end
})
end

0 comments on commit d22d8a3

Please sign in to comment.