blockgame/mods/bg_terrain/cleanup.lua
trans_soup 7df5d33d02 refactor: extract repeated code into api function.
move function `starts_with`, which was declared twice in separate files,
to the api, and make those files use that function instead.
2023-10-17 14:58:15 +02:00

23 lines
622 B
Lua

-- rename from bg_core to bg_terrain.
minetest.register_lbm({
name = "bg_terrain:rename_core_mod",
nodenames = {
"core:stone",
"core:cobblestone",
"core:dirt",
"core:grass",
"bg_core:stone",
"bg_core:cobblestone",
"bg_core:dirt",
"bg_core:grass",
},
run_at_every_load = true,
action = function (pos, node)
local prefix = ""
if blockgame.starts_with(node.name, "core") then prefix = "core"
elseif blockgame.starts_with(node.name, "bg_core") then prefix = "bg_core" end
local name = string.sub(node.name, string.len(prefix) + 1)
minetest.set_node(pos, {name = "bg_terrain" .. name})
end,
})