diff --git a/worldeditadditions/lib/selection/cloud.lua b/worldeditadditions/lib/selection/cloud.lua deleted file mode 100644 index 1d41fde..0000000 --- a/worldeditadditions/lib/selection/cloud.lua +++ /dev/null @@ -1,37 +0,0 @@ --- ██████ ██ ██████ ██ ██ ██████ --- ██ ██ ██ ██ ██ ██ ██ ██ --- ██ ██ ██ ██ ██ ██ ██ ██ --- ██ ██ ██ ██ ██ ██ ██ ██ --- ██████ ███████ ██████ ██████ ██████ -worldeditadditions.add_pos = {} -function worldeditadditions.selection.add_point(name, pos) - if pos ~= nil then - -- 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) - worldedit.player_notify(name, "Expanded region by "..volume_difference.." nodes") - else - worldedit.player_notify(name, "Error: Too far away (try raising your maxdist with //farwand maxdist )") - -- print("[set_pos1]", name, "nil") - end -end -function worldeditadditions.selection.clear_points(name) - worldedit.pos1[name] = nil - worldedit.pos2[name] = nil - worldedit.marker_update(name) - worldedit.set_pos[name] = nil - - worldedit.player_notify(name, "Region cleared") -end diff --git a/worldeditadditions/lib/selection/init.lua b/worldeditadditions/lib/selection/init.lua index 28e3e9b..ce3fedf 100644 --- a/worldeditadditions/lib/selection/init.lua +++ b/worldeditadditions/lib/selection/init.lua @@ -1,8 +1,7 @@ local wea = worldeditadditions local wea_m = wea.modpath .. "/lib/selection/" -wea.selection = {} +wea.add_pos = {} -dofile(wea_m.."cloud.lua") -dofile(wea_m.."resize_helpers.lua") +wea.selection = dofile(wea_m.."selection.lua") dofile(wea_m.."stack.lua") diff --git a/worldeditadditions/lib/selection/resize_helpers.lua b/worldeditadditions/lib/selection/resize_helpers.lua deleted file mode 100644 index e69de29..0000000 diff --git a/worldeditadditions/lib/selection/selection.lua b/worldeditadditions/lib/selection/selection.lua new file mode 100644 index 0000000..299fe1b --- /dev/null +++ b/worldeditadditions/lib/selection/selection.lua @@ -0,0 +1,49 @@ +-- ███████ ███████ ██ ███████ ██████ ████████ ██ ██████ ███ ██ +-- ██ ██ ██ ██ ██ ██ ██ ██ ██ ████ ██ +-- ███████ █████ ██ █████ ██ ██ ██ ██ ██ ██ ██ ██ +-- ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ +-- ███████ ███████ ███████ ███████ ██████ ██ ██ ██████ ██ ████ + +---Selection helpers and modifiers +local selection = {} + +--- Additively adds a point to the current selection or +-- makes a selection from the provided point. +-- @param name string Player name. +-- @param pos vector The position to include. +function selection.add_point(name, pos) + if pos ~= nil then + -- 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) + worldedit.player_notify(name, "Expanded region by "..volume_difference.." nodes") + else + worldedit.player_notify(name, "Error: Too far away (try raising your maxdist with //farwand maxdist )") + -- print("[set_pos1]", name, "nil") + end +end + +--- Clears current selection. +-- @param name string Player name. +function selection.clear_points(name) + worldedit.pos1[name] = nil + worldedit.pos2[name] = nil + worldedit.marker_update(name) + worldedit.set_pos[name] = nil + + worldedit.player_notify(name, "Region cleared") +end + +return selection