summaryrefslogtreecommitdiff
path: root/init.lua
blob: 5ec05491af95a41933cebea72024ae8608b47f37 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
minetest.register_chatcommand("mapfix", {
	params = "<size>",
	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 = 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(minp, maxp)
		vm:update_liquids()
		vm:write_to_map()
		vm:update_map()
		return true, "Done."
	end,
})