Create indestructible nodes after all mods load

This commit is contained in:
LoneWolfHT 2021-04-06 21:21:42 -07:00 committed by GitHub
parent 665ec17c69
commit 8b1de22854
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -117,20 +117,22 @@ local function make_immortal(def)
def.description = def.description and ("Indestructible " .. def.description)
end
local registered_nodes = table.copy(minetest.registered_nodes)
for name, def in pairs(registered_nodes) do
local mod, nodename = name:match"(..-):(.+)"
local prefix = mod_prefixes[mod]
if nodename and prefix and not (def.groups and def.groups.mortal) then
-- HACK to preserve backwards compatibility
local new_name = ":ctf_map:" .. prefix .. nodename
if def.drop == name then
def.drop = new_name
end
make_immortal(def)
minetest.register_node(new_name, def)
if mod == "wool" then
minetest.register_alias("ctf_map:" .. nodename, new_name)
minetest.register_on_mods_loaded(function()
local registered_nodes = table.copy(minetest.registered_nodes)
for name, def in pairs(registered_nodes) do
local mod, nodename = name:match"(..-):(.+)"
local prefix = mod_prefixes[mod]
if nodename and prefix and not (def.groups and def.groups.mortal) then
-- HACK to preserve backwards compatibility
local new_name = ":ctf_map:" .. prefix .. nodename
if def.drop == name then
def.drop = new_name
end
make_immortal(def)
minetest.register_node(new_name, def)
if mod == "wool" then
minetest.register_alias("ctf_map:" .. nodename, new_name)
end
end
end
end
end)