]> git.lizzy.rs Git - worldedit.git/commitdiff
Rewrite spirals from scratch and fix upside-down pyramids. Use voxelmanip for markers...
authorAnthony Zhang <azhang9@gmail.com>
Thu, 1 Aug 2013 02:15:08 +0000 (22:15 -0400)
committerAnthony Zhang <azhang9@gmail.com>
Thu, 1 Aug 2013 02:15:08 +0000 (22:15 -0400)
Chat Commands.md
WorldEdit API.md
worldedit/compatibility.lua
worldedit/manipulations.lua
worldedit/primitives.lua
worldedit/serialization.lua
worldedit_commands/init.lua
worldedit_commands/mark.lua

index 675532a1052be05c587ccb40fd7fd69d82b04573..f70bf758d8ed825b1797eba73118feb3870057ac 100644 (file)
@@ -155,9 +155,9 @@ Add pyramid centered at WorldEdit position 1 along the x/y/z/? axis with height
     //pyramid 5 glass\r
     //pyramid 2 mesecons:wire_00000000_off\r
 \r
-### //spiral <width> <height> <spacer> <node>\r
+### //spiral <length> <height> <spacer> <node>\r
 \r
-Add spiral centered at WorldEdit position 1 with width <width>, height <height>, space between walls <spacer>, composed of <node>.\r
+Add spiral centered at WorldEdit position 1 with side length <length>, height <height>, space between walls <spacer>, composed of <node>.\r
 \r
     //spiral 20 5 3 Diamond Block\r
     //spiral 5 2 1 glass\r
index 5d7e6d9e8361e2dea46ad16253d912ba54edbb66..22441d297cdb16a424c9823557888ea3b68fec3d 100644 (file)
@@ -134,9 +134,9 @@ Adds a pyramid centered at `pos` along the `axis` axis ("x" or "y" or "z") with
 \r
 Returns the number of nodes added.\r
 \r
-### count = worldedit.spiral(pos, width, height, spacer, nodename)\r
+### count = worldedit.spiral(pos, length, height, spacer, nodename)\r
 \r
-Adds a spiral centered at `pos` with width `width`, height `height`, space between walls `spacer`, composed of `nodename`.\r
+Adds a spiral centered at `pos` with side length `length`, height `height`, space between walls `spacer`, composed of `nodename`.\r
 \r
 Returns the number of nodes added.\r
 \r
index f6971cce0a3fc9df9129443dc25a588fbde2fabb..eb81eeacaaaccd76898b3a4f1cf97ba908dd1d05 100644 (file)
@@ -17,4 +17,4 @@ worldedit.metaload = function(originpos, filename)
        if err then return 0 end\r
        local data = file:read("*a")\r
        return worldedit.deserialize(originpos, data)\r
-end
\ No newline at end of file
+end\r
index 54e0d2e8d0b494831676c67c9dbe565f6db9de64..53fea6fa8ae32d0374cc8aa6d6cabd3b11d13690 100644 (file)
@@ -1,7 +1,6 @@
 worldedit = worldedit or {}\r
 local minetest = minetest --local copy of global\r
 \r
---wip: remove env parameter where no longer needed in chat commands module\r
 --wip: fix the queue\r
 \r
 --modifies positions `pos1` and `pos2` so that each component of `pos1` is less than or equal to its corresponding conent of `pos2`, returning two new positions\r
@@ -112,11 +111,68 @@ worldedit.replaceinverse = function(pos1, pos2, searchnode, replacenode)
        return count\r
 end\r
 \r
