Skip to content

Commit

Permalink
add testing code
Browse files Browse the repository at this point in the history
  • Loading branch information
HybridDog committed May 29, 2016
1 parent 14c2670 commit 20f5f7c
Showing 1 changed file with 32 additions and 13 deletions.
45 changes: 32 additions & 13 deletions worldedit_commands/mark.lua
Expand Up @@ -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]

Expand All @@ -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
Expand Down

0 comments on commit 20f5f7c

Please sign in to comment.