4 Commits

8 changed files with 87 additions and 16 deletions

60
API.md Normal file
View File

@ -0,0 +1,60 @@
# Chat commands
There are not many chat commands provided by this modpack since it's primarily a mapgen mod. Only one is available to non-server-admins:
`mute_df_ambience`: Mutes or unmutes ambient sounds in deep caverns. This muted state is saved per-player, so players that are bothered by ambient sounds can disable them for themselves.
The following are only available for server admins:
`find_pit`: Finds the nearest glowing pit in the Underworld layer.
`mapgen_helper_loc` and `mapgen_helper_tour`: only available if the `mapgen_helper_log_locations` setting has been set to true. mapgen_helper will then record the locations of various types of mapgen feature as they are generated, and these commands will teleport the server admin to them.
`find_pit_caves`: Lists the locations of nearby vertical shaft caverns, including the top and bottom elevations.
# APIs
Not all APIs are listed here, this list focuses on APIs that modders may wish to use in sub-mods that modify DF Caverns' functionality in the existing context of this modpack.
## bones_loot
This mod populates the bones in the underworld with loot.
`bones_loot.register_loot`
Uses same table format as dungeon_loot from the default minetest_game. eg, {{name = "bucket:bucket_water", chance = 0.45, types = {"sandstone", "desert"}},
if dungeon_loot is installed it uses dungeon_loot's registration function directly.
## chasms
`chasms.register_ignore(node_name)`: Use this to set node types to be left alone by chasm-carving
`chasms.is_in_chasm(pos)`: returns true if pos is inside a chasm.
## df_ambience
`df_ambience.add_set(def)`: adds a sound set to the ambience mod. See soundsets.lua for a bunch of examples of what can go in the `def` table.
This mod has a lot of similarities to the [https://notabug.org/TenPlus1/ambience](ambience) mod, but after struggling to get that mod to "play nice" with df_caverns' needs it turned out to be easier to just re-implement the specific parts of the mod that were needed here.
## df_caverns
`df_caverns.get_biome(pos)`: returns the string name of the df_cavern biome that pos is located in, or nil if it's outside of any of df_caverns' cavern layers. df_caverns uses a homebrew biome system rather than the built-in biome registration system.
`df_caverns.is_ground_content(node_id)`: used by subterrane's mapgen to avoid removing nodes placed by df_caverns' mapgen. If you're adding new map features inside dfcavern's hollow spaces and they're being chopped in half at mapblock boundaries then you may be able to solve this by overriding this method with one that recognizes the nodes you're adding.
This was never really expected to be something that someone would need to do, though, so this is a little clunky. If you're having trouble with this please file an issue.
`df_caverns.populate_puzzle_chest(pos)`: When a "puzzle chest" is generated in the Underworld ruins this method gets called to populate its contents. If you wish to override the contents of the puzzle chest then you can override this method. Place items in the "main" inventory at the pos parameter's location.
## looped_node_sound
`looped_node_sound.register(def)`: A simple mod for making nodes emit a looped sound when the player is nearby.
def = {
node_list = {"df_trees:torchspine_1_lit"},
sound = "dfcaverns_torchspine_loop",
max_gain = 0.5,
gain_per_node = 0.05,
}

View File

@ -28,6 +28,8 @@ Some of the other cave decorations provide dim bioluminescent lighting in some c
[A more comprehensive guide can be found here.](guide.md) [A more comprehensive guide can be found here.](guide.md)
[APIs and player commands can be found here.](API.md)
## Synergies with other mods ## Synergies with other mods
"[dynamic liquid](https://github.com/minetest-mods/dynamic_liquid)" is recommended to provide Dwarf Fortress-like fluid dynamics and to deal with water that might spill into caverns. "[dynamic liquid](https://github.com/minetest-mods/dynamic_liquid)" is recommended to provide Dwarf Fortress-like fluid dynamics and to deal with water that might spill into caverns.

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -6,8 +6,8 @@ df_dependencies.mods_required = {}
df_dependencies.select_required = function(def) df_dependencies.select_required = function(def)
local ret local ret
for _, dependency in ipairs(def) do for _, dependency in ipairs(def) do
mod = dependency[1] local mod = dependency[1]
item = dependency[2] local item = dependency[2]
df_dependencies.mods_required[mod] = true df_dependencies.mods_required[mod] = true
if minetest.get_modpath(mod) then if minetest.get_modpath(mod) then
ret = item ret = item
@ -20,8 +20,8 @@ end
df_dependencies.select_optional = function(def) df_dependencies.select_optional = function(def)
local ret local ret
for _, dependency in ipairs(def) do for _, dependency in ipairs(def) do
mod = dependency[1] local mod = dependency[1]
item = dependency[2] local item = dependency[2]
df_dependencies.mods_required[mod] = true df_dependencies.mods_required[mod] = true
if minetest.get_modpath(mod) then if minetest.get_modpath(mod) then
ret = item ret = item

View File

@ -111,7 +111,7 @@ minetest.register_craftitem("df_farming:sugar", {
_doc_items_longdesc = df_farming.doc.sweet_pod_sugar_desc, _doc_items_longdesc = df_farming.doc.sweet_pod_sugar_desc,
_doc_items_usagehelp = df_farming.doc.sweet_pod_sugar_usage, _doc_items_usagehelp = df_farming.doc.sweet_pod_sugar_usage,
inventory_image = "dfcaverns_sugar.png", inventory_image = "dfcaverns_sugar.png",
groups = {dfcaverns_cookable = 1, sugar = 1}, groups = {dfcaverns_cookable = 1, sugar = 1, food_sugar = 1},
}) })
local recipe_registered = false local recipe_registered = false

View File

@ -40,7 +40,7 @@ local slade_drill_def = {
light_source = minetest.LIGHT_MAX, light_source = minetest.LIGHT_MAX,
description = S("Slade Drill"), description = S("Slade Drill"),
inventory_image = "dfcaverns_slade_drill.png", inventory_image = "dfcaverns_slade_drill.png",
groups = {cracky=3, stone=1, slade=1, pit_plasma_resistant=1, mese_radiation_shield=1,creative_breakable=1, material_stone=1}, groups = {cracky=3, slade=1, pit_plasma_resistant=1, mese_radiation_shield=1,creative_breakable=1, material_stone=1},
sounds = df_dependencies.sound_stone({ footstep = { name = "bedrock2_step", gain = 1 } }), sounds = df_dependencies.sound_stone({ footstep = { name = "bedrock2_step", gain = 1 } }),
_mcl_blast_resistance = 8, _mcl_blast_resistance = 8,
_mcl_hardness = 5, _mcl_hardness = 5,