blockgame/mods/bg_api/cleanup.lua
trans_soup 7755583fa4 rename mods and add hacky cleanup thing.
rename mods; add `bg_` prefix.

add hacky cleanup ABM (couldn't get LBM:s to work), that converts old
nodes into new ones according to this rename.

the cleanup doesn't do anything for items, though.
2023-10-15 18:22:13 +02:00

19 lines
552 B
Lua

-- move from old modnames to new ones. (old ones didn't have the `bg_` prefix.)
minetest.register_on_mods_loaded(function ()
local nodes = minetest.registered_nodes
local names = {}
for name, _ in pairs(nodes) do
table.insert(names, string.sub(name, 4))
end
-- using LBM:s doesn't work for some reason, so this ABM hack thing is used instead.
minetest.register_abm({
nodenames = names,
interval = 10,
chance = 1,
action = function (pos, node)
local name = node.name
minetest.set_node(pos, {name = "bg_" .. name})
end,
})
end)