Advertisement
serafim7

quarry карьер [OpenComputers]

Nov 23rd, 2019 (edited)
1,311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 21.26 KB | None | 0 0
  1. --[[ opencomputers карьер by serafim
  2.      pastebin.com/1m7k9F01   update 13.06.21
  3.      
  4. https://computercraft.ru/topic/3927-quarry-karer/
  5.  
  6. Копает змейкой квадрат проходя три слоя блоков за один подход,
  7. пока не выкопает весь объём до бэдрока или не упрётся в
  8. не разрушаемый блок, при этом вернётся к старту и сообщит о проблеме,
  9. также предложит продолжить копать с последней позиции.
  10.  
  11. требования:
  12. инвентарь, контроллер инвентаря, генератор, улучшение парение.
  13.  
  14. пример сборки:
  15. https://i.imgur.com/fR7F4fA.png
  16.  
  17. использование:
  18. на старте, сзади робота поставить сундук,
  19. положить в сундук запасной инструмент, уголь больше 20 штук.
  20. Робот может работать без сундука и всего прочего, нужна только кирка.
  21.  
  22. пример запуска: (по умолчанию один чанк)
  23. quarry 16 16 2  или  quarry
  24. -- 2 опустится в низ на 2 блока от старта.
  25.  
  26. получить список предметов:
  27. https://pastebin.com/au9etcfF
  28. ]]--
  29.  
  30. local a = {...}
  31. local width = tonumber(a[1]) or 16 --ширина
  32. local length = tonumber(a[2]) or 16 --длина
  33. local down = tonumber(a[3]) or 2 --опустится в низ
  34.  
  35. --список мусора
  36. local scrap = {
  37.   "cobblestone", --булыжник
  38.   "stone",       --камень
  39.   "dirt",        --земля
  40.   "gravel",      --гравий
  41.   "flint",       --кремень
  42.   "sand",        --песок
  43.   "sandstone"    --песчаник
  44. }
  45.  
  46. --список инструмента
  47. local toollist = {
  48.   "ickaxe",
  49.   "rill",
  50.   "pick",
  51.   "vajra"
  52. }
  53.  
  54. local event = require("event")
  55. local com = require('component')
  56. local computer = require("computer")
  57. local fuelchest,fuelinv,refuel,charger = true,true,true,false
  58. local cheststart,ridht,bedrock = true,true,false
  59. local depth,xPos,zPos,xDir,zDir = 0,0,0,0,1
  60. local timestart = computer.uptime()
  61. local unloaded,durability = 0,0
  62. local toolstrength = 0.07
  63. local x,y,z,xd,zd
  64.  
  65. if not com.isAvailable("robot") then
  66.   print("только роботы могут использовать эту программу")
  67.   os.exit()
  68. end
  69. local r = require("robot")
  70.  
  71. local invsize = r.inventorySize()
  72. local tools = invsize
  73. local coal = invsize-1
  74.  
  75. if not com.isAvailable("inventory_controller") then
  76.   print("нет контроллера инвентаря")
  77.   os.exit()
  78. end
  79. local i_c = com.inventory_controller
  80.  
  81. if not com.isAvailable("generator") then
  82.   print("нет генератора")
  83.   os.exit()
  84. end
  85. local gen = com.generator
  86.  
  87. --статус
  88. local function status(msg)
  89.   print("[ "..os.date("%H:%M:%S",computer.uptime()-timestart).." ] "..msg)
  90. end
  91.  
  92. --чанк лоадер
  93. local function chunkload(state)
  94.   if com.isAvailable("chunkloader") then
  95.     if state then
  96.       com.chunkloader.setActive(true)
  97.       print("чанк лоадер активен")
  98.     else
  99.       com.chunkloader.setActive(false)
  100.       print("чанк лоадер деактивирован".."\n")
  101.     end
  102.   end
  103. end
  104.  
  105. --поиск предмета в инвентаре робота
  106. local function slotitem(slot,list)
  107.   local item = i_c.getStackInInternalSlot(slot)
  108.   if item then
  109.     for j, name in pairs(list) do
  110.       if string.find(item.name,name) then
  111.         if item.charge == nil or item.charge/item.maxCharge > toolstrength then
  112.           return true
  113.         end
  114.       end
  115.     end
  116.   end
  117.   for i = 1,invsize do
  118.     if r.count(i) > 0 then
  119.       for j, name in pairs(list) do
  120.         local item = i_c.getStackInInternalSlot(i)
  121.         if item and string.find(item.name,name) then
  122.           if item.charge == nil or item.charge/item.maxCharge > toolstrength then
  123.             r.select(i)
  124.             r.transferTo(slot)
  125.             return true
  126.           end
  127.         end
  128.       end
  129.     end
  130.   end
  131.   return false
  132. end
  133.  
  134. --взять из сундука расходники
  135. local function servise(slotinv,list)
  136.   local inv = i_c.getInventorySize(3)
  137.   if inv then
  138.     if slotitem(slotinv,list) then
  139.       return true
  140.     end
  141.     r.select(slotinv)
  142.     if r.count(slotinv) > 0 and not r.drop() then
  143.       returnHome("в сундуке нет места")
  144.       return false
  145.     end
  146.     for slot = 1,inv do
  147.       for j, name in pairs(list) do
  148.         local item = i_c.getStackInSlot(3,slot)
  149.         if item and string.find(item.name,name) then
  150.           if item.charge == nil or item.charge/item.maxCharge > toolstrength then
  151.             i_c.suckFromSlot(3,slot)
  152.             return true
  153.           end
  154.         end
  155.       end
  156.     end
  157.     return false
  158.   else
  159.     returnHome("нет сундука")
  160.   end
  161. end
  162.  
  163. --заряжаемся от зарядчика
  164. local function charging()
  165.   local chardg = true
  166.   while true do
  167.     local e1 = computer.energy()
  168.     os.sleep(2)
  169.     local e2 = computer.energy()  
  170.     if e2 > e1 + 500 then
  171.       if chardg then
  172.         chardg = false
  173.         status("заряжаюсь...")
  174.       end
  175.       os.sleep(2)
  176.     else
  177.       break
  178.     end
  179.   end
  180. end
  181.  
  182. --сортируем лут
  183. local function sortlut(droplut)
  184.   status("сортирую лут...")
  185.   r.swingDown()
  186.   for i = 1,invsize do      
  187.     if r.count(i) > 0 then
  188.       local item = i_c.getStackInInternalSlot(i)
  189.       if string.find(item.name,"coal") then
  190.         r.select(i)
  191.         r.transferTo(coal)
  192.       else
  193.         for n = 1,#scrap do
  194.           if scrap[n] == item.name:gsub('%g+:','') then
  195.             r.select(i)
  196.             r.dropDown()
  197.             break
  198.           end
  199.         end
  200.       end
  201.     end
  202.   end
  203.   for i = 1,invsize-2 do
  204.     if r.count(i) == 0 then
  205.       for j = invsize-2,1,-1 do
  206.         if r.count(j) > 0 then
  207.           if j < i then
  208.             break
  209.           end
  210.           r.select(j)
  211.           r.transferTo(i)
  212.           break
  213.         end
  214.       end
  215.     end
  216.   end
  217.   local unload = function()
  218.     local inv = i_c.getInventorySize(3)
  219.     if inv then
  220.       cheststart = true
  221.       for i = 1,invsize-2 do
  222.         if r.count(i) > 0 then
  223.           r.select(i)
  224.           unloaded = unloaded + r.count(i)
  225.           if not r.drop() then
  226.             returnHome("в сундуке нет места")
  227.             return
  228.           end
  229.         end
  230.       end
  231.       if not charger then
  232.         servise(tools,toollist)
  233.       end
  234.       r.select(coal)
  235.       gen.insert()
  236.       servise(coal,{"coal"})
  237.       charging()
  238.     elseif not cheststart then
  239.       returnHome("инвентарь заполнен")
  240.     else
  241.       returnHome("нет сундука")
  242.     end
  243.     fuelchest = true
  244.     status("всего добыто руды: "..unloaded)
  245.   end
  246.   if r.count(invsize-6) > 0 then
  247.     status("возвращаюсь к сундуку сложить лут")
  248.     x,y,z,xd,zd = xPos,depth,zPos,xDir,zDir
  249.     goTo( 0,0,0,0,-1 )
  250.     unload()
  251.     goTo( x,y,z,xd,zd )
  252.   end
  253.   if droplut and cheststart then
  254.     unload()
  255.   end
  256.   r.select(1)
  257. end
  258.  
  259. --стоп
  260. local function stop(msg)
  261.   print("\n".."!!! стоп !!!".."\n"..msg.."\n")
  262.   r.setLightColor(0xFF0000)
  263.   r.turnAround()
  264.   chunkload(false)
  265.   computer.beep(1000, 1)
  266.   status("программа завершена")
  267.   os.exit()
  268. end
  269.  
  270. --возврат к старту
  271. function returnHome(msg,save,reason)
  272.   r.setLightColor(0xFF0000)
  273.   if save then
  274.     x,y,z,xd,zd = xPos,depth,zPos,xDir,zDir
  275.   end
  276.   if y ~= nil then
  277.     print("последняя ширина "..width..", длина "..length..", глубина "..y)
  278.   end
  279.   goTo( 0,0,0,0,-1 )
  280.   if save and cheststart and r.count(1) > 0 then
  281.     sortlut(true)
  282.   end
  283.   goTo( 0,0,0,0,1 )
  284.   if reason then
  285.     print("причина возврата: "..reason)
  286.   end
  287.   status("!!! стоп !!!".."\n"..msg.."\n")
  288.   chunkload(false)
  289.   print("продолжить копать ? [Y/n]")
  290.   while true do
  291.     r.setLightColor(0xFFFFFF)
  292.     computer.beep(1000, 1)
  293.     r.setLightColor(0xFF0000)
  294.     local e = ({event.pull(10,"key_down")})[4]
  295.     if e == 49 then
  296.       computer.beep(500, 0.1)
  297.       print("программа завершена")
  298.       os.exit()
  299.     elseif e == 21 or e == 28 then
  300.       computer.beep(500, 0.1)
  301.       r.setLightColor(0xFFFFFF)
  302.       print("продолжаю копать...")
  303.       chunkload(true)
  304.       goTo( x,y,z,xd,zd )
  305.       break
  306.     end
  307.   end
  308. end
  309.  
  310. --дозаправка углём
  311. local function checkfuel()
  312.   if computer.energy() <= 6000 then
  313.     refuel = true
  314.   end
  315.   if gen.count() <= 10 and refuel then
  316.     for i = 1,invsize do
  317.       local item = i_c.getStackInInternalSlot(i)
  318.       if item and string.find(item.name,"coal") then
  319.         r.select(i)
  320.         r.transferTo(coal)
  321.       end
  322.     end
  323.     r.select(coal)
  324.     if gen.insert() then
  325.       fuelinv = true
  326.       status("заправился, угля в генераторе = "..gen.count())
  327.     elseif fuelchest and cheststart then
  328.       x,y,z,xd,zd = xPos,depth,zPos,xDir,zDir
  329.       status("возвращаюсь к сундуку за углем")
  330.       goTo( 0,0,0,0,-1 )
  331.       if servise(coal,{"coal"}) then
  332.         r.select(coal)
  333.         gen.insert()
  334.         status("заправился, угля в генераторе = "..gen.count())
  335.       else
  336.         fuelchest = false
  337.         status("в сундуке нет угля")
  338.       end
  339.       charging()
  340.       goTo( x,y,z,xd,zd )
  341.     else
  342.       refuel = false
  343.       if fuelinv then
  344.         fuelinv = false
  345.         status("нет угля в инвентаре робота !!!")
  346.       end
  347.     end
  348.     r.select(1)
  349.   end
  350.   if computer.energy() <= 5000 then
  351.     x,y,z,xd,zd = xPos,depth,zPos,xDir,zDir
  352.     status("энергии < 5 000 возвращаюсь")
  353.     goTo( 0,0,0,0,1 )
  354.     charging()
  355.     if computer.energy() >= 10000 then
  356.       status("зарядился :)")
  357.       goTo( x,y,z,xd,zd )
  358.       return
  359.     elseif gen.count() >= 10 then
  360.       status("мало энергии, заряжаюсь до 10 000")
  361.       while true do
  362.         os.sleep(10)
  363.         if computer.energy() >= 10000 then
  364.           status("зарядился :)")
  365.           goTo( x,y,z,xd,zd )
  366.           break
  367.         elseif gen.count() == 0 then
  368.           returnHome("закончился уголь")
  369.           break
  370.         end
  371.       end
  372.     else
  373.       returnHome("закончился уголь")
  374.     end
  375.   end
  376. end
  377.  
  378. --проверяем разряженный электроинструмент
  379. local function electric(eq1,eq2)
  380.   if eq1 then
  381.     r.select(tools)
  382.     i_c.equip()
  383.   end
  384.   local item = i_c.getStackInInternalSlot(tools)
  385.   if eq2 then
  386.     i_c.equip()
  387.   end
  388.   if item and item.charge ~= nil then
  389.     if item.charge/item.maxCharge <= toolstrength then
  390.       return true
  391.     end
  392.   end
  393.   return false
  394. end
  395.  
  396. --берем запасной инструмент
  397. local function tool(save)
  398.   local checktool = r.durability()
  399.   if checktool == nil or checktool <= toolstrength then
  400.     if save then
  401.       x,y,z,xd,zd = xPos,depth,zPos,xDir,zDir
  402.     end
  403.     if slotitem(tools,toollist) then
  404.       r.select(tools)
  405.       i_c.equip()
  406.       status("взял инструмент в инвентаре")
  407.       local item = i_c.getStackInInternalSlot(tools)
  408.       if item and item.charge == nil then
  409.         r.dropDown()
  410.       end
  411.       durability = 0
  412.     elseif charger and electric(true,true) then
  413.       local chargetool = function(msg)
  414.         local inv = i_c.getInventorySize(3)
  415.         if inv and inv <= 4 then
  416.           if not r.drop() then
  417.             charger = false
  418.             status("в зарядчике нет места")
  419.           else
  420.             status(msg)
  421.             while true do
  422.               local c1 = i_c.getStackInSlot(3,1)
  423.               os.sleep(2)
  424.               local c2 = i_c.getStackInSlot(3,1)
  425.               if c2.charge < c1.charge + 500 then
  426.                 break
  427.               end
  428.             end
  429.             if not r.suck() then
  430.               charger = false
  431.               status("не могу забрать инструмент")
  432.             elseif electric() then
  433.               charger = false
  434.               status("инструмент не заряжен")
  435.             end
  436.           end
  437.         else
  438.           charger = false
  439.           status("зарядчик не найден")
  440.         end
  441.         if charger == false then
  442.           tool()
  443.         end
  444.       end
  445.       status("возвращаюсь к зарядчику инструмента")
  446.       goTo( 0,0,0,-1,0 )
  447.       electric(true)
  448.       chargetool("заряжаю инструмент...")
  449.       if electric(true) then
  450.         chargetool("заряжаю запасной инструмент...")
  451.       end
  452.       charging()
  453.       durability = 0
  454.       goTo( x,y,z,xd,zd )
  455.     elseif cheststart then
  456.       local savetool = function()
  457.         local item = i_c.getStackInInternalSlot(tools)
  458.         if item and item.charge ~= nil then
  459.           local inv = i_c.getInventorySize(3)
  460.           if inv then
  461.             if not r.drop() then
  462.               returnHome("в сундуке нет места")
  463.               return
  464.             end
  465.           else
  466.             returnHome("нет сундука")
  467.             return
  468.           end
  469.         else
  470.           r.dropDown()
  471.         end
  472.       end
  473.       status("возвращаюсь к сундуку за инструментом")
  474.       goTo( 0,0,0,0,-1 )
  475.       r.select(tools)
  476.       savetool()
  477.       if servise(tools,toollist) then
  478.         i_c.equip()
  479.         savetool()
  480.         servise(tools,toollist)
  481.         status("взял инструмент из сундука")
  482.         charging()
  483.         durability = 0
  484.         goTo( x,y,z,xd,zd )
  485.       else
  486.         returnHome("в сундуке нет инструмента")
  487.       end
  488.     else
  489.       returnHome("нет инструмента")
  490.     end
  491.     r.select(1)
  492.   elseif r.detect() then
  493.     local d1 = string.format("%.3f",r.durability())
  494.     for i, side in ipairs({1,3,0}) do
  495.       com.robot.swing(side)
  496.       local d2 = string.format("%.3f",r.durability())
  497.       if d2 < d1 then
  498.         durability = math.floor(d2/(d1-d2))
  499.         break
  500.       end
  501.     end
  502.   end
  503. end
  504.  
  505. --движение в сторону side
  506. local function robotMove(side)
  507.   while true do
  508.     local ok,reason = com.robot.move(side)
  509.     if ok then
  510.       return true
  511.     elseif reason and reason == "already moving" then
  512.       os.sleep(0.1)
  513.     else
  514.       return false,reason
  515.     end
  516.   end
  517. end
  518.  
  519. --идём по Х в 0 координат
  520. local function x_forward()
  521.   for xx = 1,width-1 do
  522.     while true do
  523.       if robotMove(3) then
  524.         xPos = xPos - 1
  525.         break
  526.       else
  527.         r.swing()
  528.       end
  529.     end
  530.   end
  531. end
  532.  
  533. --движемся в верх
  534. local function tryUp()
  535.   local tru = 0
  536.   while true do
  537.     if robotMove(1) then
  538.       depth = depth - 1
  539.       break
  540.     else
  541.       r.swingUp()
  542.     end
  543.     tru = tru + 1
  544.     if tru >= 7 then
  545.       tru = 0
  546.       returnHome("не могу подняться",true)
  547.     end
  548.   end
  549. end
  550.  
  551. --обнаружение бедрока
  552. local function checkbedrock()
  553.   for i = 1,3 do
  554.     if r.detectDown() and not r.swingDown() then
  555.       if bedrock then
  556.         break
  557.       elseif i == 2 then
  558.         tool(true)
  559.       elseif i == 3 then
  560.         status("низ достигнут !")
  561.         bedrock = true
  562.         if y ~= nil then
  563.           status("глубина "..y)
  564.         end
  565.       end
  566.     else
  567.       break
  568.     end
  569.   end
  570. end
  571.  
  572. --копаем и движемся вперед
  573. local function digForward()
  574.   if durability <= 3 then
  575.     tool(true)
  576.   end
  577.   r.swingUp()
  578.   r.swing()
  579.   checkbedrock()
  580.   durability = durability - 3
  581.   if r.count(invsize-2) > 0 then
  582.     sortlut()
  583.   end
  584.   local tru,reason = 0
  585.   while true do
  586.     if r.detect() then
  587.       _,reason = r.swing()
  588.       durability = durability - 1
  589.     else
  590.       ok,reason = robotMove(3)
  591.       if ok then
  592.         xPos = xPos + xDir
  593.         zPos = zPos + zDir
  594.         break
  595.       end
  596.     end
  597.     tru = tru + 1
  598.     if tru == 3 then
  599.       tool(true)
  600.     elseif tru == 4 or tru == 5 then
  601.       if bedrock then
  602.         tryUp()
  603.       end
  604.     elseif tru >= 20 then
  605.       tru = 0
  606.       returnHome("непреодолимое препятствие",true,reason)
  607.     end
  608.   end
  609. end
  610.  
  611. --спускаемся в низ
  612. local function go_down()
  613.   for zz = 1,down do
  614.     while true do
  615.       checkbedrock()
  616.       if robotMove(0) then
  617.         depth = depth + 1
  618.         break
  619.       elseif bedrock then
  620.         while true do
  621.           r.swing()
  622.           if r.detect() then
  623.             tryUp()
  624.           else
  625.             return
  626.           end
  627.         end
  628.       end
  629.     end
  630.   end
  631. end
  632.  
  633. --поворот в лево
  634. local function turnLeft()
  635.   while not r.turnLeft() do
  636.     os.sleep(0.1)
  637.   end
  638.   xDir, zDir = -zDir, xDir
  639. end
  640.  
  641. --поворот в право
  642. local function turnRight()
  643.   while not r.turnRight() do
  644.     os.sleep(0.1)
  645.   end
  646.   xDir, zDir = zDir, -xDir
  647. end
  648.  
  649. --навигация к сундуку
  650. function goTo( x,y,z,xd,zd )
  651.   local Xposition = function()
  652.     if xPos > x then
  653.       while xDir ~= -1 do
  654.         turnLeft()
  655.       end
  656.       while xPos > x do
  657.         if robotMove(3) then
  658.           xPos = xPos - 1
  659.         else
  660.           r.swing()
  661.         end
  662.       end
  663.     elseif xPos < x then
  664.       while xDir ~= 1 do
  665.         turnRight()
  666.       end
  667.       while xPos < x do
  668.         if robotMove(3) then
  669.           xPos = xPos + 1
  670.         else
  671.           r.swing()
  672.         end
  673.       end
  674.     end
  675.   end
  676.   local Zposition = function()
  677.     if zPos > z then
  678.       while zDir ~= -1 do
  679.         turnLeft()
  680.       end
  681.       while zPos > z do
  682.         if robotMove(3) then
  683.           zPos = zPos - 1
  684.         else
  685.           r.swing()
  686.         end
  687.       end
  688.     elseif zPos < z then
  689.       while zDir ~= 1 do
  690.         turnRight()
  691.       end
  692.       while zPos < z do
  693.         if robotMove(3) then
  694.           zPos = zPos + 1
  695.         else
  696.           r.swing()
  697.         end
  698.       end
  699.     end
  700.   end
  701.   r.select(1)
  702.   while depth < y do
  703.     while xDir ~= 0 or zDir ~= 1 do
  704.       turnRight()
  705.     end
  706.     if robotMove(0) then
  707.       depth = depth + 1
  708.     else
  709.       r.swingDown()
  710.     end
  711.   end
  712.   if y > 0 then
  713.     Zposition()
  714.     Xposition()
  715.   else
  716.     Xposition()
  717.     Zposition()
  718.   end
  719.   while depth > y do
  720.     if robotMove(1) then
  721.       depth = depth - 1
  722.     else
  723.       r.swingUp()
  724.     end
  725.   end
  726.   while xDir ~= xd or zDir ~= zd do
  727.     turnRight()
  728.   end
  729. end
  730.  
  731. --копаем
  732. local function dig()
  733.   os.execute("cls")
  734.   print("размер карьера:  ширина "..width.."  длина "..length)
  735.   print("угля в генераторе = "..gen.count())
  736.   print("энергии = "..math.floor(100*computer.energy()/computer.maxEnergy()).." %")
  737.   print("подготовка...")
  738.   goTo( 0,0,0,0,-1 )
  739.   for slot = 1,invsize do
  740.     if r.count(slot) == 0 then
  741.       r.select(slot)
  742.       i_c.equip()
  743.       break
  744.     end
  745.     if slot == invsize then
  746.       stop("в инвентаре робота нет пустых слотов")
  747.     end
  748.   end
  749.   local inv = i_c.getInventorySize(3)
  750.   if inv then
  751.     cheststart = true
  752.     print("доступен сундук")
  753.     if servise(tools,toollist) then
  754.       r.select(tools)
  755.       i_c.equip()
  756.       servise(tools,toollist)
  757.     else
  758.       stop("нет инструмента")
  759.     end
  760.     if servise(coal,{"coal"}) then
  761.       r.select(coal)
  762.       if gen.insert() then
  763.         print("заправился, угля в генераторе = "..gen.count())
  764.         servise(coal,{"coal"})
  765.       end
  766.     else
  767.       fuelchest = false
  768.     end
  769.   else
  770.     cheststart = false
  771.     print("сундук сзади робота не найден")
  772.     if slotitem(tools,toollist) then
  773.       r.select(tools)
  774.       i_c.equip()
  775.       slotitem(tools,toollist)
  776.     else
  777.       stop("нет инструмента")
  778.     end
  779.     checkfuel()
  780.   end
  781.   goTo( 0,0,0,-1,0 )
  782.   local inv = i_c.getInventorySize(3)
  783.   if inv and inv <= 4 then
  784.     charger = true
  785.     print("доступен зарядчик")
  786.   end
  787.   goTo( 0,0,0,0,1 )
  788.   charging()
  789.   r.setLightColor(0xFFFFFF)
  790.   chunkload(true)
  791.   print("опускаюсь на "..down.." блока(ов)")
  792.   for height = 1,256 do
  793.     refuel = true
  794.     checkfuel()
  795.     go_down()
  796.     down = 3
  797.     for xx = 1,width do
  798.       for yy = 1,length-1 do
  799.         digForward()
  800.       end
  801.       checkfuel()
  802.       if xx ~= width then
  803.         if ridht then
  804.           turnRight()
  805.           digForward()
  806.           turnRight()
  807.           ridht = false
  808.         else
  809.           turnLeft()
  810.           digForward()
  811.           turnLeft()
  812.           ridht = true
  813.         end
  814.       end
  815.     end
  816.     r.swingUp()
  817.     r.swingDown()
  818.     if ridht then
  819.       turnLeft()
  820.       x_forward()
  821.       turnLeft()
  822.       ridht = false
  823.     else
  824.       turnRight()
  825.       x_forward()
  826.       turnRight()
  827.       ridht = true
  828.     end
  829.     if bedrock then
  830.       goTo( 0,0,0,0,-1 )
  831.       sortlut(true)
  832.       stop("завершил копать :)")
  833.     end
  834.   end
  835. end
  836.  
  837. dig()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement