diff --git a/mods/ITEMS/mcl_farming/init.lua b/mods/ITEMS/mcl_farming/init.lua index adce058e..17a4d7c9 100644 --- a/mods/ITEMS/mcl_farming/init.lua +++ b/mods/ITEMS/mcl_farming/init.lua @@ -27,3 +27,73 @@ dofile(minetest.get_modpath("mcl_farming").."/potatoes.lua") -- ========= BEETROOT ========= dofile(minetest.get_modpath("mcl_farming").."/beetroot.lua") + +-- This function generates a row of plantlike and nodebox nodes whose +-- name starts with a given string, starting at a given position. It +-- places a given node below so that the rendering can be examined. +local function generate_plant_row(prefix, pos, below_node) + local i = 1 + for node_name, node in pairs(minetest.registered_nodes) do + if ( + 1 == node_name:find(prefix) and + ( + "plantlike" == node.drawtype or + "nodebox" == node.drawtype + ) + ) then + local node_pos = { + x = pos.x + i, + y = pos.y, + z = pos.z, + } + minetest.set_node( + node_pos, + { + name = node_name, + param2 = node.place_param2 or 0 + } + ) + local below_pos = { + x = node_pos.x, + y = node_pos.y - 1, + z = node_pos.z + } + minetest.set_node( + below_pos, + below_node + ) + i = i + 1 + end + end +end + +minetest.register_chatcommand("generate_farming_plant_rows",{ + description = "Generates rows of mcl_farming plant nodes on farming soil and glass", + privs = { debug = true }, + func = function(name, param) + local player = minetest.get_player_by_name(name) + local pos = player:get_pos() + local node_prefixes = { + "mcl_farming:beetroot", + "mcl_farming:carrot", + "mcl_farming:melon", + "mcl_farming:potato", + "mcl_farming:pumpkin", + "mcl_farming:wheat", + } + for i,node_prefix in ipairs(node_prefixes) do + generate_plant_row( + node_prefix, + pos, + { name = "mcl_farming:soil" } + ) + pos.z = pos.z + 2 + generate_plant_row( + node_prefix, + pos, + { name = "mcl_core:glass" } + ) + pos.z = pos.z + 2 + end + end +})