Minetest-WorldEditAdditions/worldeditadditions/lib/selection/cloud.lua

49 lines
2.1 KiB
Lua
Raw Normal View History

2021-03-13 00:47:10 +01:00
-- ██████ ██ ██████ ██ ██ ██████
-- ██ ██ ██ ██ ██ ██ ██ ██
-- ██ ██ ██ ██ ██ ██ ██ ██
-- ██ ██ ██ ██ ██ ██ ██ ██
-- ██████ ███████ ██████ ██████ ██████
worldeditadditions.add_pos = {}
2021-03-13 03:11:43 +01:00
worldeditadditions.selection = {}
function worldeditadditions.selection.add_point(name, pos)
2021-03-13 00:47:10 +01:00
if pos ~= nil then
2021-10-03 16:31:27 +02:00
local is_new = not worldedit.pos1[name] and not worldedit.pos2[name]
2021-03-13 00:47:10 +01:00
-- print("[set_pos1]", name, "("..pos.x..", "..pos.y..", "..pos.z..")")
if not worldedit.pos1[name] then worldedit.pos1[name] = vector.new(pos) end
if not worldedit.pos2[name] then worldedit.pos2[name] = vector.new(pos) end
worldedit.marker_update(name)
local volume_before = worldedit.volume(worldedit.pos1[name], worldedit.pos2[name])
worldedit.pos1[name], worldedit.pos2[name] = worldeditadditions.vector.expand_region(worldedit.pos1[name], worldedit.pos2[name], pos)
local volume_after = worldedit.volume(worldedit.pos1[name], worldedit.pos2[name])
local volume_difference = volume_after - volume_before
worldedit.marker_update(name)
2021-10-03 16:31:27 +02:00
print("DEBUG volume_before", volume_before, "volume_after", volume_after)
if is_new then
local msg = "Created new region of "..volume_after.." node"
if volume_after ~= 1 then msg = msg.."s" end
worldedit.player_notify(name, msg)
else
local msg = "Expanded region by "..volume_difference.." node"
if volume_difference ~= 1 then msg = msg.."s" end
worldedit.player_notify(name, msg)
end
2021-03-13 00:47:10 +01:00
else
worldedit.player_notify(name, "Error: Too far away (try raising your maxdist with //farwand maxdist <number>)")
-- print("[set_pos1]", name, "nil")
end
end
function worldeditadditions.selection.clear_points(name)
2021-03-13 00:47:10 +01:00
worldedit.pos1[name] = nil
worldedit.pos2[name] = nil
worldedit.marker_update(name)
worldedit.set_pos[name] = nil
worldedit.player_notify(name, "Region cleared")
end