CultistaDeCrocs

stairs

Sep 15th, 2024 (edited)
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.03 KB | None | 0 0
  1. local escolha = nil
  2. local passos = 0
  3. local parou = false
  4.  
  5. local asshat = require("libraries.asshat")
  6.  
  7. function detectarChao()
  8.     local isBlock, block = turtle.inspectDown()
  9.     if (isBlock) then
  10.         parou = true
  11.     end
  12. end
  13.  
  14. function detectarColisao()
  15.     local isBlock, block = turtle.inspect()
  16.     if (isBlock) then
  17.         parou = true
  18.         colocarBaixo()
  19.     end
  20. end
  21.  
  22. function andarFrente()
  23.     if not turtle.forward() then
  24.         turtle.select(1)
  25.         turtle.refuel(1)
  26.         turtle.forward()
  27.     end
  28.     passos = passos+1
  29. end
  30.  
  31. function andarCima()
  32.     if not turtle.up() then
  33.         turtle.select(1)
  34.         turtle.refuel(1)
  35.         turtle.up()
  36.     end
  37.     passos = passos+1
  38. end
  39.  
  40. function andarBaixo()
  41.     if not turtle.down() then
  42.         turtle.select(1)
  43.         turtle.refuel(1)
  44.         turtle.down()
  45.     end
  46.     passos = passos+1
  47. end
  48.  
  49. function constroiCima()
  50.     while not parou do
  51.         colocarBaixo()
  52.         andarCima()
  53.         detectarColisao()
  54.         andarFrente()
  55.         detectarChao()
  56.         detectarColisao()
  57.     end
  58. end
  59.  
  60. function constroiBaixo()
  61.     while not parou do
  62.         colocarBaixo()
  63.         detectarColisao()
  64.         andarFrente()
  65.         andarBaixo()
  66.         detectarChao()
  67.         detectarColisao()
  68.     end
  69. end
  70.  
  71. function cavaBaixo()
  72.     print ("Please input the number of steps.")
  73.     local numDegraus = lerNumero()
  74.    
  75.     for i=0, numDegraus do
  76.         turtle.dig()
  77.         andarFrente()
  78.         turtle.digUp()
  79.         turtle.digDown()
  80.         andarBaixo()
  81.         turtle.digDown()
  82.     end
  83. end
  84.  
  85. function constroiQuarry()
  86.     while(not(turtle.inspectDown())) do
  87.         while(not(turtle.inspect())) do
  88.             colocarBaixo()
  89.             andarFrente()
  90.             andarBaixo()
  91.         end
  92.         turtle.turnRight()
  93.     end
  94. end
  95.  
  96. function construirEscada()
  97.     local funcoes =
  98.     {
  99.         [1] = constroiCima,
  100.         [2] = constroiBaixo,
  101.         [3] = constroiQuarry,
  102.         [4] = cavaBaixo
  103.     }
  104.    
  105.     local funcao = funcoes[escolha]
  106.     funcao()
  107. end
  108.  
  109.  
  110. -- Main
  111.  
  112. informacaoTitulo("S T A I R  B U I L D E R")
  113. print("Put lots of coal in my 1st inventory slot and lots of blocks in my 2nd one.\n")
  114. print("Choose mode:")
  115. imprimirTabela({"Build up", "Build down", "Build spiral up", "Dig down"})
  116.  
  117. escolha = pedeEscolha(4)
  118. construirEscada()
  119. agradece(passos)
Add Comment
Please, Sign In to add comment