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
This commit is contained in:
mruncreative 2024-10-16 00:27:20 +02:00 committed by GitHub
parent ac83dead50
commit b46c589a38
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -82,15 +82,6 @@ local function meseconify_door(name)
end end
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 -- Trapdoor
local function trapdoor_switch(name) local function trapdoor_switch(name)
return function(pos, node) return function(pos, node)
@ -140,9 +131,15 @@ local function meseconify_trapdoor(name)
end end
end end
local trapdoors_list = { minetest.register_on_mods_loaded(function()
"doors:trapdoor", for k,_ in pairs(doors.registered_doors) do
"doors:trapdoor_steel", if k:find("_a$") then
"xpanes:trapdoor_steel_bar" meseconify_door(k:sub(1,-3))
} end
for i=1,#trapdoors_list do meseconify_trapdoor(trapdoors_list[i]) end end
for k,_ in pairs(doors.registered_trapdoors) do
if not k:find("_open$") then
meseconify_trapdoor(k)
end
end
end)