From 25e4aa59835cf9bdb6b818ba7e91a345abd2765e Mon Sep 17 00:00:00 2001 From: teknomunk Date: Thu, 30 May 2024 21:36:16 -0500 Subject: [PATCH] Fix default value handling during set (allows bool settings to be set to false), add game rules: doMobSpawning, disableRaids, doWeatherCycle, doFireTick --- mods/CORE/vl_tuning/init.lua | 6 +++++- mods/ENTITIES/mcl_mobs/mod.conf | 2 +- mods/ENTITIES/mcl_mobs/spawning.lua | 8 ++++++-- mods/ENVIRONMENT/mcl_raids/init.lua | 6 ++++++ mods/ENVIRONMENT/mcl_raids/mod.conf | 2 +- mods/ENVIRONMENT/mcl_weather/mod.conf | 2 +- mods/ENVIRONMENT/mcl_weather/weather_core.lua | 6 ++++++ mods/ITEMS/mcl_fire/init.lua | 11 +++++++++++ mods/ITEMS/mcl_fire/mod.conf | 2 +- 9 files changed, 38 insertions(+), 7 deletions(-) diff --git a/mods/CORE/vl_tuning/init.lua b/mods/CORE/vl_tuning/init.lua index e203148cc..3c5e3a2cc 100644 --- a/mods/CORE/vl_tuning/init.lua +++ b/mods/CORE/vl_tuning/init.lua @@ -30,7 +30,11 @@ local tunable_class = {} function tunable_class:set(value) local self_type = self.type if type(value) == "string" then - self[1] = self_type.from_string(value) or self.default + local new_value = self_type.from_string(value) + if new_value == nil then new_value = self.default end + + minetest.log("action","new_value="..dump(new_value)) + self[1] = new_value else self[1] = value end diff --git a/mods/ENTITIES/mcl_mobs/mod.conf b/mods/ENTITIES/mcl_mobs/mod.conf index 927c1c905..22b029780 100644 --- a/mods/ENTITIES/mcl_mobs/mod.conf +++ b/mods/ENTITIES/mcl_mobs/mod.conf @@ -1,5 +1,5 @@ name = mcl_mobs author = PilzAdam description = Adds a mob API for mods to add animals or monsters, etc. -depends = mcl_particles, mcl_luck +depends = mcl_particles, mcl_luck, vl_tuning optional_depends = mcl_weather, mcl_explosions, mcl_hunger, mcl_worlds, invisibility, lucky_block, cmi, doc_identifier, mcl_armor, mcl_portals, mcl_experience, mcl_sculk diff --git a/mods/ENTITIES/mcl_mobs/spawning.lua b/mods/ENTITIES/mcl_mobs/spawning.lua index c0e68e55b..318f13e4b 100644 --- a/mods/ENTITIES/mcl_mobs/spawning.lua +++ b/mods/ENTITIES/mcl_mobs/spawning.lua @@ -1,7 +1,12 @@ --lua locals +local S = minetest.get_translator("mcl_mobs") local math, vector, minetest, mcl_mobs = math, vector, minetest, mcl_mobs local mob_class = mcl_mobs.mob_class +local gamerule_doMobSpawning = vl_tuning.setting("gamerule:doMobSpawning", "bool", { + description = S("Whether mobs should spawn naturally, or via global spawning logic, such as for cats, phantoms, patrols, wandering traders, or zombie sieges. Does not affect special spawning attempts, like monster spawners, raids, or iron golems."), default = true +}) + local modern_lighting = minetest.settings:get_bool("mcl_mobs_modern_lighting", true) local nether_threshold = tonumber(minetest.settings:get("mcl_mobs_nether_threshold")) or 11 local end_threshold = tonumber(minetest.settings:get("mcl_mobs_end_threshold")) or 0 @@ -905,8 +910,6 @@ end mcl_mobs.spawn_group = spawn_group -local S = minetest.get_translator("mcl_mobs") - minetest.register_chatcommand("spawn_mob",{ privs = { debug = true }, description=S("spawn_mob is a chatcommand that allows you to type in the name of a mob without 'typing mobs_mc:' all the time like so; 'spawn_mob spider'. however, there is more you can do with this special command, currently you can edit any number, boolean, and string variable you choose with this format: spawn_mob 'any_mob:var:'. any_mob being your mob of choice, mobs_variable being the variable, and variable value being the value of the chosen variable. and example of this format: \n spawn_mob skeleton:var:\n this would spawn a skeleton that wouldn't attack you. REMEMBER-THIS> when changing a number value always prefix it with 'NUM', example: \n spawn_mob skeleton:var:\n this setting the skelly's jump height to 10. if you want to make multiple changes to a mob, you can, example: \n spawn_mob skeleton:var::var::var::var:\n etc."), @@ -1187,6 +1190,7 @@ if mobs_spawn then local timer = 0 minetest.register_globalstep(function(dtime) + if not gamerule_doMobSpawning[1] then return end timer = timer + dtime if timer < WAIT_FOR_SPAWN_ATTEMPT then return end diff --git a/mods/ENVIRONMENT/mcl_raids/init.lua b/mods/ENVIRONMENT/mcl_raids/init.lua index d0c10eb20..dcfb0b55b 100644 --- a/mods/ENVIRONMENT/mcl_raids/init.lua +++ b/mods/ENVIRONMENT/mcl_raids/init.lua @@ -2,6 +2,10 @@ mcl_raids = {} local S = minetest.get_translator(minetest.get_current_modname()) +local gamerule_disableRaids = vl_tuning.setting("gamerule:disableRaids", "bool", { + description = S("Whether raids are disabled"), default = false, +}) + -- Define the amount of illagers to spawn each wave. local waves = { { @@ -291,6 +295,8 @@ mcl_events.register_event("raid",{ exclusive_to_area = 128, enable_bossbar = true, cond_start = function(self) + if gamerule_disableRaids[1] then return false end + --minetest.log("Cond start raid") local r = {} for _,p in pairs(minetest.get_connected_players()) do diff --git a/mods/ENVIRONMENT/mcl_raids/mod.conf b/mods/ENVIRONMENT/mcl_raids/mod.conf index b4616e56b..ba70db917 100644 --- a/mods/ENVIRONMENT/mcl_raids/mod.conf +++ b/mods/ENVIRONMENT/mcl_raids/mod.conf @@ -1,3 +1,3 @@ name = mcl_raids author = PrairieWind -depends = mcl_events, mobs_mc, mcl_potions, mcl_bells, mcl_achievements +depends = mcl_events, mobs_mc, mcl_potions, mcl_bells, mcl_achievements, vl_tuning diff --git a/mods/ENVIRONMENT/mcl_weather/mod.conf b/mods/ENVIRONMENT/mcl_weather/mod.conf index 4f1102b7a..3d5c27839 100644 --- a/mods/ENVIRONMENT/mcl_weather/mod.conf +++ b/mods/ENVIRONMENT/mcl_weather/mod.conf @@ -1,5 +1,5 @@ name = mcl_weather author = xeranas description = Weather and sky handling: Rain, snow, thunderstorm, End and Nether ambience -depends = mcl_init, mcl_worlds +depends = mcl_init, mcl_worlds, vl_tuning optional_depends = lightning diff --git a/mods/ENVIRONMENT/mcl_weather/weather_core.lua b/mods/ENVIRONMENT/mcl_weather/weather_core.lua index 32d8db4df..0f2b0f381 100644 --- a/mods/ENVIRONMENT/mcl_weather/weather_core.lua +++ b/mods/ENVIRONMENT/mcl_weather/weather_core.lua @@ -2,6 +2,10 @@ local S = minetest.get_translator(minetest.get_current_modname()) local math = math +local gamerule_doWeatherCycle = vl_tuning.setting("gamerule:doWeatherCycle", "bool", { + description = S("Whether the weather can change naturally. The /weather command can still change weather."), default = true +}) + -- weather states, 'none' is default, other states depends from active mods mcl_weather.state = "none" @@ -126,6 +130,8 @@ end local t, wci = 0, mcl_weather.check_interval minetest.register_globalstep(function(dtime) + if not gamerule_doWeatherCycle[1] then return end + t = t + dtime if t < wci then return end t = 0 diff --git a/mods/ITEMS/mcl_fire/init.lua b/mods/ITEMS/mcl_fire/init.lua index 02fa29061..c95ac064a 100644 --- a/mods/ITEMS/mcl_fire/init.lua +++ b/mods/ITEMS/mcl_fire/init.lua @@ -7,6 +7,9 @@ local modpath = minetest.get_modpath(modname) local S = minetest.get_translator(modname) local has_mcl_portals = minetest.get_modpath("mcl_portals") +local gamerule_doFireTick = vl_tuning.setting("gamerule:doFireTick", "bool", { + description = S("Whether fire should spread and naturally extinguish"), default = true +}) local set_node = minetest.set_node local get_node = minetest.get_node @@ -366,6 +369,8 @@ else -- Fire enabled chance = 12, catch_up = false, action = function(pos) + if not gamerule_doFireTick[1] then return end + local p = get_ignitable(pos) if p then spawn_fire(p) @@ -383,6 +388,8 @@ else -- Fire enabled chance = 9, catch_up = false, action = function(pos) + if not gamerule_doFireTick[1] then return end + local p=get_ignitable_by_lava(pos) if p then spawn_fire(p) @@ -397,6 +404,8 @@ else -- Fire enabled chance = 3, catch_up = false, action = function(pos) + if not gamerule_doFireTick[1] then return end + local p=has_flammable(pos) if p then local n=minetest.get_node_or_nil(p) @@ -418,6 +427,8 @@ else -- Fire enabled chance = 18, catch_up = false, action = function(pos) + if not gamerule_doFireTick[1] then return end + local p = has_flammable(pos) if not p then return diff --git a/mods/ITEMS/mcl_fire/mod.conf b/mods/ITEMS/mcl_fire/mod.conf index 4a1d52ee2..768b25260 100644 --- a/mods/ITEMS/mcl_fire/mod.conf +++ b/mods/ITEMS/mcl_fire/mod.conf @@ -1,3 +1,3 @@ name = mcl_fire depends = mcl_core, mcl_worlds, mcl_sounds, mcl_particles, mcl_util -optional_depends = mcl_portals \ No newline at end of file +optional_depends = mcl_portals, vl_tuning