Advertisement
guerre10

Rails

Aug 12th, 2022 (edited)
670
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.47 KB | None | 0 0
  1. function power()
  2.     --place a powered rail
  3.     turtle.down()
  4.     --place a earth block first
  5.     turtle.select(15)
  6.     turtle.placeDown()
  7.     turtle.up()
  8.     turtle.turnRight()
  9.     turtle.forward()
  10.     --place a redstone torch, but first a block
  11.     turtle.select(16)
  12.     turtle.down()
  13.     turtle.placeDown()
  14.     turtle.up()
  15.     turtle.select(7)
  16.     if turtle.getItemCount()== 0 then
  17.         turtle.select(8)
  18.     end
  19.     turtle.placeDown()
  20.     turtle.turnLeft()
  21.     turtle.turnLeft()
  22.     turtle.forward()
  23.     turtle.turnRight()
  24.     turtle.select(5)
  25.     if turtle.getItemCount()== 0 then
  26.         turtle.select(6)
  27.     end
  28.     turtle.placeDown()
  29.     turtle.placeDown()
  30. end
  31.  
  32. function normal()
  33.     turtle.down()
  34.     turtle.select(16)
  35.     turtle.placeDown()
  36.     turtle.up()
  37.     --inventory checks
  38.     local slot= 1
  39.     turtle.select(1)
  40.     while turtle.getItemCount()== 0 do
  41.         slot= slot +1
  42.         turtle.select(slot)
  43.     end
  44.     turtle.placeDown()
  45. end
  46.  
  47. function pathing()
  48.     path= math.random(1,8)
  49.             --5 and 6 turn, 3 and 7
  50.     if path== 5 then
  51.         turtle.turnLeft()
  52.         turtle.forward()
  53.     elseif path== 6 then
  54.         turtle.turnRight()
  55.         turtle.forward()
  56.     elseif path == 3 or 7 then
  57.         turtle.forward()
  58.         turtle.up()
  59.     elseif path == 2 then
  60.         turtle.forward()
  61.         turtle.down()
  62.     else
  63.         turtle.forward()
  64.     end
  65.  
  66. end
  67.  
  68. function makePath(size)
  69.     power()
  70.     for i = 1, size do
  71.         if i%6== 0 then
  72.         --every 6 place a powered rail and go straight ahead
  73.             power()
  74.         else
  75.             pathing()
  76.             normal()
  77.         end
  78.     end
  79. end
  80.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement