Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --1:z+ 2:x- 3:z- 4:x+
- --Functii
- function mergi(fata)
- if fata==1 then
- turtle.forward()
- else
- turtle.down()
- end
- end
- function sapa(fata)
- if fata==1 then
- turtle.dig()
- else
- turtle.digDown()
- end
- end
- function mergi_coord(X_dorit, Y_dorit, Z_dorit, prioritate_Y)
- --Mergi pe X
- if my_X>X_dorit then
- turn(2)
- end
- end
- function turn(poz)
- print("Turn " .. poz)
- if poz==heading then
- return
- else
- print(poz.." nu e "..heading)
- end
- if poz==heading-1 then
- turtle.turnLeft()
- end
- if poz==heading+1 then
- turtle.turnRight()
- else
- turtle.turnRight()
- turtle.turnRight()
- end
- heading = poz
- end
- function load_coord()
- --load home
- local home_file = fs.open("home.lua", "r")
- home_X=home_file.readLine()
- home_Y=home_file.readLine()
- home_Z=home_file.readLine()
- home_file.close()
- --load my_coord
- local my_file = fs.open("my.lua", "r")
- my_X=my_file.readLine()
- my_Y=my_file.readLine()
- my_Z=my_file.readLine()
- heading=my_file.readLine()
- my_file.close()
- print(heading)
- end
- function save_coord()
- local my_file = fs.open("my.lua", "w")
- my_file.write(my_X)
- my_file.write("\n")
- my_file.write(my_Y)
- my_file.write("\n")
- my_file.write(my_Z)
- my_file.write("\n")
- my_file.write(tostring(heading))
- my_file.write("\n")
- my_file.close()
- end
- load_coord()
- turn(3)
- save_coord()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement