Commit f0521a58 authored by Fedja Beader's avatar Fedja Beader
Browse files

WorldEdit: add fill command

parent ea6735ad
......@@ -294,6 +294,7 @@ end
local function help()
return ".csmwe off\n"
.. ".csmwe copy [file_name] -- Copy nodes in bounding box selected with .pos\n"
.. ".csmwe fill <item_string> -- fill bounding box with item_string. Use csmwe paste to apply\n"
.. ".csmwe paste -- Paste stored nodes with lowest pos corresponding to .pos 1\n"
.. ".csmwe down [radius_x] [radius_z] [depth] [height] -- by default digs a 10 nodes deep 5x5 hole where you are standing\n"
.. ".csmwe lights <number> -- set the layer period at which autominer places lights above your head\n"
......@@ -314,6 +315,9 @@ local function csmwe_chatcommand_func(param)
if args[2] then
node_storage:save(args[2])
end
elseif args[1] == "fill" and args[2] then
node_storage = WorldEdit.NodeStorage:new() -- overwrite old node_storage
node_storage:fill_bounding_box(positions, args[2])
elseif args[1] == "load" and args[2] then
node_storage = WorldEdit.NodeStorage:load(args[2]) -- overwrite old node_storage
elseif args[1] == "paste" then
......
......@@ -64,6 +64,30 @@ function NodeStorage:convert_for_placement()
end
function NodeStorage:fill_bounding_box(bb, item_string)
if not bb.min then
l:err("Need at least two positions to fill an area")
else
self.bb = bb
-- save all
l:debug("Anchor position: " .. minetest.pos_to_string(bb.min))
for x = bb.min.x, bb.max.x do
for y = bb.min.y, bb.max.y do
for z = bb.min.z, bb.max.z do
local pos = { x = x, y = y, z = z }
local rel_pos = vector.subtract(pos, bb.min)
local node = { name = item_string, param2 = 0 }
table.insert(self.nodes, { pos = rel_pos, node = node} )
end
end
end
self:print_bill_of_materials()
end
end
function NodeStorage:from_bounding_box(bb)
-- needs two positions to save
if not bb.min then
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment