From b46c589a38c98b4fe84716922dbabb21841bca67 Mon Sep 17 00:00:00 2001 From: mruncreative <67873653+mruncreative@users.noreply.github.com> Date: Wed, 16 Oct 2024 00:27:20 +0200 Subject: [PATCH] Support doors and trapdoors from mods (#683) * Support doors and trapdoors from mods Removed hardcoded door names and instead now use the API of the door mod to meseconify all doors and trapdoors that have been registered after the mods are finished loading. * indentation as described by sfan5 --- mesecons_doors/init.lua | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/mesecons_doors/init.lua b/mesecons_doors/init.lua index 420029a0..8b6b33cb 100644 --- a/mesecons_doors/init.lua +++ b/mesecons_doors/init.lua @@ -82,15 +82,6 @@ local function meseconify_door(name) end end -local doors_list = { - "doors:door_wood", - "doors:door_steel", - "doors:door_glass", - "doors:door_obsidian_glass", - "xpanes:door_steel_bar", -} -for i=1,#doors_list do meseconify_door(doors_list[i]) end - -- Trapdoor local function trapdoor_switch(name) return function(pos, node) @@ -140,9 +131,15 @@ local function meseconify_trapdoor(name) end end -local trapdoors_list = { - "doors:trapdoor", - "doors:trapdoor_steel", - "xpanes:trapdoor_steel_bar" -} -for i=1,#trapdoors_list do meseconify_trapdoor(trapdoors_list[i]) end +minetest.register_on_mods_loaded(function() + for k,_ in pairs(doors.registered_doors) do + if k:find("_a$") then + meseconify_door(k:sub(1,-3)) + end + end + for k,_ in pairs(doors.registered_trapdoors) do + if not k:find("_open$") then + meseconify_trapdoor(k) + end + end +end)