259 posts
Posted 27 May 2016 - 06:45 PM
This program has no sleep() in it, yet it's not that fast. It's run on a command computer and it's designed to find all attached blocks to the block underneath the computer and replace them with air.
I know that these computers have the ability to erase the blocks pretty fast, but this is rather slow.
http://pastebin.com/ZpUjb3uP
2427 posts
Location
UK
Posted 27 May 2016 - 06:54 PM
3057 posts
Location
United States of America
Posted 27 May 2016 - 07:45 PM
commands.getBlockInfo is slow. Try running a few in parallel.
1023 posts
Posted 27 May 2016 - 07:48 PM
commands.getBlockInfo is slow. Try running a few in parallel.
To expand this thread will likely help a lot if you get stuck:
http://www.computercraft.info/forums2/index.php?/topic/24627-getblockinfo-async/execAsync will not work due to the fact getBlockInfo can not be used in async.
259 posts
Posted 27 May 2016 - 11:37 PM
I must not know how to do parallel functions. I looked at the wiki and now it freezes when I put it in. I tried to add a return to the function it calls, but that didn't help and errored saying it was looking for a function and got boolean when I had it return true.
3057 posts
Location
United States of America
Posted 27 May 2016 - 11:45 PM
A common mistake is to call the function and pass the result to the parallel function. Here's an example of how
I would approach this task:
local tCoords = {}
--#add a bunch of coordinates to the tCoords table
local function execCoords()
while #tCoords > 0 do
local x, y, z = (unpack or table.unpack)(table.remove( tCoords, 1 ))
local info = commands.getBlockInfo( x, y, z )
--#do stuff with the info
end
end
local tExecute = {}
for i = 1, 10 do
tExecute[ i ] = execCoords
end
parallel.waitForAll( unpack( tExecute ) )