Advertisement
johnneijzen

John Fill Program(2015)

Oct 15th, 2015
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.56 KB | None | 0 0
  1. --[[
  2. Version
  3.         0.01 10/15/2015
  4. Changelog
  5.         0.01 - First Draft
  6. ]]
  7.  
  8. -- Local Variables in My New Program style it now a-z not random
  9. -- Area
  10. local long = 0
  11. local longCount = 0
  12. local wide = 0
  13. local wideCount = 0
  14. --Misc
  15. local buildSlot = 3
  16. local donePlacing = 0
  17. local fuelItem = turtle.getItemCount(1)
  18. local noFuelNeed = 0
  19. local LorR = 0
  20. local selectType = 0
  21.  
  22.  
  23. local function refuel()
  24.     if noFuelNeed == 0 then
  25.         repeat
  26.             if turtle.getFuelLevel() < 100 then
  27.                 if fuelItem > 0 then
  28.                     turtle.select(1)
  29.                     turtle.refuel(1)
  30.                     fuelItem = fuelItem - 1
  31.                 else
  32.                     print("out of fuel")
  33.                     os.shutdown()
  34.                 end
  35.             end
  36.         until turtle.getFuelLevel() >= 100
  37.     end
  38. end
  39.  
  40. local function placeLong()
  41.     if turtle.getItemCount(buildSlot) == 0 then
  42.         repeat
  43.             buildSlot = buildSlot + 1
  44.             if buildSlot > 16 then
  45.                 print("Out of Build Materials")
  46.                 os.shutdown()
  47.             end
  48.         until turtle.getItemCount(buildSlot) > 0
  49.     end
  50.     turtle.select(buildSlot)
  51.     turtle.placeDown()
  52.     turtle.forward()
  53.     longCount = longCount + 1
  54. end
  55.  
  56. local function placeWide()
  57.     if LorR == 0 then
  58.         turtle.turnRight()
  59.     else
  60.         turtle.turnLeft()
  61.     end
  62.     turtle.placeDown()
  63.     turtle.forward()
  64.     if turtle.getItemCount(buildSlot) == 0 then
  65.         repeat
  66.             buildSlot = buildSlot + 1
  67.             if buildSlot > 16 then
  68.                 print("Out of Build Materials")
  69.                 os.shutdown()
  70.             end
  71.         until turtle.getItemCount(buildSlot) > 0
  72.     end
  73.     turtle.select(buildSlot)
  74.     turtle.placeDown()
  75.     if LorR == 0 then
  76.         turtle.turnRight()
  77.         LorR = 1
  78.     else
  79.         turtle.turnLeft()
  80.         LorR = 0
  81.     end
  82.     longCount = 0
  83.     wideCount = wideCount + 1
  84. end
  85.  
  86. local function fill()
  87.     repeat
  88.         refuel()
  89.         placeLong()
  90.         if longCount == long then
  91.             if wideCount == wide then
  92.                 -- Notting
  93.             else
  94.                 placeWide()
  95.             end
  96.         end
  97.         if longCount == long and wideCount == wide then
  98.             donePlacing = 1
  99.         end
  100.     until donePlacing == 1
  101.     print("turtle is Done")
  102. end
  103.  
  104. --starting
  105. local function starting()
  106.     print("welcome to John Fill Program")
  107.     print("Please enter lenght you want to fill")
  108.     long = tonumber(read())
  109.     long = long - 1
  110.     print("Please enter wide you want to fill")
  111.     wide = tonumber(read())
  112.     wide = wide - 1
  113.     print("Please enter what type fill you want")
  114.     print("1 = Fill, 2 = Walls(WIP), 3 = Cube(WIP)")
  115.     selectType = tonumber(read())
  116.     if turtle.getFuelLevel() == "unlimited" then
  117.         print("Your turtle config does need fuel")
  118.         noFuelNeed = 1
  119.     end
  120.     if selectType == 1 then
  121.         fill()
  122.     elseif selectType == 2 then
  123.         -- wall()
  124.     elseif selectType == 3 then
  125.         -- cube()
  126.     end
  127. end
  128.  
  129. starting()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement