DevTest: /test_place_node skips dummy/cb nodes

This commit is contained in:
Wuzzy 2022-10-08 18:58:02 +02:00 committed by sfan5
parent 23ef0d0916
commit c1e732448c
3 changed files with 9 additions and 3 deletions

@ -6,6 +6,7 @@ minetest.register_craftitem("callbacks:callback_item_1", {
description = "Callback test item 1\n(Use/Drop + Sneak to switch to item 2)", description = "Callback test item 1\n(Use/Drop + Sneak to switch to item 2)",
inventory_image = "callbacks_callback_item_1.png", inventory_image = "callbacks_callback_item_1.png",
wield_image = "callbacks_callback_item_1.png", wield_image = "callbacks_callback_item_1.png",
groups = { callback_test = 1 },
on_secondary_use = function(itemstack, user, pointed_thing) on_secondary_use = function(itemstack, user, pointed_thing)
minetest.log("[callbacks:callback_item_1 on_secondary_use] " .. itemstack:get_name()) minetest.log("[callbacks:callback_item_1 on_secondary_use] " .. itemstack:get_name())
@ -81,6 +82,7 @@ minetest.register_craftitem("callbacks:callback_item_2", {
description = "Callback test item 2\n(Use to switch to item 1)", description = "Callback test item 2\n(Use to switch to item 1)",
inventory_image = "callbacks_callback_item_2.png", inventory_image = "callbacks_callback_item_2.png",
wield_image = "callbacks_callback_item_2.png", wield_image = "callbacks_callback_item_2.png",
groups = { callback_test = 1 },
on_use = function(itemstack, user, pointed_thing) on_use = function(itemstack, user, pointed_thing)
minetest.log("[callbacks:callback_item_2 on_use]") minetest.log("[callbacks:callback_item_2 on_use]")

@ -7,7 +7,7 @@ minetest.register_node("callbacks:callback_node", {
description = "Callback Test Node (construct/destruct/timer)".."\n".. description = "Callback Test Node (construct/destruct/timer)".."\n"..
"Tests callbacks: on_construct, after_place_node, on_destruct, after_destruct, after_dig_node, on_timer", "Tests callbacks: on_construct, after_place_node, on_destruct, after_destruct, after_dig_node, on_timer",
tiles = {"callbacks_callback_node.png"}, tiles = {"callbacks_callback_node.png"},
groups = {dig_immediate=3}, groups = {callback_test=1, dig_immediate=3},
-- This was known to cause a bug in minetest.item_place_node() when used -- This was known to cause a bug in minetest.item_place_node() when used
-- via minetest.place_node(), causing a placer with no position -- via minetest.place_node(), causing a placer with no position
paramtype2 = "facedir", paramtype2 = "facedir",

@ -91,7 +91,7 @@ end
minetest.register_chatcommand("test_place_nodes", { minetest.register_chatcommand("test_place_nodes", {
params = "[ no_param2 ]", params = "[ no_param2 ]",
description = "Test: Place all nodes and optionally their permissible param2 variants", description = "Test: Place all nodes (except dummy and callback nodes) and optionally their permissible param2 variants",
func = function(name, param) func = function(name, param)
local player = minetest.get_player_by_name(name) local player = minetest.get_player_by_name(name)
if not player then if not player then
@ -113,7 +113,11 @@ minetest.register_chatcommand("test_place_nodes", {
local nodes = {} local nodes = {}
local emerge_estimate = 0 local emerge_estimate = 0
for itemstring, def in pairs(minetest.registered_nodes) do for itemstring, def in pairs(minetest.registered_nodes) do
if itemstring ~= "ignore" then if itemstring ~= "ignore" and
-- Skip callback test and dummy nodes
-- to avoid clutter and chat spam
minetest.get_item_group(itemstring, "callback_test") == 0 and
minetest.get_item_group(itemstring, "dummy") == 0 then
table.insert(nodes, itemstring) table.insert(nodes, itemstring)
if def.paramtype2 == 0 then if def.paramtype2 == 0 then
emerge_estimate = emerge_estimate + 1 emerge_estimate = emerge_estimate + 1