+worldedit.copy = function(pos1, pos2, axis, amount)\r
+       local pos1, pos2 = worldedit.sort_pos(pos1, pos2)\r
+\r
+       if amount == 0 then\r
+               return\r
+       end\r
+\r
+       local other1, other2\r
+       if axis == "x" then\r
+               other1, other2 = "y", "z"\r
+       elseif axis == "y" then\r
+               other1, other2 = "x", "z"\r
+       else --axis == "z"\r
+               other1, other2 = "x", "y"\r
+       end\r
+\r
+       --make area stay loaded\r
+       local manip = minetest.get_voxel_manip()\r
+       manip:read_from_map(pos1, pos2)\r
+\r
+       --prepare slice along axis\r
+       local extent = {\r
+               [axis] = 1,\r
+               [other1]=pos2[other1] - pos1[other1] + 1,\r
+               [other2]=pos2[other2] - pos1[other2] + 1,\r
+       }\r
+       local nodes = {}\r
+       local schematic = {size=extent, data=nodes}\r
+\r
+       local currentpos = {x=pos1.x, y=pos1.y, z=pos1.z}\r
+       local stride = {x=1, y=extent.x, z=extent.x * extent.y}\r
+       local get_node = minetest.get_node\r
+       for index1 = 1, extent[axis] do --go through each slice\r
+               --copy slice into schematic\r
+               local newindex1 = (index1 + offset[axis]) * stride[axis] + 1 --offset contributed by axis plus 1 to make it 1-indexed\r
+               for index2 = 1, extent[other1] do\r
+                       local newindex2 = newindex1 + (index2 + offset[other1]) * stride[other1]\r
+                       for index3 = 1, extent[other2] do\r
+                               local i = newindex2 + (index3 + offset[other2]) * stride[other2]\r
+                               nodes[i] = get_node(pos)\r
+                       end\r
+               end\r
+\r
+               --copy schematic to target\r
+               currentpos[axis] = currentpos[axis] + amount\r
+               place_schematic(currentpos, schematic)\r
+\r
+               --wip: copy meta\r
+\r
+               currentpos[axis] = currentpos[axis] + 1\r
+       end\r
+       return worldedit.volume(pos1, pos2)\r
+end\r
+\r
 --copies the region defined by positions `pos1` and `pos2` along the `axis` axis ("x" or "y" or "z") by `amount` nodes, returning the number of nodes copied\r
 worldedit.copy = function(pos1, pos2, axis, amount)\r
        local pos1, pos2 = worldedit.sort_pos(pos1, pos2)\r
 \r
-       --wip: copy slice by slice using schematic method in the copy axis and transfer metadata in separate loop (and if the amount is greater than the length in the axis, copy whole thing at a time), use voxelmanip to keep area loaded\r
+       --make area stay loaded\r
+       local manip = minetest.get_voxel_manip()\r
+       manip:read_from_map(pos1, pos2)\r
+\r
        local get_node, get_meta, add_node = minetest.get_node, minetest.get_meta, minetest.add_node\r
        if amount < 0 then\r
                local pos = {x=pos1.x, y=0, z=0}\r
@@ -166,7 +222,11 @@ end
 worldedit.move = function(pos1, pos2, axis, amount)\r
        local pos1, pos2 = worldedit.sort_pos(pos1, pos2)\r
 \r
-       --wip: move slice by slice using schematic method in the move axis and transfer metadata in separate loop (and if the amount is greater than the length in the axis, copy whole thing at a time and erase original after, using schematic method), use voxelmanip to keep area loaded\r
+       --make area stay loaded\r
+       local manip = minetest.get_voxel_manip()\r
+       manip:read_from_map(pos1, pos2)\r
+\r
+       --wip: move slice by slice using schematic method in the move axis and transfer metadata in separate loop (and if the amount is greater than the length in the axis, copy whole thing at a time and erase original after, using schematic method)\r
        local get_node, get_meta, add_node, remove_node = minetest.get_node, minetest.get_meta, minetest.add_node, minetest.remove_node\r
        if amount < 0 then\r
                local pos = {x=pos1.x, y=0, z=0}\r
@@ -215,7 +275,7 @@ worldedit.move = function(pos1, pos2, axis, amount)
 end\r
 \r
 --duplicates the region defined by positions `pos1` and `pos2` along the `axis` axis ("x" or "y" or "z") `count` times, returning the number of nodes stacked\r
-worldedit.stack = function(pos1, pos2, axis, count, env)\r
+worldedit.stack = function(pos1, pos2, axis, count)\r
        local pos1, pos2 = worldedit.sort_pos(pos1, pos2)\r
        local length = pos2[axis] - pos1[axis] + 1\r
        if count < 0 then\r
@@ -226,7 +286,7 @@ worldedit.stack = function(pos1, pos2, axis, count, env)
        local copy = worldedit.copy\r
        for i = 1, count do\r
                amount = amount + length\r
-               copy(pos1, pos2, axis, amount, env)\r
+               copy(pos1, pos2, axis, amount)\r
        end\r
        return worldedit.volume(pos1, pos2) * count\r
 end\r
@@ -291,7 +351,7 @@ worldedit.scale = function(pos1, pos2, factor)
 end\r
 \r
 --transposes a region defined by the positions `pos1` and `pos2` between the `axis1` and `axis2` axes, returning the number of nodes transposed, the new transposed position 1, and the new transposed position 2\r
-worldedit.transpose = function(pos1, pos2, axis1, axis2, env)\r
+worldedit.transpose = function(pos1, pos2, axis1, axis2)\r
        local pos1, pos2 = worldedit.sort_pos(pos1, pos2)\r
 \r
        local compare\r
@@ -350,7 +410,7 @@ worldedit.transpose = function(pos1, pos2, axis1, axis2, env)
 end\r
 \r
 --flips a region defined by the positions `pos1` and `pos2` along the `axis` axis ("x" or "y" or "z"), returning the number of nodes flipped\r
-worldedit.flip = function(pos1, pos2, axis, env)\r
+worldedit.flip = function(pos1, pos2, axis)\r
        local pos1, pos2 = worldedit.sort_pos(pos1, pos2)\r
 \r
        --make area stay loaded\r
@@ -388,7 +448,7 @@ worldedit.flip = function(pos1, pos2, axis, env)
 end\r
 \r
 --rotates a region defined by the positions `pos1` and `pos2` by `angle` degrees clockwise around axis `axis` (90 degree increment), returning the number of nodes rotated\r
-worldedit.rotate = function(pos1, pos2, axis, angle, env)\r
+worldedit.rotate = function(pos1, pos2, axis, angle)\r
        local pos1, pos2 = worldedit.sort_pos(pos1, pos2)\r
 \r
        local axis1, axis2\r
@@ -403,20 +463,20 @@ worldedit.rotate = function(pos1, pos2, axis, angle, env)
 \r
        local count\r
        if angle == 90 then\r
-               worldedit.flip(pos1, pos2, axis1, env)\r
-               count, pos1, pos2 = worldedit.transpose(pos1, pos2, axis1, axis2, env)\r
+               worldedit.flip(pos1, pos2, axis1)\r
+               count, pos1, pos2 = worldedit.transpose(pos1, pos2, axis1, axis2)\r
        elseif angle == 180 then\r
-               worldedit.flip(pos1, pos2, axis1, env)\r
-               count = worldedit.flip(pos1, pos2, axis2, env)\r
+               worldedit.flip(pos1, pos2, axis1)\r
+               count = worldedit.flip(pos1, pos2, axis2)\r
        elseif angle == 270 then\r
-               worldedit.flip(pos1, pos2, axis2, env)\r
-               count, pos1, pos2 = worldedit.transpose(pos1, pos2, axis1, axis2, env)\r
+               worldedit.flip(pos1, pos2, axis2)\r
+               count, pos1, pos2 = worldedit.transpose(pos1, pos2, axis1, axis2)\r
        end\r
        return count, pos1, pos2\r
 end\r
 \r
 --rotates all oriented nodes in a region defined by the positions `pos1` and `pos2` by `angle` degrees clockwise (90 degree increment) around the Y axis, returning the number of nodes oriented\r
