Advertisement
Guest User

startup

a guest
Jan 19th, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.84 KB | None | 0 0
  1. function clearScrn()
  2.   term.clear()
  3.   term.setCursorPos(1,1)
  4. end
  5.  
  6. function quarry()
  7.   repeat
  8.     local uin = true
  9.     clearScrn()
  10.     print("Would you like to set [N]ew or [O]ld coords:")
  11.     local input = read()
  12.  
  13.     if input == "N" or input == "n" then
  14.       clearScrn()
  15.       print("Enter X coord:")
  16.       local xq = read()
  17.       rednet.send(48, xq)
  18.       print("Enter Z coord:")
  19.       local zq = read()
  20.       rednet.send(48, zq)
  21.       local file = fs.open("coords", "w")
  22.       file.writeLine(xq)
  23.       file.writeLine(zq)
  24.       file.close()
  25.       clearScrn()
  26.       print("Turtle is quarrying...")
  27.       repeat
  28.         local id, msg = rednet.receive()
  29.       until msg == "done"
  30.     elseif (input == "O" or input == "o") and (fs.exists("coords") == true) then
  31.       local file = fs.open("coords", "r")
  32.       local xf = file.readLine()
  33.       local zf = file.readLine()
  34.       file.close()
  35.       repeat
  36.         local uin1 = true
  37.         clearScrn()
  38.         print("Would you like to move the quarry [F]orward, [B]ack, [L]eft, or [R]ight:")
  39.         input = read()
  40.         if input == "F" or input == "f" then
  41.           zf = zf - 9
  42.         elseif input == "B" or input == "b" then  
  43.           zf = zf + 9
  44.         elseif input == "L" or input == "l" then
  45.           xf = xf - 9
  46.         elseif input == "R" or input == "r" then
  47.           xf = xf + 9
  48.         else
  49.           uin1 = false
  50.         end
  51.       until uin1 == true
  52.       rednet.send(48, xf)
  53.       rednet.send(48, zf)
  54.       file = fs.open("coords", "w")
  55.       file.writeLine(xq)
  56.       file.writeLine(zq)
  57.       file.close()
  58.       clearScrn()
  59.       print("Turtle is quarrying...")
  60.       repeat
  61.         local id, msg = rednet.receive()
  62.       until msg == "done"
  63.     else
  64.       uin = false
  65.     end
  66.   until uin == true
  67. end
  68.  
  69. rednet.open("top")
  70. while true do
  71.   quarry()
  72. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement