Automatically register ALL doors

Fixes brick-based doors not being rotatable.
main
copygirl 1 year ago
parent 28de8125fd
commit 0037cf4e3f
  1. 24
      init.lua

@ -18,6 +18,7 @@ local update_rotating_state = nc_extended_rotating.state.update_rotating_state
local get_rotating_state = nc_extended_rotating.state.get_rotating_state
-- TODO: Fix HUD showing rotation hint when we wouldn't / can't rotate.
-- TODO: Simplify registration and `on_rightclick` replacement into one call.
-- TODO: Add some more comments.
nodecore.register_playerstep({
@ -56,8 +57,14 @@ do
for _, prism_state in ipairs({ "", "_on", "_gated" }) do
register_rotatable("nc_optics:prism" .. prism_state, PRISM_FILTERED_LOOKUP) end
register_rotatable("nc_doors:panel_plank" , PANEL_FILTERED_LOOKUP)
register_rotatable("nc_doors:panel_cobble", PANEL_FILTERED_LOOKUP)
-- Register all existing door panels.
nodecore.register_on_register_item({
retroactive = true,
func = function(name, def)
if def.groups and def.groups.door_panel and (not def.groups.door)
then register_rotatable(name, PANEL_FILTERED_LOOKUP) end
end,
})
end
local function handle_rightclick(pos, node, clicker)
@ -91,8 +98,17 @@ do
for _, lens_state in ipairs({ "", "_on", "_gated" }) do
replace_optics_on_rightclick("nc_optics:prism" .. lens_state) end
replace_panel_on_rightclick("nc_doors:panel_plank" , "nc_woodwork:staff")
replace_panel_on_rightclick("nc_doors:panel_cobble", "nc_lode:rod_tempered")
-- Replace `on_rightclick` for all existing doors' panels.
nodecore.register_on_register_item({
retroactive = true,
func = function(name, def)
if def.groups and def.groups.door then
local panel = def.drop_in_place -- The panel version of the door.
local pin = def.drop -- Dropped item is the door's pin.
replace_panel_on_rightclick(panel.name, pin.name)
end
end,
})
end
-- Override `nc_scaling`'s default empty hand right-click behavior so we can use it

Loading…
Cancel
Save