ethereal_rebalance/init.lua

70 lines
1.9 KiB
Lua

--[[
Copyright 2024 Andrey Stepanov
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
]]--
local decor_to_exclude = {}
decor_to_exclude["default:cactus"] = { "desert", }
local function has_value(tab, value)
for _, v in pairs(tab) do
if v == value then
return true
end
end
return false
end
local function is_empty(tab)
if next(tab) == nil then
return true
else
return false
end
end
local decorations_backup = table.copy(minetest.registered_decorations)
minetest.clear_registered_decorations()
for _, decoration in pairs(decorations_backup) do
local biomes_to_exclude = decor_to_exclude[decoration.decoration]
if biomes_to_exclude == nil then
minetest.register_decoration(decoration)
else
local biomes_backup = table.copy(decoration.biomes)
decoration.biomes = {}
for _, biome in pairs(biomes_backup) do
if not has_value(biomes_to_exclude, biome) then
table.insert(decoration.biomes, biome)
end
end
if not is_empty(decoration.biomes) then
minetest.register_decoration(decoration)
end
end
end
-- cactus
minetest.register_decoration(
{
decoration = "default:cactus",
deco_type = "simple",
biomes = { "desert" },
sidelen = 80,
y_min = 1,
y_max = 100,
place_on = { "default:desert_sand" },
fill_ratio = 0.001,
height_max = 4
}
)