25
25
26
26
-- sets a region defined by positions `pos1` and `pos2` to `nodename`, returning the number of nodes filled
27
27
worldedit .set = function (pos1 , pos2 , nodenames )
28
+ local oneNode
28
29
if type (nodenames ) == ' string' then
29
- nodenames = {nodenames }
30
+ oneNode = true
31
+ else
32
+ oneNode = false
30
33
end
31
34
32
35
local pos1 , pos2 = worldedit .sort_pos (pos1 , pos2 )
@@ -48,10 +51,10 @@ worldedit.set = function(pos1, pos2, nodenames)
48
51
for i ,v in ipairs (nodenames ) do
49
52
node_ids [i ] = minetest .get_content_id (nodenames [i ])
50
53
end
51
- if # node_ids == 1 then -- only one type of node
52
- local id = node_ids [ 1 ]
54
+ if oneNode then -- only one type of node
55
+ local id = node_ids
53
56
for i in area :iterp (pos1 , pos2 ) do nodes [i ] = id end -- fill area with node
54
- else -- several tpyes of nodes specified
57
+ else -- several types of nodes specified
55
58
local id_count , rand = # node_ids , math.random
56
59
for i in area :iterp (pos1 , pos2 ) do nodes [i ] = node_ids [rand (id_count )] end -- fill randomly with all types of specified nodes
57
60
end
@@ -417,13 +420,19 @@ worldedit.stack = function(pos1, pos2, axis, count)
417
420
if count < 0 then
418
421
count = - count
419
422
length = - length
420
- end
421
- local amount = 0
422
- local copy = worldedit .copy
423
- for i = 1 , count do
424
- amount = amount + length
425
- copy (pos1 , pos2 , axis , amount )
426
- end
423
+ end
424
+ local amount = 0
425
+ local copy = worldedit .copy
426
+ local i = 1
427
+ function nextone ()
428
+ if i <= count then
429
+ i = i + 1
430
+ amount = amount + length
431
+ copy (pos1 , pos2 , axis , amount )
432
+ minetest .after (0 ,nextone )
433
+ end
434
+ end
435
+ nextone ()
427
436
return worldedit .volume (pos1 , pos2 ) * count
428
437
end
429
438
0 commit comments