-worldedit.orient = function(pos1, pos2, angle, env) --wip: support 6D facedir rotation along arbitrary axis\r
+worldedit.orient = function(pos1, pos2, angle) --wip: support 6D facedir rotation along arbitrary axis\r
        local pos1, pos2 = worldedit.sort_pos(pos1, pos2)\r
        local registered_nodes = minetest.registered_nodes\r
 \r
@@ -477,7 +537,7 @@ worldedit.orient = function(pos1, pos2, angle, env) --wip: support 6D facedir ro
 end\r
 \r
 --fixes the lighting in a region defined by positions `pos1` and `pos2`, returning the number of nodes updated\r
-worldedit.fixlight = function(pos1, pos2, env)\r
+worldedit.fixlight = function(pos1, pos2)\r
        local pos1, pos2 = worldedit.sort_pos(pos1, pos2)\r
 \r
        --make area stay loaded\r
index eb4624b5cdde33026817daeb7c01dbeff0fe5225..e359baab0d40f39251d2b4da9e4f2e1af33fb590 100644 (file)
@@ -326,7 +326,7 @@ worldedit.cylinder = function(pos, axis, length, radius, nodename)
                        local newindex3 = newindex2 + (index3 + offset[other2]) * stride[other2]\r
                        if index2 * index2 + index3 * index3 <= max_radius then\r
                                for index1 = min_slice, max_slice do --add column along axis\r
-                                       local i = newindex3 + index1 * stride[axis] + 1\r
+                                       local i = newindex3 + index1 * stride[axis]\r
                                        nodes[i] = node_id\r
                                end\r
                                count = count + length\r
@@ -358,18 +358,14 @@ worldedit.pyramid = function(pos, axis, height, nodename)
 \r
        --handle inverted pyramids\r
        local startaxis, endaxis, step\r
-       local currentpos = {x=pos.x, y=pos.y, z=pos.z}\r
        if height > 0 then\r
                height = height - 1\r
-               startaxis, endaxis = 0, height\r
                step = 1\r
                pos1[axis] = pos[axis] --upper half of box\r
        else\r
-               height = -height - 1\r
-               startaxis, endaxis = height, 0\r
+               height = height + 1\r
                step = -1\r
-               pos2[axis] = pos[axis] + 1 --lower half of box\r
-               currentpos[axis] = pos[axis] - height --bottom of box\r
+               pos2[axis] = pos[axis] --lower half of box\r
        end\r
 \r
        --set up voxel manipulator\r
@@ -387,19 +383,20 @@ worldedit.pyramid = function(pos, axis, height, nodename)
        --fill selected area with node\r
        local node_id = minetest.get_content_id(nodename)\r
        local stride = {x=1, y=area.ystride, z=area.zstride}\r
-       local offset = {x=currentpos.x - emerged_pos1.x, y=currentpos.y - emerged_pos1.y, z=currentpos.z - emerged_pos1.z}\r
+       local offset = {x=pos.x - emerged_pos1.x, y=pos.y - emerged_pos1.y, z=pos.z - emerged_pos1.z}\r
+       local size = height * step\r
        local count = 0\r
-       for index1 = startaxis, endaxis, step do --go through each level of the pyramid\r
+       for index1 = 0, height, step do --go through each level of the pyramid\r
                local newindex1 = (index1 + offset[axis]) * stride[axis] + 1 --offset contributed by axis plus 1 to make it 1-indexed\r
-               for index2 = -height, height do\r
+               for index2 = -size, size do\r
                        local newindex2 = newindex1 + (index2 + offset[other1]) * stride[other1]\r
-                       for index3 = -height, height do\r
+                       for index3 = -size, size do\r
                                local i = newindex2 + (index3 + offset[other2]) * stride[other2]\r
                                nodes[i] = node_id\r
                        end\r
                end\r
