Let NodeCore fix non-canonical facedir itself

With commit 24e2e7b7, NodeCore has changed its rotation API.
It now automatically fixes "non-canonical" facedir values on
node update, and `spindata` is no longer.
main
copygirl 2 months ago
parent f4ac338afa
commit 0efd61af6d
  1. 7
      init.lua
  2. 2
      state.lua
  3. 10
      utility.lua

@ -9,11 +9,8 @@ nc_extended_rotating.entity = include("entity") -- Depends on `utility`.
nc_extended_rotating.registry = include("registry") -- Depends on `rotate` and `state` (late).
nc_extended_rotating.state = include("state") -- Depends on `registry`, `rotate` and `utility`.
do
-- Do a quick check if we're using a compatible version of NodeCore.
local lens_def = minetest.registered_nodes["nc_optics:lens"]
if not lens_def.spindata then error("Requires NodeCore 966ed012 or later") end
end
-- Do a quick check if we're using a compatible version of NodeCore.
if not nodecore.param2_canonical then error("Requires NodeCore 24e2e7b7 or later") end
-------------------------------------
-- Register Player Update Function --

@ -4,7 +4,6 @@ local math_round, minetest, vector
local is_rightclick_filtered = nc_extended_rotating.registry.is_rightclick_filtered;
local is_rotatable = nc_extended_rotating.registry.is_rotatable;
local rotate_facedir = nc_extended_rotating.rotate.rotate_facedir;
local fix_rotatable_facedir = nc_extended_rotating.utility.fix_rotatable_facedir;
local rotation_vector_from_lookat = nc_extended_rotating.utility.rotation_vector_from_lookat;
-- Distance at which we want to rotate by "pushing" on an edge.
@ -66,7 +65,6 @@ local function calculate_rotating_state(player, data)
state.invert = is_sneaking
state.facedir = rotate_facedir(state.node.param2, state.axis, -degrees)
state.facedir = fix_rotatable_facedir(state.node, state.facedir)
state.success = state.facedir and state.facedir ~= state.node.param2
-- TODO: Until we have a way to display "rotation non-success", don't show rotation hint at all.

@ -44,14 +44,4 @@ function utility.rotation_vector_from_lookat(node, pointed_thing, edge_distance)
return b - math_abs(p) <= edge_distance and math_sign(p) or 0 end)
end
-- NodeCore only has a couple of "canonical" orientations for its nodes.
-- This returns a canonical facedir equivalent to the one passed in.
function utility.fix_rotatable_facedir(node, facedir)
local name = node and node.name or ""
local def = minetest.registered_nodes[name]
if not def then return nil end
if not def.spindata then return facedir end
return def.spindata.equiv[facedir]
end
return utility

Loading…
Cancel
Save