Add debug command to spawn mcl_farming plant nodes

This patch adds the debug command “/generate_farming_plant_rows”. The
command generates rows of plants and stems per plant type near a player.
A farming soil or glass node is placed below each node, so players can
find and examine possible gaps between a plant node and a node below.
master
Nils Dagsson Moskopp 2022-04-18 05:13:38 +02:00
parent 1ce88e7528
commit de8ea11b39
No known key found for this signature in database
GPG Key ID: A3BC671C35191080
1 changed files with 70 additions and 0 deletions

View File

@ -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
})