Advertisement
Ranger1230

opencomputer mining

Sep 2nd, 2015
592
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.86 KB | None | 0 0
  1. local robot = require 'robot'
  2. local diameter, depth, x, z, y
  3.  
  4. function getNumberInput(message)
  5.   local validInput = false
  6.   local userInput
  7.   while not validInput do
  8.     io.write(message)
  9.     io.flush()
  10.     userInput = io.read()
  11.    
  12.     validInput = tonumber(userInput) ~= nil
  13.     if not validInput then
  14.       io.write("Please enter a numeric value")
  15.       io.flush()
  16.     end
  17.   end
  18.   return tonumber(userInput)
  19. end
  20.  
  21. function digForward(blocksToDig)
  22.   local cannotMove
  23.   for i = 0, blocksToDig, 1 do
  24.     cannotMove = robot.detect()
  25.     if cannotMove then
  26.       robot.swing()
  27.     end
  28.     robot.forward()
  29.   end
  30. end
  31.  
  32. diameter = getNumberInput("What size hole should I dig?")
  33. depth = getNumberInput("How deep should I dig? (-1 means I'll go till bedrock WARNING DO NOT DO THIS IF THERE IS NO BEDROCK ONLY VOID!!!)")
  34.  
  35. print(diameter)
  36. print(depth)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement