Advertisement
taoshi

Untitled

Jan 20th, 2021 (edited)
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.70 KB | None | 0 0
  1. --quarry
  2. --копает область х, z, y размером
  3. --в положительной оси координат
  4. --вперёд z, вправо х, вниз у блоков
  5. function quarry(x,z,y)
  6.  local x, z, y=x, z, y
  7.  local robot=require("component.robot")
  8.  local detect=require("robot.detect")
  9.  local swing=require("robot.swing")
  10.  local forward=require("robot.forward")
  11.  local mSide=reqiure("robot.side")
  12.  local dig = --вперёд вниз вверх
  13.     function(side)
  14.      if detect[side]
  15.       then swing[side]
  16.      end
  17.     return robot[side]
  18.     end
  19.    
  20.     function trawel(i,side)
  21.      for f=2,i do mSide(side) end
  22.      return true end
  23.    
  24.     local up={} --возврат по координатам
  25.     up[0]=function()
  26.      trawel(y, "up")
  27.     end
  28.    
  29.     up[1]=function()
  30.      trawel(y, "up")
  31.      robot.turn("right")
  32.      trawel(z, "forward")
  33.      robot.turnAround()
  34.     end
  35.    
  36.     up[3]=function()
  37.      trawel(y, "up")
  38.      trawel(x, "forward")
  39.      robot.turn(right)
  40.     end
  41.    
  42.     up[2]=function()
  43.      trawel(z, "forward")
  44.      robot.turn("right")
  45.      up[3]()
  46.     end
  47.    
  48.     local turnSide="turnRight"
  49.     local nextTurn="turnLeft"
  50.    
  51.  for cy=2,y do --основной цикл копки
  52.   dig("down")
  53.   for cx=2,x do
  54.    for cz=2,z do
  55.    dig("forward")
  56.    end --cz loop
  57.  
  58.   robot[turnSide]()
  59.   if cx<x then
  60.    dig("forward")
  61.    robot.forward()
  62.    else if x%2==0 robot.turnLeft() end
  63.   end
  64.   robot[turnSide]()
  65.  
  66.   turnSide, nextTurn=nextTurn, turnSide
  67.   end --cx loop
  68.   robot[nextTurn]()
  69.  end --cy loop
  70.  --вычисляем в каком углу робот:
  71.  --1=z 2=zx 3=x 4=0 и возвращаемся
  72.  
  73.  up[((3+x%2)*y)%4]
  74.  
  75. end  --возврат из функции карьер
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement