forked from VoxeLibre/VoxeLibre
Simplify within_limits function
so you don't need a cs degree to read it ^^
This commit is contained in:
parent
df8c234def
commit
9a95557ec8
|
@ -915,23 +915,21 @@ end
|
||||||
|
|
||||||
|
|
||||||
-- check if within physical map limits (-30911 to 30927)
|
-- check if within physical map limits (-30911 to 30927)
|
||||||
local within_limits, wmin, wmax = nil, -30913, 30928
|
local function within_limits(pos, radius)
|
||||||
within_limits = function(pos, radius)
|
local wmin, wmax = -30912, 30928
|
||||||
if mcl_vars then
|
if mcl_vars then
|
||||||
if mcl_vars.mapgen_edge_min and mcl_vars.mapgen_edge_max then
|
if mcl_vars.mapgen_edge_min and mcl_vars.mapgen_edge_max then
|
||||||
wmin, wmax = mcl_vars.mapgen_edge_min, mcl_vars.mapgen_edge_max
|
wmin, wmax = mcl_vars.mapgen_edge_min, mcl_vars.mapgen_edge_max
|
||||||
within_limits = function(pos, radius)
|
|
||||||
return pos
|
|
||||||
and (pos.x - radius) > wmin and (pos.x + radius) < wmax
|
|
||||||
and (pos.y - radius) > wmin and (pos.y + radius) < wmax
|
|
||||||
and (pos.z - radius) > wmin and (pos.z + radius) < wmax
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if radius then
|
||||||
|
wmin = wmin - radius
|
||||||
|
wmax = wmax + radius
|
||||||
end
|
end
|
||||||
return pos
|
for _,v in pairs(pos) do
|
||||||
and (pos.x - radius) > wmin and (pos.x + radius) < wmax
|
if v < wmin or v > wmax then return false end
|
||||||
and (pos.y - radius) > wmin and (pos.y + radius) < wmax
|
end
|
||||||
and (pos.z - radius) > wmin and (pos.z + radius) < wmax
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue