Advertisement
Guest User

Untitled

a guest
Jul 16th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. --1:z+ 2:x- 3:z- 4:x+
  2.  
  3.  
  4. --Functii
  5. function mergi(fata)
  6. if fata==1 then
  7. turtle.forward()
  8. else
  9. turtle.down()
  10. end
  11. end
  12. function sapa(fata)
  13. if fata==1 then
  14. turtle.dig()
  15. else
  16. turtle.digDown()
  17. end
  18. end
  19. function mergi_coord(X_dorit, Y_dorit, Z_dorit, prioritate_Y)
  20. --Mergi pe X
  21. if my_X>X_dorit then
  22. turn(2)
  23. end
  24. end
  25. function turn(poz)
  26. print("Turn " .. poz)
  27. if poz==heading then
  28. return
  29. end
  30. if poz==heading-1 then
  31. turtle.turnLeft()
  32. end
  33. if poz==heading+1 then
  34. turtle.turnRight()
  35. else
  36. turtle.turnRight()
  37. turtle.turnRight()
  38. end
  39. heading = poz
  40. end
  41. function load_coord()
  42. --load home
  43. local home_file = fs.open("home.lua", "r")
  44. home_X=home_file.readLine()
  45. home_Y=home_file.readLine()
  46. home_Z=home_file.readLine()
  47. home_file.close()
  48. --load my_coord
  49. local my_file = fs.open("my.lua", "r")
  50. my_X=my_file.readLine()
  51. my_Y=my_file.readLine()
  52. my_Z=my_file.readLine()
  53. heading=my_file.readLine()
  54. my_file.close()
  55. end
  56. function save_coord()
  57. local my_file = fs.open("my.lua", "w")
  58. my_file.write(my_X)
  59. my_file.write("\n")
  60. my_file.write(my_Y)
  61. my_file.write("\n")
  62. my_file.write(my_Z)
  63. my_file.write("\n")
  64. my_file.write(heading)
  65. my_file.write("\n")
  66. my_file.close()
  67. end
  68.  
  69.  
  70. load_coord()
  71. turn(3)
  72. save_coord()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement