mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-11-28 13:53:45 +01:00
Fix default value handling during set (allows bool settings to be set to false), add game rules: doMobSpawning, disableRaids, doWeatherCycle, doFireTick
This commit is contained in:
parent
387101fc8e
commit
fdd52bda90
@ -30,7 +30,11 @@ local tunable_class = {}
|
|||||||
function tunable_class:set(value)
|
function tunable_class:set(value)
|
||||||
local self_type = self.type
|
local self_type = self.type
|
||||||
if type(value) == "string" then
|
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
|
else
|
||||||
self[1] = value
|
self[1] = value
|
||||||
end
|
end
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
name = mcl_mobs
|
name = mcl_mobs
|
||||||
author = PilzAdam
|
author = PilzAdam
|
||||||
description = Adds a mob API for mods to add animals or monsters, etc.
|
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
|
optional_depends = mcl_weather, mcl_explosions, mcl_hunger, mcl_worlds, invisibility, lucky_block, cmi, doc_identifier, mcl_armor, mcl_portals, mcl_experience, mcl_sculk
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
--lua locals
|
--lua locals
|
||||||
|
local S = minetest.get_translator("mcl_mobs")
|
||||||
local math, vector, minetest, mcl_mobs = math, vector, minetest, mcl_mobs
|
local math, vector, minetest, mcl_mobs = math, vector, minetest, mcl_mobs
|
||||||
local mob_class = mcl_mobs.mob_class
|
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 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 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
|
local end_threshold = tonumber(minetest.settings:get("mcl_mobs_end_threshold")) or 0
|
||||||
@ -728,8 +733,6 @@ end
|
|||||||
|
|
||||||
mcl_mobs.spawn_group = spawn_group
|
mcl_mobs.spawn_group = spawn_group
|
||||||
|
|
||||||
local S = minetest.get_translator("mcl_mobs")
|
|
||||||
|
|
||||||
minetest.register_chatcommand("spawn_mob",{
|
minetest.register_chatcommand("spawn_mob",{
|
||||||
privs = { debug = true },
|
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<mobs_variable=variable_value>:'. 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<passive=true>:\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<jump_height=NUM10>:\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<passive=true>::var<jump_height=NUM10>::var<fly_in=air>::var<fly=true>:\n etc."),
|
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<mobs_variable=variable_value>:'. 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<passive=true>:\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<jump_height=NUM10>:\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<passive=true>::var<jump_height=NUM10>::var<fly_in=air>::var<fly=true>:\n etc."),
|
||||||
@ -1010,6 +1013,7 @@ if mobs_spawn then
|
|||||||
|
|
||||||
local timer = 0
|
local timer = 0
|
||||||
minetest.register_globalstep(function(dtime)
|
minetest.register_globalstep(function(dtime)
|
||||||
|
if not gamerule_doMobSpawning[1] then return end
|
||||||
|
|
||||||
timer = timer + dtime
|
timer = timer + dtime
|
||||||
if timer < WAIT_FOR_SPAWN_ATTEMPT then return end
|
if timer < WAIT_FOR_SPAWN_ATTEMPT then return end
|
||||||
|
@ -2,6 +2,10 @@
|
|||||||
mcl_raids = {}
|
mcl_raids = {}
|
||||||
local S = minetest.get_translator(minetest.get_current_modname())
|
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.
|
-- Define the amount of illagers to spawn each wave.
|
||||||
local waves = {
|
local waves = {
|
||||||
{
|
{
|
||||||
@ -291,6 +295,8 @@ mcl_events.register_event("raid",{
|
|||||||
exclusive_to_area = 128,
|
exclusive_to_area = 128,
|
||||||
enable_bossbar = true,
|
enable_bossbar = true,
|
||||||
cond_start = function(self)
|
cond_start = function(self)
|
||||||
|
if gamerule_disableRaids[1] then return false end
|
||||||
|
|
||||||
--minetest.log("Cond start raid")
|
--minetest.log("Cond start raid")
|
||||||
local r = {}
|
local r = {}
|
||||||
for _,p in pairs(minetest.get_connected_players()) do
|
for _,p in pairs(minetest.get_connected_players()) do
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
name = mcl_raids
|
name = mcl_raids
|
||||||
author = PrairieWind
|
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
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
name = mcl_weather
|
name = mcl_weather
|
||||||
author = xeranas
|
author = xeranas
|
||||||
description = Weather and sky handling: Rain, snow, thunderstorm, End and Nether ambience
|
description = Weather and sky handling: Rain, snow, thunderstorm, End and Nether ambience
|
||||||
depends = mcl_init, mcl_worlds, mcl_playerinfo, mcl_util
|
depends = mcl_init, mcl_worlds, mcl_playerinfo, mcl_util, vl_tuning
|
||||||
optional_depends = lightning
|
optional_depends = lightning
|
||||||
|
@ -2,6 +2,10 @@ local S = minetest.get_translator(minetest.get_current_modname())
|
|||||||
|
|
||||||
local math = math
|
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
|
-- weather states, 'none' is default, other states depends from active mods
|
||||||
mcl_weather.state = "none"
|
mcl_weather.state = "none"
|
||||||
|
|
||||||
@ -126,6 +130,8 @@ end
|
|||||||
local t, wci = 0, mcl_weather.check_interval
|
local t, wci = 0, mcl_weather.check_interval
|
||||||
|
|
||||||
minetest.register_globalstep(function(dtime)
|
minetest.register_globalstep(function(dtime)
|
||||||
|
if not gamerule_doWeatherCycle[1] then return end
|
||||||
|
|
||||||
t = t + dtime
|
t = t + dtime
|
||||||
if t < wci then return end
|
if t < wci then return end
|
||||||
t = 0
|
t = 0
|
||||||
|
@ -7,6 +7,9 @@ local modpath = minetest.get_modpath(modname)
|
|||||||
local S = minetest.get_translator(modname)
|
local S = minetest.get_translator(modname)
|
||||||
|
|
||||||
local has_mcl_portals = minetest.get_modpath("mcl_portals")
|
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 set_node = minetest.set_node
|
||||||
local get_node = minetest.get_node
|
local get_node = minetest.get_node
|
||||||
@ -366,6 +369,8 @@ else -- Fire enabled
|
|||||||
chance = 12,
|
chance = 12,
|
||||||
catch_up = false,
|
catch_up = false,
|
||||||
action = function(pos)
|
action = function(pos)
|
||||||
|
if not gamerule_doFireTick[1] then return end
|
||||||
|
|
||||||
local p = get_ignitable(pos)
|
local p = get_ignitable(pos)
|
||||||
if p then
|
if p then
|
||||||
spawn_fire(p)
|
spawn_fire(p)
|
||||||
@ -383,6 +388,8 @@ else -- Fire enabled
|
|||||||
chance = 9,
|
chance = 9,
|
||||||
catch_up = false,
|
catch_up = false,
|
||||||
action = function(pos)
|
action = function(pos)
|
||||||
|
if not gamerule_doFireTick[1] then return end
|
||||||
|
|
||||||
local p=get_ignitable_by_lava(pos)
|
local p=get_ignitable_by_lava(pos)
|
||||||
if p then
|
if p then
|
||||||
spawn_fire(p)
|
spawn_fire(p)
|
||||||
@ -397,6 +404,8 @@ else -- Fire enabled
|
|||||||
chance = 3,
|
chance = 3,
|
||||||
catch_up = false,
|
catch_up = false,
|
||||||
action = function(pos)
|
action = function(pos)
|
||||||
|
if not gamerule_doFireTick[1] then return end
|
||||||
|
|
||||||
local p=has_flammable(pos)
|
local p=has_flammable(pos)
|
||||||
if p then
|
if p then
|
||||||
local n=minetest.get_node_or_nil(p)
|
local n=minetest.get_node_or_nil(p)
|
||||||
@ -418,6 +427,8 @@ else -- Fire enabled
|
|||||||
chance = 18,
|
chance = 18,
|
||||||
catch_up = false,
|
catch_up = false,
|
||||||
action = function(pos)
|
action = function(pos)
|
||||||
|
if not gamerule_doFireTick[1] then return end
|
||||||
|
|
||||||
local p = has_flammable(pos)
|
local p = has_flammable(pos)
|
||||||
if not p then
|
if not p then
|
||||||
return
|
return
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
name = mcl_fire
|
name = mcl_fire
|
||||||
depends = mcl_core, mcl_worlds, mcl_sounds, mcl_particles, mcl_util
|
depends = mcl_core, mcl_worlds, mcl_sounds, mcl_particles, mcl_util
|
||||||
optional_depends = mcl_portals
|
optional_depends = mcl_portals, vl_tuning
|
||||||
|
Loading…
Reference in New Issue
Block a user