-               count = count + (height * 2 + 1) ^ 2\r
-               height = height - 1\r
+               count = count + (size * 2 + 1) ^ 2\r
+               size = size - 1\r
        end\r
 \r
        --update map nodes\r
@@ -410,70 +407,72 @@ worldedit.pyramid = function(pos, axis, height, nodename)
        return count\r
 end\r
 \r
---adds a spiral centered at `pos` with width `width`, height `height`, space between walls `spacer`, composed of `nodename`, returning the number of nodes added\r
-worldedit.spiral = function(pos, width, height, spacer, nodename, env) --wip: rewrite this whole thing, nobody can understand it anyways\r
-       -- spiral matrix - http://rosettacode.org/wiki/Spiral_matrix#Lua\r
-       local abs = math.abs\r
-       local sign = function(s) return s ~= 0 and s / av(s) or 0 end\r
-       local function sindex(z, x) -- returns the value at (x, z) in a spiral that starts at 1 and goes outwards\r
-               if z == -x and z >= x then return (2*z+1)^2 end\r
-               local longest = math.max(abs(z), abs(x))\r
-               return (2*longest-1)^2 + 4*longest + 2*longest*sign(x+z) + sign(z^2-x^2)*(longest-(abs(z)==longest and sign(z)*x or sign(x)*z)) -- OH GOD WHAT\r
+--adds a spiral centered at `pos` with side length `length`, height `height`, space between walls `spacer`, composed of `nodename`, returning the number of nodes added\r
+worldedit.spiral = function(pos, length, height, spacer, nodename)\r
+       local extent = math.ceil(length / 2)\r
+       local pos1 = {x=pos.x - extent, y=pos.y, z=pos.z - extent}\r
+       local pos2 = {x=pos.x + extent, y=pos.y + height, z=pos.z + extent}\r
+\r
+       --set up voxel manipulator\r
+       local manip = minetest.get_voxel_manip()\r
+       local emerged_pos1, emerged_pos2 = manip:read_from_map(pos1, pos2)\r
+       local area = VoxelArea:new({MinEdge=emerged_pos1, MaxEdge=emerged_pos2})\r
+\r
+       --fill emerged area with ignore\r
+       local nodes = {}\r
+       local ignore = minetest.get_content_id("ignore")\r
+       for i = 1, worldedit.volume(emerged_pos1, emerged_pos2) do\r
+               nodes[i] = ignore\r
        end\r
-       local function spiralt(side)\r
-               local ret, id, start, stop = {}, 0, math.floor((-side+1)/2), math.floor((side-1)/2)\r
-               for i = 1, side do\r
-                       for j = 1, side do\r
-                               local id = side^2 - sindex(stop - i + 1,start + j - 1)\r
-                               ret[id] = {x=i,z=j}\r
+\r
+       --\r
+       local node_id = minetest.get_content_id(nodename)\r
+       local stride = {x=1, y=area.ystride, z=area.zstride}\r
+       local offsetx, offsety, offsetz = pos.x - emerged_pos1.x, pos.y - emerged_pos1.y, pos.z - emerged_pos1.z\r
+       local i = offsetz * stride.z + offsety * stride.y + offsetx + 1\r
+\r
+       --add first column\r
+       local column = i\r
+       for y = 1, height do\r
+               nodes[column] = node_id\r
+               column = column + stride.y\r
+       end\r
+\r
+       --add spiral segments\r
+       local axis, other = "x", "z"\r
+       local sign = 1\r
+       local count = height\r
+       for segment = 1, length / spacer - 1 do --go through each segment except the last\r
+               for index = 1, segment * spacer do --fill segment\r
+                       i = i + stride[axis] * sign\r
+                       local column = i\r
+                       for y = 1, height do --add column\r
+                               nodes[column] = node_id\r
+                               column = column + stride.y\r
                        end\r
+                       count = count + height\r
+               end\r
+               axis, other = other, axis --swap axes\r
+               if segment % 2 == 1 then --change sign every other turn\r
+                       sign = -sign\r
                end\r
