Advertisement
Guest User

Untitled

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