Advertisement
zapakitu

Untitled

Jul 16th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 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. else
  30. print(poz.." nu e "..heading)
  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. print(heading)
  58. end
  59. function save_coord()
  60. local my_file = fs.open("my.lua", "w")
  61. my_file.write(my_X)
  62. my_file.write("\n")
  63. my_file.write(my_Y)
  64. my_file.write("\n")
  65. my_file.write(my_Z)
  66. my_file.write("\n")
  67. my_file.write(tostring(heading))
  68. my_file.write("\n")
  69. my_file.close()
  70. end
  71.  
  72.  
  73. load_coord()
  74. turn(3)
  75. save_coord()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement