Advertisement
M0n5t3r

Floor_Bot

Jul 4th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.71 KB | None | 0 0
  1. local stone_slot = 0
  2.  
  3. local ender_chest_slot = 1
  4.  
  5. local forward_motion = 0
  6. local left_motion = 0
  7.  
  8. local left_right = "right"
  9.  
  10. term.write("Insert Length: ")
  11. Length = tonumber(read()) - 1
  12. print(" ")
  13.  
  14. term.write("Insert Width: ")
  15. Width = tonumber(read())
  16. print(" ")
  17.  
  18. local Length = Length
  19. local Width = Width
  20.  
  21.  
  22. function selectStone()
  23.     local is_stone = 0
  24.     for q=2,15 do
  25.         local item_detail = turtle.getItemDetail(q)
  26.         if item_detail then
  27.             if string.find(item_detail.name, "stone_slab") ~= nil and item_detail.count > 1 then
  28.                 is_stone = q
  29.                 break
  30.             end
  31.         end
  32.     end
  33.     if is_stone == 0 then
  34.         print("no stones found, gotte get some")
  35.         refilChest()
  36.     else
  37.         stone_slot = is_stone
  38.         turtle.select(stone_slot)
  39.         print(stone_slot)
  40.     end
  41. end
  42. function refilChest()
  43.     turtle.select(ender_chest_slot)
  44.     if turtle.place() then
  45.         --suck all items, than turn left  
  46.         for q=2,16 do
  47.             turtle.select(q)
  48.             local toSuck = 64 - turtle.getItemCount(q)
  49.             turtle.suck(toSuck)
  50.         end
  51.         --
  52.         turtle.select(ender_chest_slot)
  53.         if turtle.getItemCount(ender_chest_slot) == 0 then
  54.             print("Chest is right")
  55.             turtle.dig()
  56.             turtle.select(2)
  57.         else
  58.             turtle.select(ender_chest_slot)
  59.             turtle.drop(64)
  60.             turtle.dig()
  61.             turtle.select(2)
  62.         end
  63.     else
  64.         --als ik 'm niet kan plaatsten moet hij draaien ofzo
  65.         turtle.turnRight()
  66.         if turtle.place() then
  67.             --suck all items, than turn Right
  68.             for q=2,16 do
  69.                 turtle.select(q)
  70.                 local toSuck = 64 - turtle.getItemCount(q)
  71.                 turtle.suck(toSuck)
  72.             end
  73.             --
  74.             turtle.select(ender_chest_slot)
  75.             if turtle.getItemCount(ender_chest_slot) == 0 then
  76.                 print("Chest is right")
  77.                 turtle.dig()
  78.                 turtle.select(2)
  79.             else
  80.                 turtle.select(ender_chest_slot)
  81.                 turtle.drop(64)
  82.                 turtle.dig()
  83.                 turtle.select(2)
  84.             end
  85.             turtle.turnLeft()
  86.         else
  87.             while turtle.place() == false do
  88.                 turtle.dig()
  89.             end
  90.             --suck all items, than turn Right
  91.             for q=2,16 do
  92.                 turtle.select(q)
  93.                 local toSuck = 64 - turtle.getItemCount(q)
  94.                 turtle.suck(toSuck)
  95.             end
  96.  
  97.             turtle.select(ender_chest_slot)
  98.             if turtle.getItemCount(ender_chest_slot) == 0 then
  99.                 print("Chest is right")
  100.                 turtle.dig()
  101.                 turtle.select(2)
  102.             else
  103.                 turtle.select(ender_chest_slot)
  104.                 turtle.drop(64)
  105.                 turtle.dig()
  106.                 turtle.select(2)
  107.             end
  108.  
  109.             turtle.turnLeft()
  110.         end
  111.     end
  112. end
  113. function empty_if_not_right()
  114.     if string.find(turtle.getItemDetail(1).name, "ender") ~= nil then
  115.         print("Chest is right")
  116.     else
  117.         print("Seem to lost my chest? ")
  118.     end
  119.  
  120.     for p=2,16 do
  121.         if string.find(turtle.getItemDetail(p).name, "stone_slab") ~= nil then
  122.             print("Slot: " .. p .. " has stones")
  123.         else
  124.             turtle.select(p)
  125.             turtle.turnLeft()
  126.             turtle.turnLeft()
  127.             turtle.drop(64)
  128.             turtle.turnRight()
  129.             turtle.turnRight()
  130.             print("Seem to have no stone? ")
  131.             refilChest()
  132.         end
  133.     end
  134. end
  135. function place_or_not()
  136.     selectStone()
  137.     while turtle.placeUp() == false do
  138.         turtle.digUp()
  139.     end
  140. end
  141.  
  142. function makeLine()
  143.     place_or_not()
  144.     repeat
  145.         if turtle.forward() then
  146.             forward_motion = forward_motion + 1
  147.             place_or_not()
  148.         else
  149.             if forward_motion > (Length - 10) then
  150.                 break
  151.             end
  152.         end
  153.     until forward_motion == Length
  154.     forward_motion = 0
  155. end
  156.  
  157. function start()
  158.     print("Starting")
  159.     repeat
  160.         makeLine()
  161.         empty_if_not_right()
  162.         if left_right == "left" then
  163.             turtle.turnRight()
  164.             turtle.forward()
  165.             turtle.turnRight()
  166.             left_motion = left_motion + 1
  167.             left_right = "right"
  168.         else
  169.             turtle.turnLeft()
  170.             turtle.forward()
  171.             turtle.turnLeft()
  172.             left_motion = left_motion + 1
  173.             left_right = "left"
  174.         end
  175.     until left_motion == Width
  176.     makeLine()
  177.     print("Done?")
  178. end
  179.  
  180. start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement