From d9e4af9ecea9bdea273a0a7ea7a2da6aa4ab56fc Mon Sep 17 00:00:00 2001 From: Aaron Suen Date: Thu, 20 Oct 2022 07:27:03 -0400 Subject: [PATCH] Fix place_as_node facedir anisotropy When a facedir node drops/lands on the ground, it should be facing a random direction instead of biased toward one specific orientation. --- mods/nc_items/node.lua | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/mods/nc_items/node.lua b/mods/nc_items/node.lua index 73d0693d..1cfbed29 100644 --- a/mods/nc_items/node.lua +++ b/mods/nc_items/node.lua @@ -1,6 +1,8 @@ -- LUALOCALS < --------------------------------------------------------- -local ItemStack, minetest, nodecore - = ItemStack, minetest, nodecore +local ItemStack, math, minetest, nodecore + = ItemStack, math, minetest, nodecore +local math_random + = math.random -- LUALOCALS > --------------------------------------------------------- local modname = minetest.get_current_modname() @@ -83,7 +85,11 @@ function nodecore.place_stack(pos, stack, placer, pointed_thing) if stack:get_count() == 1 then local def = minetest.registered_nodes[stack:get_name()] if def and def.groups and def.groups.stack_as_node then - nodecore.set_loud(pos, {name = stack:get_name()}) + local node = {name = stack:get_name()} + if def.paramtype2 == "facedir" then + node.param2 = math_random(0, 3) + end + nodecore.set_loud(pos, node) if def.after_place_node then def.after_place_node(pos, nil, stack) end