From 20f5f7c966e005215957b16949ac4c86129998ee Mon Sep 17 00:00:00 2001 From: HybridDog Date: Sun, 29 May 2016 10:41:08 +0200 Subject: [PATCH] add testing code --- worldedit_commands/mark.lua | 45 ++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/worldedit_commands/mark.lua b/worldedit_commands/mark.lua index 4993227..38279a5 100644 --- a/worldedit_commands/mark.lua +++ b/worldedit_commands/mark.lua @@ -29,25 +29,37 @@ end worldedit.mark_pos2 = function(name) local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name] - if pos2 ~= nil then - --make area stay loaded + if pos2 then + -- make area stay loaded local manip = minetest.get_voxel_manip() manip:read_from_map(pos2, pos2) - end - if worldedit.marker2[name] ~= nil then --marker already exists - worldedit.marker2[name]:remove() --remove marker - worldedit.marker2[name] = nil - end - if pos2 ~= nil then - --add marker - worldedit.marker2[name] = minetest.add_entity(pos2, "worldedit:pos2") - if worldedit.marker2[name] ~= nil then - worldedit.marker2[name]:get_luaentity().player_name = name + if worldedit.marker2[name] then + -- move marker + worldedit.marker2[name]:moveto(pos2) + else + -- add marker + worldedit.marker2[name] = minetest.add_entity(pos2, "worldedit:pos2") + if worldedit.marker2[name] ~= nil then + worldedit.marker2[name]:get_luaentity().player_name = name + end end + elseif worldedit.marker2[name] then --remove marker + worldedit.marker2[name]:remove() + worldedit.marker2[name] = nil end worldedit.mark_region(name) end +local function V_updated_chunk(pos1, pos2) + pos1 = vector.apply(pos1, function(c) + return c - c%16 + end) + pos2 = vector.apply(pos2, function(c) + return c+16 - c%16 + end) + return worldedit.volume(pos1,pos2) +end + worldedit.mark_region = function(name) local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name] @@ -64,9 +76,16 @@ worldedit.mark_region = function(name) local sizex, sizey, sizez = (1 + pos2.x - pos1.x) / 2, (1 + pos2.y - pos1.y) / 2, (1 + pos2.z - pos1.z) / 2 --make area stay loaded + --[[ + local cV = V_updated_chunk(pos1, pos2) + local KiB_before = tonumber(io.popen("ps -C minetest -o rss | tail -n 1"):read("*a")) +--]] local manip = minetest.get_voxel_manip() manip:read_from_map(pos1, pos2) - +--[[ + local KiB_dif = KiB_before - tonumber(io.popen("ps -C minetest -o rss | tail -n 1"):read("*a")) + print(cV.." nodes, "..KiB_dif.. " KiB") +--]] local markers = {} --XY plane markers