jordyvl

Platform builder

Nov 24th, 2013
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Turtle platform builder, builds a square platform using whatever stuff is in it's inventory
  2. -- put fuel in any slot.
  3. -- USAGE:     platform 10    (default is 8)
  4. -- will build a 10x10 platform, one block below the turtle's position starting at the front-left of the platform
  5. -- try to put fuel AFTER the blocks he's placing, otherwise he might try to place the fuel
  6.  
  7. -- this function places a whole row of stuff
  8. function placeArow()
  9.  for row=1,size-1 do
  10.   k=1
  11.   local count=0
  12.   while count<1 do
  13.    count=turtle.getItemCount(k)
  14.    k=k+1
  15.    if (k>16) then
  16.     print("No more materials! add some...it's ok, I'll wait...")
  17.     os.sleep(10)
  18.     k=1;
  19.    end --endif
  20.   end  --endwhile
  21.   turtle.select(k-1)
  22.   turtle.placeDown()
  23.   turtle.forward()
  24.   end  -- next row
  25.   turtle.placeDown()
  26.  end
  27.  
  28.  function grabFuel()
  29.  for i=1,16 do
  30.   turtle.select(i)
  31.   turtle.refuel()
  32.  end
  33. end
  34.  
  35. -------------------  START
  36. args = {...}
  37. size = args[1]
  38. if (size=="") then
  39.  size=8
  40. end
  41.  
  42. print ("building platform of "..size.." x "..size..", "..turtle.getFuelLevel().." Fuel left..")
  43. grabFuel()
  44.  
  45. for column=1,math.floor(size/2) do
  46.  placeArow()
  47.  turtle.turnRight()
  48.  turtle.forward()
  49.  turtle.turnRight()
  50.  
  51.  grabFuel()
  52.  
  53.  placeArow()
  54.  turtle.turnLeft()
  55.  turtle.forward()
  56.  turtle.turnLeft()
  57. end -- next column
  58.  
  59. turtle.turnLeft()
  60. for i=1,size do
  61.  turtle.forward()
  62. end
  63. turtle.turnRight()
  64. print("I'm done here, hope you like my work.")
  65. sleep(3)
Add Comment
Please, Sign In to add comment