-               return ret\r
        end\r
-       if env == nil then env = minetest.env end\r
-       -- connect the joined parts\r
-       local spiral = spiralt(width)\r
-       height = tonumber(height)\r
-       if height < 1 then height = 1 end\r
-       spacer = tonumber(spacer)-1\r
-       if spacer < 1 then spacer = 1 end\r
-       local count = 0\r
-       local node = {name=nodename}\r
-       local np,lp\r
-       for y=0,height do\r
-               lp = nil\r
-               for _,v in ipairs(spiral) do\r
-                       np = {x=pos.x+v.x*spacer, y=pos.y+y, z=pos.z+v.z*spacer}\r
-                       if lp~=nil then\r
-                               if lp.x~=np.x then \r
-                                       if lp.x<np.x then \r
-                                               for i=lp.x+1,np.x do\r
-                                                       env:add_node({x=i, y=np.y, z=np.z}, node)\r
-                                                       count = count + 1\r
-                                               end\r
-                                       else\r
-                                               for i=np.x,lp.x-1 do\r
-                                                       env:add_node({x=i, y=np.y, z=np.z}, node)\r
-                                                       count = count + 1\r
-                                               end\r
-                                       end\r
-                               end\r
-                               if lp.z~=np.z then \r
-                                       if lp.z<np.z then \r
-                                               for i=lp.z+1,np.z do\r
-                                                       env:add_node({x=np.x, y=np.y, z=i}, node)\r
-                                                       count = count + 1\r
-                                               end\r
-                                       else\r
-                                               for i=np.z,lp.z-1 do\r
-                                                       env:add_node({x=np.x, y=np.y, z=i}, node)\r
-                                                       count = count + 1\r
-                                               end\r
-                                       end\r
-                               end\r
-                       end\r
-                       lp = np\r
+\r
+       --add shorter final segment\r
+       for index = 1, (math.floor(length / spacer) - 2) * spacer do\r
+               i = i + stride[axis] * sign\r
+               local column = i\r
+               for y = 1, height do --add column\r
+                       nodes[column] = node_id\r
+                       column = column + stride.y\r
                end\r
+               count = count + height\r
        end\r
+print(minetest.serialize(nodes))\r
+       --update map nodes\r
+       manip:set_data(nodes)\r
+       manip:write_to_map()\r
+       manip:update_map()\r
+\r
        return count\r
-end\r
+end
\ No newline at end of file
index 7b65b256e75957eda20e8c91327ede48f1a5b196..731b8d44459edff48aa1e6fe44cfa7463092fb92 100644 (file)
@@ -183,7 +183,7 @@ end
 --loads the nodes represented by string `value` at position `originpos`, returning the number of nodes deserialized\r
 --contains code based on [table.save/table.load](http://lua-users.org/wiki/SaveTableToFile) by ChillCode, available under the MIT license (GPL compatible)\r
 worldedit.deserialize = function(originpos, value)\r
-       --make sure the area stays loaded --wip: not very performant\r
+       --make area stay loaded --wip: not very performant\r
        local pos1, pos2 = worldedit.allocate(originpos, value)\r
        local manip = minetest.get_voxel_manip()\r
        manip:read_from_map(pos1, pos2)\r
index 1a5784973cbc6211ee34b934473f6c3362a0f746..b6c1e794a1bc5dccaaec02fb2f688b95e09ef50b 100644 (file)
@@ -536,8 +536,8 @@ minetest.register_chatcommand("/pyramid", {
 })\r
 \r
 minetest.register_chatcommand("/spiral", {\r
-       params = "<width> <height> <space> <node>",\r
-       description = "Add spiral centered at WorldEdit position 1 with width <width>, height <height>, space between walls <space>, composed of <node>",\r
+       params = "<length> <height> <space> <node>",\r
+       description = "Add spiral centered at WorldEdit position 1 with side length <length>, height <height>, space between walls <space>, composed of <node>",\r
        privs = {worldedit=true},\r
        func = function(name, param)\r
                local pos = worldedit.pos1[name]\r
@@ -546,7 +546,7 @@ minetest.register_chatcommand("/spiral", {
                        return\r
                end\r
 \r
-               local found, _, width, height, space, nodename = param:find("^(%d+)%s+(%d+)%s+(%d+)%s+(.+)$")\r
+               local found, _, length, height, space, nodename = param:find("^(%d+)%s+(%d+)%s+(%d+)%s+(.+)$")\r
                if found == nil then\r
                        worldedit.player_notify(name, "invalid usage: " .. param)\r
                        return\r
@@ -557,7 +557,7 @@ minetest.register_chatcommand("/spiral", {
                        return\r
                end\r
 \r
-               local count = worldedit.spiral(pos, tonumber(width), tonumber(height), tonumber(space), node)\r
+               local count = worldedit.spiral(pos, tonumber(length), tonumber(height), tonumber(space), node)\r
                worldedit.player_notify(name, count .. " nodes added")\r
        end,\r
 })\r
index c241acb9ebb721c833450ff8cb671dd2fdfc0765..3295d747bc660c8c1026d1a29184b64eed7d60d1 100644 (file)
@@ -21,16 +21,21 @@ minetest.register_entity(":worldedit:region_cube", {
        end,\r
 })\r
 \r
---wip: use voxelmanip to put the entity in the correct spot\r
-\r
 --marks worldedit region position 1\r
 worldedit.mark_pos1 = function(name)\r
        local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]\r
+\r
+       if pos1 ~= nil then\r
+               --make area stay loaded\r
+               local manip = minetest.get_voxel_manip()\r
+               manip:read_from_map(pos1, pos1) --wip: see if this even works\r
+       end\r
        if worldedit.marker1[name] ~= nil then --marker already exists\r
                worldedit.marker1[name]:remove() --remove marker\r
                worldedit.marker1[name] = nil\r
        end\r
-       if pos1 ~= nil then --add marker\r
+       if pos1 ~= nil then\r
+               --add marker\r
                worldedit.marker1[name] = minetest.add_entity(pos1, "worldedit:pos1")\r
                worldedit.marker1[name]:get_luaentity().active = true\r
                if pos2 ~= nil then --region defined\r
@@ -42,11 +47,18 @@ end
 --marks worldedit region position 2\r
 worldedit.mark_pos2 = function(name)\r
        local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]\r
+\r
+       if pos2 ~= nil then\r
+               --make area stay loaded\r
+               local manip = minetest.get_voxel_manip()\r
+               manip:read_from_map(pos2, pos2) --wip: see if this even works\r
+       end\r
        if worldedit.marker2[name] ~= nil then --marker already exists\r
                worldedit.marker2[name]:remove() --remove marker\r
                worldedit.marker2[name] = nil\r
        end\r
-       if pos2 ~= nil then --add marker\r
+       if pos2 ~= nil then\r
+               --add marker\r
                worldedit.marker2[name] = minetest.add_entity(pos2, "worldedit:pos2")\r
                worldedit.marker2[name]:get_luaentity().active = true\r
                if pos1 ~= nil then --region defined\r
@@ -56,10 +68,16 @@ worldedit.mark_pos2 = function(name)
 end\r
 \r
 worldedit.mark_region = function(pos1, pos2)\r
+       --make area stay loaded\r
+       local manip = minetest.get_voxel_manip()\r
+       manip:read_from_map(pos1, pos2)\r
+\r
        if worldedit.marker[name] ~= nil then --marker already exists\r
                --wip: remove markers\r
        end\r
-       \r
+       if pos1 ~= nil and pos2 ~= nil then\r
+               --wip: place markers\r
+       end\r
 end\r
 \r
 minetest.register_entity(":worldedit:pos1", {\r