Fix a crash in ambient sound biome checking when the player is halfway between level 2 and level 3. Also add API to puzzle chests

This fixes issue https://github.com/FaceDeer/dfcaverns/issues/39
This commit is contained in:
FaceDeer
2022-10-22 10:02:34 -06:00
parent 5ea9ee9de0
commit a6cd433ecf
3 changed files with 19 additions and 10 deletions

View File

@ -47,7 +47,12 @@ df_caverns.register_biome_check(function(pos, heat, humidity)
end
local biome = get_biome(heat, humidity)
if biome == "bloodnether" then
if subterrane.get_cavern_value("cavern layer 3", pos) < 0 then
local cavern_value = subterrane.get_cavern_value("cavern layer 3", pos)
if cavern_value == nil then
-- this shouldn't happen, the pos.y check above should prevent it.
return nil
end
if cavern_value < 0 then
return "nethercap"
end
return "bloodthorn"