CultistaDeCrocs

SeussFazerEscada

Jun 10th, 2021
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.16 KB | None | 0 0
  1. local parou = false
  2. local comecou = nil
  3. local mao = 2
  4. local maoCheia = false
  5.  
  6. term.clear()
  7. term.setCursorPos(1,1)
  8. print("Já que eu não sei qual vai ser o comprimento da escada, eu não sei quanto carvão eu vou precisar, então coloque bastante no primeiro slot do meu inventário.")
  9. print("")
  10. print("coloque bastante do bloco que você quiser no meu inventário. Digite 1 para construir pra cima e digite 2 para construir pra baixo.")
  11. comecou = read()
  12.  
  13. function colocarBloco()
  14.     maoCheia = false
  15.     while not maoCheia do
  16.         if(mao > 16) then
  17.             term.clear()
  18.             term.setCursorPos(1,1)
  19.             term.setTextColor(colors.red)
  20.             print("ERRO: acabaram meus blocos")
  21.             term.setTextColor(colors.white)
  22.             error()
  23.         end
  24.         turtle.select(mao)
  25.         if(turtle.getItemCount (mao) > 0) then
  26.             maoCheia = true
  27.         else
  28.             maoCheia = false
  29.             mao = mao + 1
  30.         end
  31.     end
  32.     turtle.placeDown()
  33. end
  34.    
  35.  
  36.  
  37. function detectarChao()
  38.     local isBlock, block = turtle.inspectDown()
  39.     if (isBlock) then
  40.         parou = true
  41.     end
  42. end
  43.  
  44. function detectarColisao()
  45.     local isBlock, block = turtle.inspect()
  46.     if (isBlock) then
  47.         parou = true
  48.     end
  49. end
  50.  
  51. function andarFrente()
  52.     if not turtle.forward() then
  53.         turtle.select(1)
  54.         turtle.refuel(1)
  55.         turtle.forward()
  56.     end
  57. end
  58.  
  59. function andarCima()
  60.     if not turtle.up() then
  61.         turtle.select(1)
  62.         turtle.refuel(1)
  63.         turtle.up()
  64.     end
  65. end
  66.  
  67. function andarBaixo()
  68.     if not turtle.down() then
  69.         turtle.select(1)
  70.         turtle.refuel(1)
  71.         turtle.down()
  72.     end
  73. end
  74.  
  75. function construirEscada()
  76.     if(comecou == "1") then
  77.         colocarBloco()
  78.         andarCima()
  79.         detectarColisao()
  80.         andarFrente()
  81.         detectarChao()
  82.     end
  83.     if(comecou == "2") then
  84.         colocarBloco()
  85.         detectarColisao()
  86.         andarFrente()
  87.         andarBaixo()
  88.         detectarChao()
  89.     end
  90. end
  91.  
  92. while comecou == nil do
  93.    
  94. end
  95.  
  96. if(comecou ~= "1" and comecou ~= "2") then
  97.     term.clear()
  98.     term.setCursorPos(1,1)
  99.     term.setTextColor(colors.red)
  100.     print("ERRO: escolha inválida. Rode o programa de novo e escolha apenas 1 ou 2.")
  101.     term.setTextColor(colors.white)
  102.     error()
  103. end
  104.  
  105. while not parou do
  106.     construirEscada()
  107. end
  108. term.clear()
  109. term.setCursorPos(1,1)
  110. print("Terminei. Obrigado por comprar o S.E.U.S.S.!")
  111.  
Advertisement
Add Comment
Please, Sign In to add comment