enable ores in MCL2, fix some undeclared globals, fix icecap growth in MCL (achievements are a good debugging tool)

This commit is contained in:
FaceDeer 2022-08-21 16:38:34 -06:00
parent b593e3935c
commit e7d8b3ba42
7 changed files with 61 additions and 30 deletions

View File

@ -66,7 +66,7 @@ minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack
local achievement = plant_node_achievements[newnode.name] local achievement = plant_node_achievements[newnode.name]
if not achievement then return end if not achievement then return end
local achievement_name = achievement.achievement local achievement_name = achievement.achievement
if not player_awards or player_awards.unlocked[achievement_name] ~= achievement_name then if not player_awards.unlocked or player_awards.unlocked[achievement_name] ~= achievement_name then
-- all of the growable plants in DFCaverns are timer-based. If you place -- all of the growable plants in DFCaverns are timer-based. If you place
-- a seedling or seed and the resulting node has a timer running, then -- a seedling or seed and the resulting node has a timer running, then
-- it's passed the checks to see if it was placed in a growable area. -- it's passed the checks to see if it was placed in a growable area.

View File

@ -10,6 +10,9 @@ df_achievements = {}
local old_awards_version = false local old_awards_version = false
if awards.run_trigger_callbacks then if awards.run_trigger_callbacks then
-- older versions of awards crash when attempting to use newer versions of triggers
-- this "run_trigger_callbacks" API call is present in those older versions, so using that
-- as a fingerprint to discover them
old_awards_version = true old_awards_version = true
else else
-- used to track the progress of achievements that are based off of other achievements -- used to track the progress of achievements that are based off of other achievements
@ -37,6 +40,8 @@ awards.register_achievement = function(achievement_name, achievement_def, ...)
achievement_def.trigger = nil achievement_def.trigger = nil
end end
-- The achievement being registered has "parent" achievements that progress when it is unlocked,
-- track that here
if achievement_def._dfcaverns_achievements then if achievement_def._dfcaverns_achievements then
for _, parent_achievement in pairs(achievement_def._dfcaverns_achievements) do for _, parent_achievement in pairs(achievement_def._dfcaverns_achievements) do
local parent_source_list = achievement_parents[parent_achievement] or {} local parent_source_list = achievement_parents[parent_achievement] or {}

View File

@ -59,18 +59,22 @@ minetest.register_globalstep(function(dtime)
local player_name local player_name
local player_awards local player_awards
local unlocked
local player_data local player_data
local biome
local totals
-- loop through players -- loop through players
for _, player in pairs(minetest.get_connected_players()) do for _, player in pairs(minetest.get_connected_players()) do
player_name = player:get_player_name() player_name = player:get_player_name()
player_awards = awards.player(player_name) player_awards = awards.player(player_name)
if player_awards.unlocked["dfcaverns_visit_all_caverns"] ~= "dfcaverns_visit_all_caverns" or unlocked = player_awards.unlocked or {}
player_awards.unlocked["dfcaverns_visit_glowing_pit"] ~= "dfcaverns_visit_glowing_pit" then
if unlocked["dfcaverns_visit_all_caverns"] ~= "dfcaverns_visit_all_caverns" or
unlocked["dfcaverns_visit_glowing_pit"] ~= "dfcaverns_visit_glowing_pit" then
player_data = get_player_data(player) player_data = get_player_data(player)
biome = player_data.biome biome = player_data.biome
totals = player_data.totals totals = player_data.totals
if biome == "towercap" and check_nodes(node_types.towercap, totals) then if biome == "towercap" and check_nodes(node_types.towercap, totals) then
awards.unlock(player_name, "dfcaverns_visit_tower_cap") awards.unlock(player_name, "dfcaverns_visit_tower_cap")
elseif biome == "fungiwood" and check_nodes(node_types.fungiwood, totals) then elseif biome == "fungiwood" and check_nodes(node_types.fungiwood, totals) then
@ -106,7 +110,7 @@ minetest.register_globalstep(function(dtime)
awards.unlock(player_name, "dfcaverns_visit_underworld") awards.unlock(player_name, "dfcaverns_visit_underworld")
end end
if (totals["df_underworld_items:glow_amethyst"] or 0) > 1 and if (totals["df_underworld_items:glow_amethyst"] or 0) > 1 and
player_awards.unlocked["dfcaverns_visit_glowing_pit"] ~= "dfcaverns_visit_glowing_pit" then unlocked["dfcaverns_visit_glowing_pit"] ~= "dfcaverns_visit_glowing_pit" then
local player_pos = player:get_pos() local player_pos = player:get_pos()
local pit = df_caverns.get_nearest_glowing_pit(player_pos) local pit = df_caverns.get_nearest_glowing_pit(player_pos)
pit.location.y = player_pos.y pit.location.y = player_pos.y
@ -122,10 +126,10 @@ minetest.register_globalstep(function(dtime)
awards.unlock(player_name, "dfcaverns_visit_primordial_jungle") awards.unlock(player_name, "dfcaverns_visit_primordial_jungle")
end end
end end
if player_awards.unlocked["dfcaverns_visit_chasm"] ~= "dfcaverns_visit_chasm" and chasms.is_in_chasm(player:get_pos()) then if unlocked["dfcaverns_visit_chasm"] ~= "dfcaverns_visit_chasm" and chasms.is_in_chasm(player:get_pos()) then
awards.unlock(player_name, "dfcaverns_visit_chasm") awards.unlock(player_name, "dfcaverns_visit_chasm")
end end
if player_awards.unlocked["dfcaverns_visit_pit"] ~= "dfcaverns_visit_pit" then if unlocked["dfcaverns_visit_pit"] ~= "dfcaverns_visit_pit" then
local pos = player:get_pos() local pos = player:get_pos()
local pos_y = pos.y local pos_y = pos.y
if pos_y < -30 then -- ignore pits when near the surface if pos_y < -30 then -- ignore pits when near the surface

View File

@ -95,6 +95,8 @@ minetest.register_globalstep(function(dtime)
timer = 0 timer = 0
local player_name local player_name
local number
local ambience
-- loop through players -- loop through players
for _, player in pairs(minetest.get_connected_players()) do for _, player in pairs(minetest.get_connected_players()) do

View File

@ -37,7 +37,10 @@ df_dependencies.mods_required.mcl_mapgen = true
local old_overworld_min local old_overworld_min
local ores_extended = false
local extend_ores = function() local extend_ores = function()
if ores_extended then return end -- should only do this once.
ores_extended = true
local ores_registered = {} local ores_registered = {}
for key, val in pairs(minetest.registered_ores) do for key, val in pairs(minetest.registered_ores) do
ores_registered[val.ore] = true ores_registered[val.ore] = true
@ -75,16 +78,19 @@ local extend_ores = function()
local blob_copy = deep_copy(stone_blobs) local blob_copy = deep_copy(stone_blobs)
blob_copy.ore = ore blob_copy.ore = ore
blob_copy.clust_num_ores = cluster_size blob_copy.clust_num_ores = cluster_size
blob_copy.clust_size = math.ceil(math.sqrt(cluster_size))
blob_copy.clust_scarcity = cluster_scarcity_cuberoot*cluster_scarcity_cuberoot*cluster_scarcity_cuberoot
blob_copy.seed = localseed blob_copy.seed = localseed
blob_copy.cluster_scarcity = cluster_scarcity_cuberoot*cluster_scarcity_cuberoot*cluster_scarcity_cuberoot
blob_copy.y_min = ymin or stone_blobs.y_min blob_copy.y_min = ymin or stone_blobs.y_min
blob_copy.y_max = ymax or stone_blobs.y_max blob_copy.y_max = ymax or stone_blobs.y_max
--minetest.debug(dump(blob_copy))
minetest.register_ore(blob_copy)
end end
local scattered_ore = { local scattered_ore = {
wherein = wherein_stonelike, wherein = wherein_stonelike,
ore_type = "scatter", ore_type = "scatter",
ore = "mcl_core:stone_with_coal", --ore = "mcl_core:stone_with_coal",
clust_scarcity = 525*3, clust_scarcity = 525*3,
clust_num_ores = 5, clust_num_ores = 5,
clust_size = 3, clust_size = 3,
@ -94,24 +100,27 @@ local extend_ores = function()
noise_threshold= 0, noise_threshold= 0,
} }
local register_scattered_internal = function(ore, cluster_size, cluster_scarcity_cuberoot, threshold, ymin, ymax) local register_scattered_internal = function(ore, cluster_size, cluster_scarcity_cuberoot, threshold, ymin, ymax, wherein)
local scattered_copy = deep_copy(scattered_ore) local scattered_copy = deep_copy(scattered_ore)
scattered_copy.ore = ore scattered_copy.ore = ore
scattered_copy.cluster_size = cluster_size*cluster_size*cluster_size scattered_copy.clust_size = cluster_size*cluster_size*cluster_size
scattered_copy.clust_num_ores = math.ceil(scattered_copy.cluster_size/3) scattered_copy.clust_scarcity = cluster_scarcity_cuberoot*cluster_scarcity_cuberoot*cluster_scarcity_cuberoot
scattered_copy.clust_num_ores = math.ceil(scattered_copy.clust_size/3)
scattered_copy.seed = localseed scattered_copy.seed = localseed
scattered_copy.cluster_scarcity = cluster_scarcity_cuberoot*cluster_scarcity_cuberoot*cluster_scarcity_cuberoot
scattered_copy.threshold = threshold scattered_copy.threshold = threshold
scattered_copy.y_min = ymin or scattered_ore.y_min scattered_copy.y_min = ymin or scattered_ore.y_min
scattered_copy.y_max = ymax or scattered_ore.y_max scattered_copy.y_max = ymax or scattered_ore.y_max
scattered_copy.wherein = wherein or scattered_ore.wherein
--minetest.debug(dump(scattered_copy))
minetest.register_ore(scattered_copy)
end end
local register_scattered = function(ore, cluster_size, cluster_scarcity_cuberoot, ymin, ymax) local register_scattered = function(ore, cluster_size, cluster_scarcity_cuberoot, ymin, ymax, wherein)
assert(not (ymin and ymax) or ymin < ymax, "Elevation parameter error for register_scattered") assert(not (ymin and ymax) or ymin < ymax, "Elevation parameter error for register_scattered")
localseed = localseed + 1 -- increment this every time it's called to ensure different distributions localseed = localseed + 1 -- increment this every time it's called to ensure different distributions
-- same seed makes the noise patterns overlap. -- same seed makes the noise patterns overlap.
-- one produces widespread smaller clusters, other produces larger clusters at the peaks of the noise in addition to the smaller ones -- one produces widespread smaller clusters, other produces larger clusters at the peaks of the noise in addition to the smaller ones
register_scattered_internal(ore, cluster_size, cluster_scarcity_cuberoot, 0, ymin, ymax) register_scattered_internal(ore, cluster_size, cluster_scarcity_cuberoot, 0, ymin, ymax, wherein)
register_scattered_internal(ore, cluster_size*2, cluster_scarcity_cuberoot, 0.25, ymin, ymax) register_scattered_internal(ore, cluster_size*2, cluster_scarcity_cuberoot, 0.25, ymin, ymax, wherein)
end end
if ores_registered["mcl_core:diorite"] then if ores_registered["mcl_core:diorite"] then
@ -130,7 +139,10 @@ local extend_ores = function()
table.insert(wherein_stonelike, "mcl_core:granite") table.insert(wherein_stonelike, "mcl_core:granite")
end end
if ores_registered["mcl_core:dirt"] then if ores_registered["mcl_core:dirt"] then
register_blob("mcl_core:dirt", 33, 15) register_blob("mcl_core:dirt", 33, 15, config.sunless_sea_min)
if config.enable_primordial then
register_blob("mcl_core:dirt", 33, 15, config.primordial_min, config.primoridal_max)
end
end end
if ores_registered["mcl_core:gravel"] then if ores_registered["mcl_core:gravel"] then
register_blob("mcl_core:gravel", 33, 14) register_blob("mcl_core:gravel", 33, 14)
@ -181,19 +193,22 @@ local extend_ores = function()
register_scattered("mcl_core:stone_with_copper", 3, 18) register_scattered("mcl_core:stone_with_copper", 3, 18)
end end
if ores_registered["mcl_deepslate:deepslate"] then
register_blob("mcl_deepslate:deepslate", 33, 15, lowest_elevation, config.sunless_sea_min) -- it's called deepslate, so put it deep
end
if ores_registered["mcl_deepslate:tuff"] then
register_blob("mcl_deepslate:tuff", 33, 15, lowest_elevation, config.sunless_sea_min)
end
-- more blobs if ores_registered["mcl_deepslate:deepslate_with_emerald"] then
--"mcl_deepslate:deepslate" register_scattered("mcl_deepslate:deepslate_with_emerald", 1, 25, lowest_elevation, config.sunless_sea_min, "mcl_deepslate:deepslate")
--"mcl_deepslate:tuff" end
if ores_registered["mcl_core:stone_with_emerald"] then
-- apparently very rare register_scattered("mcl_core:stone_with_emerald", 1, 25, lowest_elevation, config.sunless_sea_min)
--"mcl_deepslate:deepslate_with_emerald" end
--"mcl_core:stone_with_emerald"
end end
if minetest.get_modpath("mcl_init") then -- Mineclone 2 if minetest.get_modpath("mcl_init") then -- Mineclone 2
old_overworld_min = mcl_vars.mg_overworld_min -- remember this for weather control old_overworld_min = mcl_vars.mg_overworld_min -- remember this for weather control
@ -203,9 +218,11 @@ if minetest.get_modpath("mcl_init") then -- Mineclone 2
mcl_vars.mg_lava_overworld_max = mcl_vars.mg_overworld_min + 10 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_end_max = mcl_vars.mg_overworld_min - 2000
if minetest.settings:get_bool("mcl_generate_ores", true) then -- shouldn't need to worry about the setting, extend_ores checks if the ores
-- have already been registered.
--if minetest.settings:get_bool("mcl_generate_ores", true) then
extend_ores() extend_ores()
end --end
df_dependencies.mods_required.mcl_structures = true df_dependencies.mods_required.mcl_structures = true
-- never mind - add dependency on mcl_strongholds and these will get generated before overworld_min gets changed. -- never mind - add dependency on mcl_strongholds and these will get generated before overworld_min gets changed.
@ -248,6 +265,8 @@ if minetest.get_modpath("mcl_mapgen") then -- Mineclone 5
.."does not have an mcl_mapgen.on_settings_changed method. This will likely result in " .."does not have an mcl_mapgen.on_settings_changed method. This will likely result in "
.."altitudes below the original bedrock being inaccessible to players.") .."altitudes below the original bedrock being inaccessible to players.")
end end
extend_ores()
end end
if minetest.get_modpath("mcl_worlds") then if minetest.get_modpath("mcl_worlds") then
local old_has_weather = mcl_worlds.has_weather local old_has_weather = mcl_worlds.has_weather

View File

@ -26,7 +26,8 @@ end
df_trees.nether_cap_growth_permitted = function(pos) df_trees.nether_cap_growth_permitted = function(pos)
local below_name = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name local below_name = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name
return minetest.get_item_group(below_name, "cools_lava") > 0 and minetest.get_item_group(below_name, "nether_cap") == 0 return (minetest.get_item_group(below_name, "cools_lava") > 0 or minetest.get_item_group(below_name, "ice") > 0)
and minetest.get_item_group(below_name, "nether_cap") == 0
end end
df_trees.spindlestem_growth_permitted = function(pos) df_trees.spindlestem_growth_permitted = function(pos)

View File

@ -16,7 +16,7 @@ looped_node_sound.register = function(def)
local max_hear_distance = def.max_hear_distance or 32 local max_hear_distance = def.max_hear_distance or 32
-- Update sound for player -- Update sound for player
function update_player_sound(player) local function update_player_sound(player)
local player_name = player:get_player_name() local player_name = player:get_player_name()
-- Search for nodes in radius around player -- Search for nodes in radius around player
local ppos = player:get_pos() local ppos = player:get_pos()