Advertisement
pson

TowerBuilder.lua

Jul 3rd, 2020
1,953
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.50 KB | None | 0 0
  1. -- Make a 7x7 tower (5x5 inside)
  2. -- Slots
  3. -- 1: Fuel
  4. -- 2: Wall and stair materials
  5. -- 3: Floor material
  6. -- 4: Torches
  7.  
  8.  
  9. function forward(steps)
  10.     local i
  11.     if steps > 0 then
  12.         for i=1,steps,1 do
  13.             turtle.forward()
  14.         end
  15.     end
  16. end
  17.  
  18. function back(steps)
  19.     local i
  20.     if steps > 0 then
  21.         for i=1,steps,1 do
  22.             turtle.back()
  23.         end
  24.     end
  25. end
  26.  
  27. function restock(slot, amount)
  28.     while turtle.getItemCount(slot) < amount+1 do
  29.         for i=5,16,1 do
  30.             turtle.select(i)
  31.             if turtle.compareTo(slot) then
  32.                 turtle.transferTo(slot)
  33.                 break
  34.             end    
  35.         end
  36.     end
  37.     turtle.select(slot)
  38. end
  39.  
  40. function wall(stair) -- Build the walls
  41.     local w, i
  42.  
  43.     while turtle.getFuelLevel() < 40 do
  44.         turtle.select(1)
  45.         turtle.refuel(1)
  46.     end
  47.     restock(2,25)
  48.     turtle.up()
  49.     for w=1,4,1 do
  50.         for i=1,6,1 do
  51.             turtle.forward()
  52.             turtle.placeDown()
  53.             if w == 1 and i == stair+1 then
  54.                 turtle.turnRight()
  55.                 turtle.forward()
  56.                 turtle.placeDown()
  57.                 turtle.back()
  58.                 turtle.turnLeft()
  59.             end
  60.         end
  61.         turtle.turnRight()
  62.     end
  63. end
  64.  
  65. function placeLine() -- Place a five long line
  66.     local i
  67.  
  68.     for i=1,4,1 do
  69.         if turtle.detectDown() then
  70.             turtle.digDown()
  71.         end
  72.         turtle.placeDown()
  73.         turtle.forward()
  74.     end
  75.     if turtle.detectDown() then
  76.         turtle.digDown()
  77.     end
  78.     turtle.placeDown()
  79. end
  80.  
  81. function floor() -- Build the floor
  82.     local i
  83.  
  84.     while turtle.getFuelLevel() < 35 do
  85.         turtle.select(1)
  86.         turtle.refuel(1)
  87.     end
  88.     restock(3,20)
  89.     turtle.turnRight()
  90.     turtle.forward()    -- The Wall
  91.     turtle.forward()    -- Stairs
  92.     turtle.turnLeft()
  93.     turtle.forward()
  94.     placeLine()
  95.     turtle.turnRight()
  96.     turtle.forward()
  97.     turtle.turnRight()
  98.     placeLine()
  99.     turtle.turnLeft()
  100.     turtle.forward()
  101.     turtle.turnLeft()
  102.     placeLine()
  103.     turtle.turnRight()
  104.     turtle.forward()
  105.     turtle.turnRight()
  106.     placeLine()
  107.     turtle.forward()
  108.     turtle.turnRight()
  109.     for i=1,5,1 do
  110.         turtle.forward()
  111.     end
  112.     turtle.turnRight()
  113. end
  114.  
  115. function torchIt(slot)
  116.     forward(3)
  117.     turtle.turnRight()
  118.     forward(3)
  119.     turtle.up()
  120.     turtle.select(4)
  121.     turtle.placeDown()
  122.     back(3)
  123.     turtle.turnLeft()
  124.     forward(3)
  125.     turtle.turnRight()
  126.     turtle.down()
  127. end
  128.  
  129. function section()
  130.     wall(1)
  131.     wall(2)
  132.     wall(3)
  133.     wall(4)
  134.     for i=1,6,1 do
  135.         turtle.forward()
  136.     end
  137.     turtle.turnRight()
  138.     wall(1)
  139.     wall(2)
  140.     wall(3)
  141.     wall(4)
  142.     floor()
  143.     torchIt()
  144. end
  145.  
  146. section()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement