summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGael-de-Sailly <gael.chretien@akeonet.com>2014-11-30 21:57:35 +0100
committerGael-de-Sailly <gael.chretien@akeonet.com>2014-11-30 21:57:35 +0100
commit12a471f760d238c4936ef41707836e9ed9f10d69 (patch)
treef0dccfdf8bb09c79574be3513395beebc0779fef
parent87cee19fbd860637213c655ec61ac5bcd98e7d1f (diff)
Cleaned the code, thanks to SmallJoker
-rw-r--r--init.lua9
1 files changed, 7 insertions, 2 deletions
diff --git a/init.lua b/init.lua
index 77ce155..680fd6f 100644
--- a/init.lua
+++ b/init.lua
@@ -1,13 +1,18 @@
minetest.register_chatcommand("mapfix", {
params = "<size>",
- description = "Recalculate the flowing liquids of a chunk",
+ description = "Recalculate the flowing liquids and the light of a chunk",
func = function(name, param)
local pos = minetest.get_player_by_name(name):getpos()
local size = tonumber(param) or 40
+
if size > 50 and not minetest.check_player_privs(name, {server=true}) then
return false, "You need the server privilege to exceed the radius of 50 blocks"
end
- local minp, maxp = {x = math.floor(pos.x - size), y = math.floor(pos.y - size), z = math.floor(pos.z - size)}, {x = math.ceil(pos.x + size), y = math.ceil(pos.y + size), z = math.ceil(pos.z + size)}
+
+ local minp = vector.round(vector.subtract(pos, size - 0.5))
+ local maxp = vector.round(vector.add(pos, size + 0.5))
+
+ -- use the voxelmanip to fix problems
local vm = minetest.get_voxel_manip()
vm:read_from_map(minp, maxp)
vm:calc_lighting()