mirror of
https://github.com/Uberi/Minetest-WorldEdit.git
synced 2025-01-12 11:00:28 +01:00
CPS-ifying stack
Continuation Passing Style lets me use minetest.after, so the server gets a chance to not hang in between every stack iteration. Could even set minetest.after(1000,nextone) if you want to see it extend once every second.
This commit is contained in:
parent
6084db9335
commit
f5b67c5bc2
@ -420,13 +420,19 @@ worldedit.stack = function(pos1, pos2, axis, count)
|
||||
if count < 0 then
|
||||
count = -count
|
||||
length = -length
|
||||
end
|
||||
local amount = 0
|
||||
local copy = worldedit.copy
|
||||
for i = 1, count do
|
||||
amount = amount + length
|
||||
copy(pos1, pos2, axis, amount)
|
||||
end
|
||||
end
|
||||
local amount = 0
|
||||
local copy = worldedit.copy
|
||||
local i = 1
|
||||
function nextone()
|
||||
if i <= count then
|
||||
i = i + 1
|
||||
amount = amount + length
|
||||
copy(pos1, pos2, axis, amount)
|
||||
minetest.after(0,nextone)
|
||||
end
|
||||
end
|
||||
nextone()
|
||||
return worldedit.volume(pos1, pos2) * count
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user