Advertisement
Guest User

a

a guest
Apr 24th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.63 KB | None | 0 0
  1. local rb = require("robot")
  2.  
  3. local function mine(times)
  4.   a, b = rb.detect()
  5.   rb.select(1)
  6.   for i=1, times do
  7.     if a == true then
  8.       rb.swing()
  9.       print("front of robot: " .. b)
  10.     end
  11.     rb.forward()
  12.     print("Was done attempt:", i)
  13.   end
  14.   os.execute("clear")
  15. end
  16.  
  17. local function howmanydidimined()
  18.   rb.select(2)
  19.   col = rb.count()
  20.   print("I mined",col)
  21. end
  22.  
  23. local function goback(times)
  24.   rb.turnAround()
  25.   for i=1, times do
  26.     rb.forward()
  27.   end
  28.   rb.dropUp()
  29.   rb.turnAround()  
  30. end
  31.  
  32. os.execute("clear")
  33. print("Enter mining times")
  34. local input = io.read()
  35.  
  36. mine(input)
  37. howmanydidimined()
  38. goback(input)
  39. print("I stopped my work")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement