add an api to chasms to let other mods build bridges without them being chopped up

This commit is contained in:
FaceDeer 2021-04-04 22:59:17 -06:00
parent 3d7c2b43a4
commit b3525c98d5
1 changed files with 16 additions and 7 deletions

View File

@ -2,6 +2,13 @@ local data = {}
chasms = {}
local ignore = {}
-- Use this to set node types to be left alone by chasm-carving
chasms.register_ignore = function(node_name)
ignore[minetest.get_content_id(node_name)] = true
end
local maxy = tonumber(minetest.settings:get("chasms_maxy")) or -50
local miny = tonumber(minetest.settings:get("chasms_miny")) or -2500
local falloff = tonumber(minetest.settings:get("chasms_falloff")) or 100
@ -129,16 +136,18 @@ minetest.register_on_generated(function(minp, maxp, seed)
local waver = math.min(math.max(math.floor(waver_data[i]+0.5), -waver_strength), waver_strength)
local intensity = get_intensity(y)
if chasm_data[chasm_area:index(x+waver, y, z)]*intensity > chasms_threshold then
if webs_present then
webs = webs or calculate_web_array(minp, maxp) -- only calculate webs when we know we're in a chasm
if webs[y + z*z_displace] and math.random() < 0.85 then -- random holes in the web
data[i] = c_web
minetest.get_node_timer({x=x,y=y,z=z}):start(1) -- this timer will check for unsupported webs
if not ignore[data[i]] then
if webs_present then
webs = webs or calculate_web_array(minp, maxp) -- only calculate webs when we know we're in a chasm
if webs[y + z*z_displace] and math.random() < 0.85 then -- random holes in the web
data[i] = c_web
minetest.get_node_timer({x=x,y=y,z=z}):start(1) -- this timer will check for unsupported webs
else
data[i] = c_air
end
else
data[i] = c_air
end
else
data[i] = c_air
end
end
end