mirror of
https://github.com/FaceDeer/dfcaverns.git
synced 2025-01-24 09:10:19 +01:00
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:
parent
5ea9ee9de0
commit
a6cd433ecf
@ -47,7 +47,12 @@ df_caverns.register_biome_check(function(pos, heat, humidity)
|
|||||||
end
|
end
|
||||||
local biome = get_biome(heat, humidity)
|
local biome = get_biome(heat, humidity)
|
||||||
if biome == "bloodnether" then
|
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"
|
return "nethercap"
|
||||||
end
|
end
|
||||||
return "bloodthorn"
|
return "bloodthorn"
|
||||||
|
@ -28,6 +28,7 @@ df_caverns.register_biome_check = function(func)
|
|||||||
table.insert(get_biome_at_pos_list, func)
|
table.insert(get_biome_at_pos_list, func)
|
||||||
end
|
end
|
||||||
df_caverns.get_biome = function(pos)
|
df_caverns.get_biome = function(pos)
|
||||||
|
pos = vector.round(pos)
|
||||||
local heat = minetest.get_heat(pos)
|
local heat = minetest.get_heat(pos)
|
||||||
local humidity = minetest.get_humidity(pos)
|
local humidity = minetest.get_humidity(pos)
|
||||||
for _, val in pairs(get_biome_at_pos_list) do
|
for _, val in pairs(get_biome_at_pos_list) do
|
||||||
|
@ -17,6 +17,17 @@ if mapgen_helper.log_location_enabled then
|
|||||||
log_location = mapgen_helper.log_first_location
|
log_location = mapgen_helper.log_first_location
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Exposed as a global so that other mods can override it.
|
||||||
|
df_caverns.populate_puzzle_chest = function(pos)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
for i = 1, math.random(1,8) do
|
||||||
|
local item = ItemStack(df_underworld_items.colour_items[math.random(1,#df_underworld_items.colour_items)])
|
||||||
|
--item:set_count(math.random(1,4))
|
||||||
|
inv:add_item("main", item)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local name_pit = function() end
|
local name_pit = function() end
|
||||||
local name_ruin = function() end
|
local name_ruin = function() end
|
||||||
|
|
||||||
@ -81,8 +92,6 @@ if named_waypoints_path then
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
local c_slade = df_caverns.node_id.slade
|
local c_slade = df_caverns.node_id.slade
|
||||||
local c_slade_block = df_caverns.node_id.slade_block
|
local c_slade_block = df_caverns.node_id.slade_block
|
||||||
local c_air = df_caverns.node_id.air
|
local c_air = df_caverns.node_id.air
|
||||||
@ -496,13 +505,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
if puzzle_chest then
|
if puzzle_chest then
|
||||||
local def = minetest.registered_nodes["df_underworld_items:puzzle_chest_closed"]
|
local def = minetest.registered_nodes["df_underworld_items:puzzle_chest_closed"]
|
||||||
def.can_dig(puzzle_chest) -- initializes the inventory
|
def.can_dig(puzzle_chest) -- initializes the inventory
|
||||||
local meta = minetest.get_meta(puzzle_chest)
|
df_caverns.populate_puzzle_chest(puzzle_chest)
|
||||||
local inv = meta:get_inventory()
|
|
||||||
for i = 1, math.random(1,8) do
|
|
||||||
local item = ItemStack(df_underworld_items.colour_items[math.random(1,#df_underworld_items.colour_items)])
|
|
||||||
--item:set_count(math.random(1,4))
|
|
||||||
inv:add_item("main", item)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
elseif building.building_type == "medium building" then
|
elseif building.building_type == "medium building" then
|
||||||
|
Loading…
Reference in New Issue
Block a user