@ -1,5 +1,5 @@
local ipairs , ItemStack , vector , include , nodecor e
= ipairs , ItemStack , vector , include , nodecor e
local ipairs , ItemStack , nodecore , include
= ipairs , ItemStack , nodecore , include
rawset ( _G , " nc_extended_rotating " , { } )
nc_extended_rotating.hud = include ( " hud " )
@ -9,6 +9,12 @@ 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
-------------------------------------
-- Register Player Update Function --
-------------------------------------
@ -30,24 +36,17 @@ nodecore.register_playerstep({
-- Register Rotatable NodeCore Nodes --
---------------------------------------
local nodecore_filtered_lookup = nc_extended_rotating.utility . nodecore_filtered_lookup
local register_rotatable = nc_extended_rotating.registry . register_rotatable ;
-- Register lenses.
local LENS_FILTERED_LOOKUP = nodecore_filtered_lookup ( function ( a , b )
return vector.equals ( a.f , b.f ) end )
for _ , lens_state in ipairs ( { " " , " _on " , " _glow " , " _glow_start " } ) do
register_rotatable ( " nc_optics:lens " .. lens_state , nil , LENS_FILTERED_LOOKUP ) end
register_rotatable ( " nc_optics:lens " .. lens_state ) end
-- Register prisms.
local PRISM_FILTERED_LOOKUP = nodecore_filtered_lookup ( function ( a , b )
return vector.equals ( a.f , b.r ) and vector.equals ( a.r , b.f ) end )
for _ , prism_state in ipairs ( { " " , " _on " , " _gated " } ) do
register_rotatable ( " nc_optics:prism " .. prism_state , nil , PRISM_FILTERED_LOOKUP ) end
register_rotatable ( " nc_optics:prism " .. prism_state ) end
-- Register all existing and to-be-registered door panels.
local PANEL_FILTERED_LOOKUP = nodecore_filtered_lookup ( function ( a , b )
return vector.equals ( a.f , b.r ) and vector.equals ( a.r , b.f ) end )
nodecore.register_on_register_item ( {
retroactive = true ,
func = function ( name , def )
@ -57,8 +56,8 @@ nodecore.register_on_register_item({
if def.groups and def.groups . door then
local panel = def.drop_in_place . name -- The panel version of the door.
local pin = def.drop_non_silktouch or def.drop -- Dropped item is the door's pin.
register_rotatable ( panel , nil , PANEL_FILTERED_LOOKUP ,
function ( _ , _ , _ , item_stack ) return ItemStack ( item_stack ) : get_name ( ) == pin end )
register_rotatable ( panel , nil , function ( _ , _ , _ , item_stack )
return ItemStack ( item_stack ) : get_name ( ) == pin end )
end
end ,
} )