Advertisement
Doob

[ComputerCraft] block resizer

Mar 30th, 2015
333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.92 KB | None | 0 0
  1. --ComputerCraft/CommandComputer/ConstructionResizer
  2. local function findBlock(x, y, z)
  3.   for i = 0, 200 do
  4.     st, block = commands.exec('testforblock ~'..x..' ~'..y..' ~'..z..' '..i)
  5.     if string.sub(block[1], 1, 12) == 'Successfully' then
  6.       return i
  7.     end
  8.   end
  9. end
  10.  
  11. local function builder(size, name, cx, cy, cz)
  12.   for x = 1, size do
  13.     for y = 1, size do
  14.       for z = 1, size do
  15.         commands.exec('setblock ~'..x-size+(size*cx)..' ~'..y-size+(size*cy)..' ~'..z-1+(size*cz)..' '..name)
  16.       end
  17.     end
  18.   end
  19. end
  20.  
  21. local function resize(region, scale)
  22.   for x = 1, region do
  23.     for y = 1, region do
  24.       for z = 1, region do
  25.         builder(scale, findBlock(x, y, z), x, y, 0-z)
  26.       end
  27.     end
  28.   end
  29. end
  30.  
  31. function printUsage()
  32.   print('Usage: resize <size of scanning region> <new size of blocks>')
  33.   return
  34. end
  35.  
  36. local tArgs = {...}
  37. if #tArgs == 2 then
  38.   resize(tArgs[1], tArgs[2])
  39. else printUsage()
  40. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement