Biopsy

biobuild 2.0

May 16th, 2012
440
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.34 KB | None | 0 0
  1. os.loadAPI("utils")
  2. os.loadAPI("matrix")
  3. os.loadAPI("aware")
  4.  
  5. local tArgs = { ... }
  6. structname = tArgs[1]
  7. startpos = {}
  8.  
  9. local function placedown(slot)
  10.     while (turtle.getItemCount(slot) < 2) do
  11.       utils.termwrite("Slot "..slot.." needs a refill!")
  12.     sleep(3)
  13.     end
  14.     turtle.select(slot)
  15.     while(turtle.placeDown() == false) do
  16.       if(turtle.digDown() == false) then
  17.         utils.termwrite("Unable to place block beneath me!")
  18.         sleep(3)
  19.       end
  20.   end
  21. end
  22.  
  23. local function buildlayer(number)
  24.   currentlayer = utils.varfromfile(structname.."/"..structname..number)
  25.  
  26.   for i=1, 50, 2 do
  27.     for j=1, 20 do
  28.       block = matrix.get(currentlayer, i, j)
  29.       if(block ~= nil) then
  30.         aware.moveto((startpos[1]+i), (startpos[2]+j))
  31.         placedown(block)
  32.       end
  33.     end
  34.     for j=20, 1, -1 do
  35.       block = matrix.get(currentlayer, i+1, j)
  36.       if(block ~= nil) then
  37.         aware.moveto((startpos[1]+i+1), (startpos[2]+j))
  38.         placedown(block)
  39.       end
  40.     end
  41.   end
  42. end
  43.  
  44. local function build()
  45.   startpos = aware.getposition("current")
  46.   structpos = 0
  47.   while(fs.exists(structname.."/"..structname..structpos)) do
  48.     buildlayer(structpos)
  49.     aware.digmoveup()
  50.     structpos = structpos + 1
  51.   end
  52.   aware.moveto(startpos[1],startpos[2],startpos[3]+structpos)
  53.   aware.goto(startpos)
  54. end
  55.  
  56. build()
Advertisement
Add Comment
Please, Sign In to add comment