Repurpose static_spawn_radius for village spawning

This commit is contained in:
Wuzzy 2024-03-08 17:40:49 +01:00
parent 65260e739d
commit aa6c3fb0fd
2 changed files with 7 additions and 9 deletions

View File

@ -5,7 +5,7 @@
local S = minetest.get_translator("rp_village")
local spawn_pos = minetest.setting_get_pos("static_spawnpoint") or {x = 0, y = 0, z = 0}
local spawn_radius = minetest.settings:get("static_spawn_radius") or 256
local spawn_radius = tonumber(minetest.settings:get("static_spawn_radius")) or 256
local mapseed = minetest.get_mapgen_setting("seed")
local bitwise_and = function(x,y)
@ -200,7 +200,7 @@ local function attempt_village_spawn(pos, village_type)
local nearest = village.get_nearest_village(spos)
if not nearest or nearest.dist > village.min_spawn_dist then
if vector.distance(spawn_pos, spos) > spawn_radius then
if spawn_radius == 0 or vector.distance(spawn_pos, spos) > spawn_radius then
minetest.log("action", "[rp_village] Spawning a village at " .. "(" .. spos.x
.. ", " .. spos.y .. ", " .. spos.z .. ")")
local ground = village_info[village_type].ground

View File

@ -38,6 +38,11 @@ weather_enable (Enable dynamic weather) bool true
# If enabled, villages will no longer be generated.
mapgen_disable_villages (Disable villages) bool false
# This number specifies the radius around the spawn point
# in which villages won't generate.
# The number 0 disables this restriction.
static_spawn_radius (Village-free radius) int 256 0
[Blocks]
# This enables TNT. TNT is a block that, when ignited, will explode, deal damage and destroy blocks around it.
# If disabled, all TNTs will be defused and thus unable to explode.
@ -84,13 +89,6 @@ mobs_spawn_protected (Mobs spawn in protected area) bool true
# The safety radius is set in static_spawn_radius.
mobs_safe_spawn (Safe spawn from mobs) bool true
# Radius around the player spawn point in which mobs don't attack.
# This is only the case in multiplayer servers and if the setting 'mobs_safe_spawn' is enabled. In singleplayer, mobs will attack regardless.
#
# Additionally, this radius also specifies the radius around
# the spawn point in which villages don't generate.
static_spawn_radius (Spawn point safety radius) int 256 0
[Graphics and audio]
# This will add an graphical effect that slightly darkens the edges of the screen.
vignette_enable (Enable vignette) bool true