Can't find any in the docs.
Tried registering under same name, but deco registration doesn't follow the colon convention, so exactly same name doesn't work because it's already taken, and using colon prefix it just registers a new decoration with the name beginning with a colon leaving the old definition intact.
Any way to override registered decoration?
Re: Any way to override registered decoration?
Nevermind, looks like there's no dedicated api for that, but the workaround is simple enough not to bother.
Code: Select all
local exclude = {"default:apple_tree"}
local decpy = table.copy(minetest.registered_decorations)
minetest.clear_registered_decorations()
for k,v in pairs(decpy) do
if not isin(v.name,exclude) then minetest.register_decoration(v) end
end
- sirrobzeroone
- Member
- Posts: 593
- Joined: Mon Jul 16, 2018 07:56
- GitHub: sirrobzeroone
- Contact:
Re: Any way to override registered decoration?
Lua dosen't appear to have builtin "isin" function. I found a function (thanks stackoverflow) that does a check and works so just adding this for others in the future:
Code: Select all
local function has_value (tab, val)
for index, value in pairs(tab) do
if value == val then
return true
end
end
return false
end
local exclude = {"default:apple_tree"}
local decpy = table.copy(minetest.registered_decorations)
minetest.clear_registered_decorations()
for k,v in pairs(decpy) do
if not has_value(exclude,v.name) then minetest.register_decoration(v) end
end
Who is online
Users browsing this forum: No registered users and 8 guests