Maxwelljonez

MJZ MC LUA Turtle Replace Floor

Oct 19th, 2021
1,020
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- MJZ LUA Simple Turtle Floor Replacement for Minecraft Computercraft
  2. -- Arguements and Arg Checking
  3. local time = os.time()
  4. local formattedTime = textutils.formatTime(time, true)
  5. local width
  6. local length
  7. term.clear()
  8. term.setCursorPos(1,1)
  9. sleep(0.1)
  10. print("-------------------")
  11. print("Let's replace dat floor.")
  12. print("What's the length?")
  13. length = read()
  14. print("-------------------")
  15. print("What's the width? (going to the right side)")
  16. width = read()
  17. term.clear()
  18. term.setCursorPos(1,1)
  19. write("Replacing Floor ")
  20. write(length)
  21. write("x")
  22. write (width)
  23. print(".")
  24. textutils.slowWrite("Turtle started at " .. formattedTime, 100)
  25. print("-------------------")
  26.  
  27. function startpos()
  28. print("No StartPos Saved")
  29. end
  30.  
  31. function forward()
  32. turtle.forward()
  33. end
  34.  
  35. function right()
  36. turtle.turnRight()
  37. end
  38.  
  39. function left()
  40. turtle.turnLeft()
  41. end
  42.  
  43. function replaceFloor()
  44. while not turtle.compareDown() do
  45. turtle.digDown()
  46. turtle.placeDown()
  47. write(".")
  48. end
  49. end
  50.  
  51. function goRow()
  52.  for l = 1, length-1 do
  53.    forward()
  54.    replaceFloor()
  55.    l = l + 1
  56.  end
  57. end
  58.  
  59. function backPos()
  60. turtle.turnRight()
  61. turtle.forward()
  62. end
  63.  
  64. -- starting code
  65. startpos()
  66. replaceFloor()
  67. goRow()
  68. for w = 1, width-1 do
  69.  if width-1 == 0 then
  70.   print("Stopped width")
  71.  elseif (w % 2 == 0) then
  72.   left()
  73.   forward()
  74.   replaceFloor()
  75.   left()
  76.   goRow()
  77.  else
  78.   right()
  79.   forward()
  80.   replaceFloor()
  81.   right()
  82.   goRow()
  83.  end
  84. w = w + 1
  85. end
  86. textutils.slowWrite("Job finished\n", 20)
RAW Paste Data