daily pastebin goal
28%
SHARE
TWEET

destroy

a guest Jun 14th, 2018 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local r = require("robot")
  2.  
  3. local f = r.forward
  4. local lt = r.turnLeft
  5. local rt = r.turnRight
  6. local ar = r.turnAround
  7. local use = r.use
  8. local sw = r.swing
  9. local swd = r.swingDown
  10. local dt = r.detect
  11. local dtD = r.detectDown
  12. local dn = r.down
  13. local up = r.up
  14.  
  15. function fD()
  16. local key = false
  17.  
  18.   if(f()) then
  19.     key = true
  20.   else
  21.     while(not(key)) do
  22.       key = f()
  23.     end
  24.   end
  25. end -- func
  26.  
  27. function dN()
  28. local key = false
  29.  
  30.   if(dn()) then
  31.     key = true
  32.   else
  33.     while(not(key)) do
  34.       key = dn()
  35.     end
  36.   end
  37. end -- func
  38.  
  39. function swD()
  40. local _,detect = dtD()
  41.   while(detect == "solid") do
  42.     _,detect = dtD()
  43.     swd()
  44.   end
  45. end -- func
  46.  
  47. function try()
  48. local _,detect = dt()
  49.   while(detect == "solid") do
  50.     _,detect = dt()
  51.     sw()
  52.   end
  53.   fD()
  54. end -- func
  55.  
  56. ----------------------------------------------
  57. print("Введите длину, ширину, глубину")
  58. print("копаемой зоны")
  59. long = io.read()
  60. width = io.read()
  61. high = io.read()
  62.  
  63. for i = 1,high do
  64.   if(i~=1) then
  65.     swD() ar() dN()
  66.   end
  67.   for j = 1,width do
  68.     if(j%2==1 and j~=1) then
  69.       if(width%2==1) then
  70.         rt() try() rt()
  71.       else
  72.         if(i%2==1) then
  73.           rt() try() rt()
  74.         else
  75.           lt() try() lt()
  76.         end
  77.       end
  78.     elseif(j%2==0) then
  79.       if(width%2==1) then
  80.         lt() try() lt()
  81.       else
  82.         if(i%2==1) then
  83.           lt() try() lt()
  84.         else
  85.           rt() try() rt()
  86.         end
  87.       end
  88.     end
  89.      
  90.     for k = 1,long-1 do
  91.       try()
  92.     end
  93.   end
  94. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top