Advertisement
Wihad

stairsToBedrock

Dec 20th, 2020 (edited)
483
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.92 KB | None | 0 0
  1. local y=0
  2. -- local tblStairs={"minecraft:cobblestone_stairs", "minecraft:stone_stairs", "extcaves:lavastone_stairs", "extcaves:polished_lavastone_stairs"} not working because if stairs direction!
  3. local tblBlocks={"minecraft:cobblestone", "minecraft:dirt", "minecraft:netherrack", "extcaves:lavastone", "minecraft:basalt", "minecraft:blackstone", "create:weathered_limestone", "quark:deepslate", "quark:cobbled_deepslate", "minecraft:deepslate", "minecraft:cobbled_deepslate", "minecraft:tuff", "byg:soapstone", "byg:scoria_stone", "byg:scoria_cobblestone"}
  4.  
  5.  
  6. function inTable(tbl, item)
  7.     for i, v in ipairs(tbl) do
  8.         if v == item then
  9.             return true
  10.         end
  11.     end
  12.     return false
  13. end
  14.  
  15. function moveForw()
  16.     local try=1
  17.     while not turtle.forward() do
  18.         print("I can't go forward .. try:"..try)
  19.         sleep(1)
  20.         try=try+1
  21.     end
  22. end
  23.  
  24. function moveUp()
  25.     local try=1
  26.     while not turtle.up() do
  27.         print("I can't go up .. try:"..try)
  28.         sleep(1)
  29.         try=try+1
  30.     end
  31. end
  32.  
  33. function moveDown()
  34.     local try=1
  35.     while not turtle.down() do
  36.         print("I can't go down .. try:"..try)
  37.         sleep(1)
  38.         try=try+1
  39.     end
  40.     y=y+1
  41. end
  42.  
  43. function turnL()
  44.     turtle.turnLeft()
  45. end
  46.  
  47. function digForw()
  48.     while turtle.detect() do
  49.         turtle.dig()
  50.     end
  51. end
  52.  
  53. function digUp()
  54.     while turtle.detectUp() do
  55.         turtle.digUp()
  56.     end
  57. end
  58.  
  59. function digDown()
  60.     turtle.digDown()
  61. end
  62.  
  63. function selectStairs()
  64.     for A=1,16 do
  65.         local item=turtle.getItemDetail(A)
  66.         if item then
  67.             if (inTable(tblBlocks, item.name)) then
  68.                 turtle.select(A)
  69.                 return(1)
  70.             end
  71.         end
  72.         if A==16 then
  73.             return(0)
  74.         end
  75.     end
  76. end
  77.  
  78. function placeStairs()
  79.     if not turtle.detectDown() then
  80.         A=selectStairs()
  81.         if A==1 then
  82.             local try=1
  83.             while not turtle.placeDown() do
  84.                 print("I can't place down. a block !..Try: "..try)
  85.                 try=try+1
  86.                 sleep(1)
  87.             end
  88.         end
  89.     end
  90. end
  91.  
  92. function startBuilding()
  93.     while true do
  94.         success, data = turtle.inspectDown()
  95.         if (data.name=="minecraft:bedrock") then break end
  96.         digDown()
  97.         placeStairs()
  98.         success, data = turtle.inspect()
  99.         if (data.name=="minecraft:bedrock") then break end        
  100.         digForw()
  101.         moveForw()
  102.         digUp()
  103.         success, data = turtle.inspectDown()
  104.         if (data.name=="minecraft:bedrock") then break end
  105.         digDown()
  106.         moveDown()
  107.     end
  108. end
  109.  
  110. function goback()
  111.     turnL()
  112.     turnL()
  113.     digUp()
  114.     moveUp()
  115.     digUp()
  116.     moveUp()
  117.     for A=1,y-2 do
  118.         digUp()
  119.         moveUp()
  120.         digUp()
  121.         moveForw()
  122.     end
  123.     moveForw()
  124.     digUp()
  125.     moveForw()
  126. end
  127.  
  128. startBuilding()
  129. goback()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement