Advertisement
TeoremaPi

Portal

Sep 6th, 2020
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.29 KB | None | 0 0
  1. -- programa para contruir los portales de la subestacion electrica
  2. -- altura de las torres
  3. htorre = 12
  4.  
  5. -- altura de la viga
  6. hviga = 10
  7.  
  8. -- longitud de la viga
  9. lviga = 15
  10.  
  11.  
  12. -- funcion para colocar bloque
  13. turtle.select(1)
  14.  
  15. function colocarBloque(direccion)
  16.   -- seleccionamos el siguiente slot con materiales
  17.   while (turtle.getItemCount() == 0) and (turtle.getSelectedSlot() < 16) do
  18.     turtle.select(turtle.getSelectedSlot() + 1)
  19.   end
  20.  
  21.   if (turtle.getItemCount() == 0) and (turtle.getSelectedSlot() == 16) then
  22.       return false
  23.   end
  24.  
  25.   if direccion == 'delante' then
  26.     turtle.place()
  27.   elseif direccion == 'debajo' then
  28.     turtle.placeDown()
  29.   end
  30.  
  31.   return true
  32. end
  33.  
  34. -- construimos la primera torre
  35. for k = 1, htorre do
  36.   turtle.up()
  37.  
  38.   if not colocarBloque('debajo') then
  39.     return
  40.   end
  41. end
  42.  
  43. -- contruimos la viga
  44. turtle.forward()
  45. for k = 1, htorre - hviga do
  46.   turtle.down()
  47. end
  48.  
  49. for k = 1, lviga do
  50.   if not colocarBloque('debajo') then
  51.     return
  52.   end
  53.  
  54.   turtle.forward()
  55. end
  56.  
  57. -- contruimos la segunda torre (hacia abajo)
  58. turtle.forward()
  59.  
  60. turtle.turnRight()
  61. turtle.turnRight()
  62.  
  63. for k = 1, htorre - hviga - 1 do
  64.   turtle.up()
  65. end
  66.  
  67. for k = 1, htorre do
  68.   if not colocarBloque('delante') then
  69.     return
  70.   end
  71.  
  72.   turtle.down()
  73. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement