Advertisement
Guest User

Untitled

a guest
Jul 16th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 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. if poz==heading then
  27. return
  28. end
  29. if poz==heading-1 then
  30. turtle.turnLeft()
  31. end
  32. if poz==heading+1 then
  33. turtle.turnRight()
  34. else
  35. turtle.turnRight()
  36. turtle.turnRight()
  37. end
  38. end
  39. function load_coord()
  40. --load home
  41. local home_file = fs.open("home.lua", "r")
  42. home_X=home_file.readLine()
  43. home_Y=home_file.readLine()
  44. home_Z=home_file.readLine()
  45. home_file.close()
  46. --load my_coord
  47. local my_file = fs.open("my.lua", "r")
  48. my_X=my_file.readLine()
  49. my_Y=my_file.readLine()
  50. my_Z=my_file.readLine()
  51. heading=my_file.readLine()
  52. my_file.close()
  53. end
  54. function save_coord()
  55. local my_file = fs.open("my.lua", "w")
  56. my_file.write(my_X)
  57. my_file.write("\n")
  58. my_file.write(my_Y)
  59. my_file.write("\n")
  60. my_file.write(my_Z)
  61. my_file.write("\n")
  62. my_file.write(heading)
  63. my_file.write("\n")
  64. my_file.close()
  65. end
  66.  
  67.  
  68. load_coord()
  69. turn(3)
  70. save_coord()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement