nodecore-cd2025/mods/nc_api/mapgen_limits.lua
Aaron Suen 8bfdc211a3 Convert some action logs to info
We were using action log level for a lot of
things because by default MT does not seem
to capture info logs to stderr.  On "production"
servers though this makes too much noise and
makes it hard to find actual player actions.
Servers that want info logging will just have
to configure/compile it in.
2021-12-11 21:26:18 -05:00

28 lines
1.1 KiB
Lua

-- LUALOCALS < ---------------------------------------------------------
local math, minetest, nodecore, string, tonumber
= math, minetest, nodecore, string, tonumber
local math_floor, string_format
= math.floor, string.format
-- LUALOCALS > ---------------------------------------------------------
local limit = tonumber(minetest.get_mapgen_setting("mapgen_limit")) or 31000
local chunksize = tonumber(minetest.get_mapgen_setting("chunksize")) or 5
chunksize = chunksize * 16
local limitchunks = math_floor(limit / chunksize)
nodecore.map_limit_min = (-limitchunks + 0.5) * chunksize + 7.5
nodecore.map_limit_max = (limitchunks - 0.5) * chunksize + 7.5
nodecore.log("info", string_format("mapgen limit: %d, chunk: %d, bounds: %0.1f to %0.1f",
limit, chunksize, nodecore.map_limit_min, nodecore.map_limit_max))
function nodecore.within_map_limits(pos)
return pos.x >= nodecore.map_limit_min
and pos.y >= nodecore.map_limit_min
and pos.z >= nodecore.map_limit_min
and pos.x <= nodecore.map_limit_max
and pos.y <= nodecore.map_limit_max
and pos.z <= nodecore.map_limit_max
end