Guest User

Untitled

a guest
Apr 18th, 2021
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.94 KB | None | 0 0
  1. -- ==========================
  2. -- === Parameter einlesen ===
  3. -- ==========================
  4.  
  5. local tArgs = { ... }
  6.  
  7. if #tArgs ~= 1 then
  8. print( "Usage: eis <anzahlIterationen> (Länge = 2 x anzahlIterationen)" )
  9. print( "Turtle Initialposition: Vorne mitte eins über und eins vor erstem Block" )
  10. print( "Eine Iteration verbraucht 6 Eisblöcke, 4 Zäune, 2 Fackeln" )
  11. print( "Slot 1: Eis, Slot 2: Zäune, Slot 3: Fackeln, Slot 4: leer" )
  12. print( "Darunterliegende Slotreihen analog. Untere Slotreihen ab >10 Iterationen relevant." )
  13. return
  14. end
  15.  
  16. local anzahlIterationen = 1
  17.  
  18. anzahlIterationen = tonumber( tArgs[1] )
  19.  
  20. -- =================
  21. -- === Debugging ===
  22. -- =================
  23.  
  24. print( "Baue Eis-Autobahn mit Länge "..anzahlIterationen.." x 2 " )
  25.  
  26. -- ==========================
  27. -- === Eis-Autobahn bauen ===
  28. -- ==========================
  29.  
  30. local slotMitEisbloecken = 1
  31. local slotMitZaeunen = 2
  32. local slotMitFackeln = 3
  33.  
  34. local aktuelleIteration = 1
  35.  
  36. local aktuelleSlotreiheAbNull = 0
  37.  
  38. local maxIterationenProSlotreihe = 10
  39.  
  40. for aktuelleIteration=1,anzahlIterationen do
  41.  
  42. if aktuelleIteration > (1 * maxIterationenProSlotreihe) then
  43. aktuelleSlotreiheAbNull = 1
  44. end
  45.  
  46. if aktuelleIteration > (2 * maxIterationenProSlotreihe) then
  47. aktuelleSlotreiheAbNull = 2
  48. end
  49.  
  50. if aktuelleIteration > (3 * maxIterationenProSlotreihe) then
  51. aktuelleSlotreiheAbNull = 3
  52. end
  53.  
  54. -- Initialposition nach vorne und eins nach links verlassen um Zielgebiet zu erreichen
  55. turtle.forward()
  56. turtle.down()
  57. turtle.turnLeft()
  58.  
  59. -- Links und rechts jeweils Eisblock, darüber Zaun, darüber Fackel
  60. turtle.select(aktuelleSlotreiheAbNull * 4 + slotMitEisbloecken)
  61. turtle.place()
  62.  
  63. turtle.up()
  64. turtle.select(aktuelleSlotreiheAbNull * 4 + slotMitZaeunen)
  65. turtle.place()
  66.  
  67. turtle.up()
  68. turtle.select(aktuelleSlotreiheAbNull * 4 + slotMitFackeln)
  69. turtle.place()
  70.  
  71. turtle.turnRight()
  72. turtle.turnRight()
  73.  
  74. turtle.down()
  75. turtle.select(aktuelleSlotreiheAbNull * 4 + slotMitZaeunen)
  76. turtle.place()
  77.  
  78. turtle.up()
  79. turtle.select(aktuelleSlotreiheAbNull * 4 + slotMitFackeln)
  80. turtle.place()
  81.  
  82. turtle.down()
  83. turtle.down()
  84. turtle.select(aktuelleSlotreiheAbNull * 4 + slotMitEisbloecken)
  85. turtle.place()
  86.  
  87. -- In der Mitte am Boden einen Eisblock platzieren
  88. turtle.turnLeft()
  89. turtle.up()
  90. turtle.placeDown()
  91.  
  92. -- Links und rechts jeweils einen Eisblock und darüber einen Zaun
  93. turtle.forward()
  94. turtle.down()
  95. turtle.turnLeft()
  96.  
  97. turtle.select(aktuelleSlotreiheAbNull * 4 + slotMitEisbloecken)
  98. turtle.place()
  99.  
  100. turtle.up()
  101. turtle.select(aktuelleSlotreiheAbNull * 4 + slotMitZaeunen)
  102. turtle.place()
  103.  
  104. turtle.turnRight()
  105. turtle.turnRight()
  106.  
  107. turtle.select(aktuelleSlotreiheAbNull * 4 + slotMitZaeunen)
  108. turtle.place()
  109.  
  110. turtle.down()
  111. turtle.select(aktuelleSlotreiheAbNull * 4 + slotMitEisbloecken)
  112. turtle.place()
  113.  
  114. -- In der Mitte am Boden einen Eisblock
  115. turtle.turnLeft()
  116. turtle.up()
  117. turtle.placeDown()
  118. end
  119.  
Advertisement
Add Comment
Please, Sign In to add comment