From 1075257bb1d018e00b5bb84e23383cb8e67b3a09 Mon Sep 17 00:00:00 2001 From: copygirl Date: Thu, 26 Oct 2023 11:30:52 +0200 Subject: [PATCH] Export get_node_active_selection_box --- utility.lua | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/utility.lua b/utility.lua index f42da82..7ac5e13 100644 --- a/utility.lua +++ b/utility.lua @@ -8,9 +8,11 @@ local rotate_box_by_facedir = nc_extended_rotating.rotate.rotate_box_by_facedir local DEFAULT_SELECTION_BOX = { min = vector.new(-0.5, -0.5, -0.5), max = vector.new( 0.5, 0.5, 0.5) } +local utility = {} + -- Gets the active `selection_box` for the specified `node` which -- has a `paramtype2` of `facedir`, based on its `param2` value. -local function get_node_active_selection_box(node) +function utility.get_node_active_selection_box(node) local def = minetest.registered_nodes[node.name] local box = def.selection_box and def.selection_box.fixed -- No need to rotate the default selection box. @@ -25,15 +27,12 @@ local function get_node_active_selection_box(node) return box end - -local utility = {} - -- Calculates the rotation vector from where a player is looking at on this node. -- * If looking near an edge, the vector points in the direction of that edge. -- * If looking near a corner, the vector similarly points in that direction. -- * Otherwise, vector simply points away from the face. function utility.rotation_vector_from_lookat(node, pointed_thing, edge_distance) - local box = get_node_active_selection_box(node) + local box = utility.get_node_active_selection_box(node) local center = (box.min + box.max) / 2 -- Calculate bounds, single vector describing the size of the selection box.