Serval_Mart-Lag

champs.lua

May 27th, 2020
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.87 KB | None | 0 0
  1. local function replace()
  2.     local exist, data = turtle.inspectDown()
  3.     if not exist or data.metadata > 2 then
  4.         turtle.digDown()
  5.         turtle.placeDown()
  6.     end
  7. end
  8.  
  9. local function do_champ(c)
  10.     bottom = peripheral.wrap("bottom")
  11.     if bottom.getItemMeta(bottom.size()) == nil then
  12.         print("start "..c)
  13.         turtle.select(1)
  14.         turtle.suckDown(48)
  15.         l = 7
  16.         x = 0
  17.         y = 0
  18.         direction = 0
  19.         for n = 1,11 do
  20.             for i = 1, l do
  21.                 while not turtle.forward() do end
  22.                 replace()
  23.                 if n % 2 == 1 then
  24.                     x = x + 1 - direction
  25.                 else
  26.                     y = y + 2 - direction
  27.                 end
  28.             end
  29.             if c % 4 < 2 then
  30.                 turtle.turnLeft()
  31.                 direction = (direction + 1) % 4
  32.             else
  33.                 turtle.turnRight()
  34.                 direction = (direction - 1) % 4
  35.             end
  36.             if n % 2 == 1 then
  37.                 l = l - 1
  38.             end
  39.         end
  40.         while not turtle.forward() do end
  41.         replace()
  42.         for i = 1,3 do
  43.             while not turtle.forward() do end
  44.         end
  45.         if c % 4 < 2 then
  46.             turtle.turnLeft()
  47.         else
  48.             turtle.turnRight()
  49.         end
  50.         for i = 1, 3 do
  51.             while not turtle.back() do end
  52.         end
  53.         for i = 1,16 do
  54.             turtle.select(i)
  55.             turtle.dropDown()
  56.         end
  57.         turtle.select(1)
  58.     end
  59. end
  60. local function make_moves(min, max)
  61.     print(min.." to "..max)
  62.     for c = min,(max-1) do
  63.         do_champ(c)
  64.         if c % 12 == 6 then
  65.             while not turtle.forward() do end
  66.             turtle.turnLeft()
  67.             while not turtle.forward() do end
  68.             for i = 1, 4 do
  69.                 while not turtle.down() do end
  70.             end
  71.             while not turtle.back() do end
  72.             turtle.turnRight()
  73.             while not turtle.back() do end
  74.         elseif c % 12 == 0 then
  75.             while not turtle.back() do end
  76.             for i = 1, 4 do
  77.                 while not turtle.down() do end
  78.             end
  79.             while not turtle.forward() do end
  80.         elseif c % 4 == 1 then
  81.             turtle.turnRight()
  82.             while not turtle.forward() do end
  83.             while not turtle.forward() do end
  84.             turtle.turnLeft()
  85.         elseif c % 4 == 3 then
  86.             turtle.turnLeft()
  87.             while not turtle.forward() do end
  88.             while not turtle.forward() do end
  89.             turtle.turnRight()
  90.         elseif c % 12 < 6 then
  91.             for i=1,8 do
  92.                 while not turtle.forward() do end
  93.             end
  94.         elseif c % 12 > 6 then
  95.             for i=1,8 do
  96.                 while not turtle.back() do end
  97.             end
  98.         end
  99.     end
  100.     if max >= 1 then
  101.         do_champ(max)
  102.     end
  103. end
  104. local tArgs = { ... }
  105. if #tArgs < 1 then
  106.     make_moves(1,12)
  107.     return
  108. elseif #tArgs == 1 then
  109.     make_moves(1, tonumber(tArgs[1]))
  110. else
  111.     make_moves(tonumber(tArgs[1]), tonumber(tArgs[2]))
  112. end
Add Comment
Please, Sign In to add comment