Advertisement
davial

Roboshovel 0.02

Jul 1st, 2015
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.96 KB | None | 0 0
  1. -- davial Robot-shovel 0.02. (alpha) --
  2.  
  3. local r = require ("robot")
  4.  
  5.   print (" Input length ")
  6.   len = io.read()
  7.   print (" Input width ")
  8.   wid = io.read()
  9.   os.sleep(3)
  10.   print (" Input heigth ")
  11.   hei = io.read()
  12.  
  13. function Dig()                                     -- самокопание
  14.   while r.detect () == true do r.swing()
  15.     os.sleep(0.6)
  16.   end
  17.     r.forward()
  18.   while r.detectUp () == true do r.swingUp()
  19.     os.sleep(0.6)
  20.   end
  21.   while r.detectDown () == true do r.swingDown()
  22.   end
  23. end
  24.  
  25. function RightHand()                              -- правый ход
  26.   Dig()
  27.   r.turnRight()
  28.     for j = 2, wid-1 do
  29.       Dig()
  30.     end
  31.   Dig()
  32.   r.turnLeft()
  33. end
  34.  
  35. function LeftHand()                               -- левый ход
  36.   Dig()
  37.   r.turnLeft()
  38.     for j = 2, wid-1 do    
  39.       Dig()
  40.     end
  41.    Dig()
  42.    r.turnRight()
  43. end
  44.  
  45. for i = 1, len do
  46.   if i%2~=0 then RightHand()
  47.             else LeftHand()
  48.   end
  49. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement