diff --git a/onion.lua b/onion.lua index 2bc2dba..83bf730 100644 --- a/onion.lua +++ b/onion.lua @@ -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 diff --git a/strawberry.lua b/strawberry.lua index 753fed4..16329c6 100644 --- a/strawberry.lua +++ b/strawberry.lua @@ -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