Compare commits

...

6 Commits

Author SHA1 Message Date
Jacob Lifshay de08a9d481
Fix bedrock in mineclone2 (#49)
* adjust more mcl_vars variables that were recently added to MineClone2

* try to detect mcl_vars values that should have been changed
2023-12-03 00:36:34 -07:00
Github is a non-free platform owned by Microsoft. Reasonable alternatives exist, such as Gitea, Sourcehut. We need a federated, mastodon-like forge based on ForgeFed. See: https://forgefed.org 8edf220213
fix crash when fake player dig slade (#46)
When a fake player, for example a node, dig slade, it return player ~= nil but it is not a current player, the server_diggable_only function tries to check the privs of the node, then this crashes

Here we use the built-in check player:is_player() so the node privs are not checked

This crash occurred in the technic mod when the corium eats the slade
2023-12-03 00:33:53 -07:00
FaceDeer 2f2577eada add mine_gas to optional depends 2023-01-08 02:38:10 -07:00
Awkanimus 06096ddc8f
No achievement when torch is placed by mods (#43) 2022-12-05 00:29:35 -07:00
FaceDeer b27a9eb8da Add a bit of API documentation. Incomplete, but covers the important stuff IMO 2022-10-22 22:43:29 -06:00
FaceDeer a6cd433ecf 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
2022-10-22 10:02:34 -06:00
9 changed files with 112 additions and 15 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)
[APIs and player commands can be found here.](API.md)
## 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.

View File

@ -60,6 +60,7 @@ local plant_node_achievements =
}
minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack, pointed_thing)
if placer == nil then return end
local player_name = placer:get_player_name()
if player_name == nil then return end
local player_awards = awards.player(player_name)
@ -150,4 +151,4 @@ awards.register_achievement("dfcaverns_plant_all_farmables", {
achievement_name="dfcaverns_plant_all_farmables",
target=df_achievements.get_child_achievement_count("dfcaverns_plant_all_farmables"),
},
})
})

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"

View File

@ -1,4 +1,4 @@
name = df_caverns
description = Adds vast underground caverns in the style of Dwarf Fortress, complete with underground flora in diverse biomes. Also adds stalactite/stalagmite decorations in the smaller tunnels.
depends = df_dependencies, subterrane, df_trees, df_mapitems
optional_depends = df_farming, ice_sprites, oil, df_underworld_items, magma_conduits, bones_loot, named_waypoints, name_generator, fireflies, chasms, big_webs, mcl_flowers
depends = df_dependencies, subterrane, df_trees, df_mapitems,
optional_depends = df_farming, ice_sprites, oil, df_underworld_items, magma_conduits, bones_loot, named_waypoints, name_generator, fireflies, chasms, big_webs, mcl_flowers, mine_gas

View File

@ -28,6 +28,7 @@ df_caverns.register_biome_check = function(func)
table.insert(get_biome_at_pos_list, func)
end
df_caverns.get_biome = function(pos)
pos = vector.round(pos)
local heat = minetest.get_heat(pos)
local humidity = minetest.get_humidity(pos)
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
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_ruin = function() end
@ -81,8 +92,6 @@ if named_waypoints_path then
end
end
local c_slade = df_caverns.node_id.slade
local c_slade_block = df_caverns.node_id.slade_block
local c_air = df_caverns.node_id.air
@ -496,13 +505,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
if puzzle_chest then
local def = minetest.registered_nodes["df_underworld_items:puzzle_chest_closed"]
def.can_dig(puzzle_chest) -- initializes the inventory
local meta = minetest.get_meta(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
df_caverns.populate_puzzle_chest(puzzle_chest)
end
end)
elseif building.building_type == "medium building" then

View File

@ -215,8 +215,33 @@ if minetest.get_modpath("mcl_init") then -- Mineclone 2
mcl_vars.mg_overworld_min = lowest_elevation
mcl_vars.mg_bedrock_overworld_min = mcl_vars.mg_overworld_min
mcl_vars.mg_bedrock_overworld_max = mcl_vars.mg_overworld_min + 4
mcl_vars.mg_lava_overworld_max = mcl_vars.mg_overworld_min + 10
mcl_vars.mg_end_max = mcl_vars.mg_overworld_min - 2000
mcl_vars.mg_realm_barrier_overworld_end_max = mcl_vars.mg_end_max
mcl_vars.mg_realm_barrier_overworld_end_min = mcl_vars.mg_end_max - 11
-- try to detect any variables that should have been modified but weren't
local bad_entries = {}
for k, v in pairs(mcl_vars) do
-- if a value is in this range, it's probably a new value added by MineClone2 that we should be adjusting, add it to the table
if type(v) == "number" and v <= old_overworld_min + 10 and v >= mcl_vars.mg_overworld_min + 100 then
bad_entries[k] = v
end
end
-- mark variables as ignored that we intentionally don't change, like so:
-- bad_entries.mg_value_that_shouldnt_be_adjusted = nil
for k, v in pairs(bad_entries) do
local new_value = v + mcl_vars.mg_overworld_min - old_overworld_min
minetest.log("error", "dfcaverns: variable wasn't modified or marked as ignored! guessing new value:")
minetest.log("error", "mcl_var." .. tostring(k) .. " = " .. tostring(new_value) .. " -- was " .. tostring(v))
minetest.log("error", "if it shouldn't be changed, mark it as ignored in df_dependencies/mapgen.lua like so:")
minetest.log("error", "bad_entries." .. tostring(k) .. " = nil")
minetest.log("error", "This is a bug, please report it to https://github.com/FaceDeer/dfcaverns/issues/new")
mcl_vars[k] = new_value
end
-- shouldn't need to worry about the setting, extend_ores checks if the ores
-- have already been registered.

View File

@ -3,7 +3,7 @@ local S = minetest.get_translator(minetest.get_current_modname())
local invulnerable = df_underworld_items.config.invulnerable_slade and not minetest.settings:get_bool("creative_mode")
local server_diggable_only = function(pos, player)
if player then
if player and player:is_player() then
return minetest.check_player_privs(player, "server")
end
return false
@ -181,4 +181,4 @@ end
if minetest.get_modpath("mesecons_mvps") and df_underworld_items.config.invulnerable_slade then
mesecon.register_mvps_stopper("df_underworld_items:slade")
end
end