Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sd = "statusDoc"
- c = peripheral.wrap("left")
- down = 0
- up = 1
- north = 2
- south = 3
- west = 4
- east = 5
- function sWrite()
- local sss = textutils.serialize(ss)
- local file = fs.open(sd, "w")
- file.write(sss)
- file.close()
- end
- function sRead()
- local file = fs.open(sd, "r")
- ss = textutils.unserialize(file.readAll())
- return ss
- end
- function getLoc()
- x, y, z = gps.locate(2, true)
- return x, y, z
- end
- function yDis()
- getLoc()
- clear()
- yDis = y - tArgs[2]
- --ss = yDis
- --sWrite()
- end
- function xDis()
- getLoc()
- clear()
- xDis = x - tArgs[1]
- --ss = xDis
- --sWrite()
- end
- function zDis()
- getLoc()
- clear()
- zDis = z - tArgs[3]
- end
- function clear()
- term.clear()
- term.setCursorPos(1,1)
- end
- function moveY()
- sRead()
- Y = ss[2]
- if Y ~= 0 then
- if Y > 0 then
- ss[2] = Y - 1
- sWrite()
- sleep(1)
- c.move(down, false, false)
- elseif Y < 0 then
- ss[2] = Y + 1
- sWrite()
- sleep(1)
- c.move(up, false, false)
- end
- --else ss[2] = nil
- end
- end
- function moveX()
- sRead()
- X = ss[1]
- if X ~= 0 then
- if X > 0 then
- ss[1] = X - 1
- sWrite()
- sleep(1)
- c.move(west, false, false)
- elseif X < 0 then
- ss[1] = X + 1
- sWrite()
- sleep(1)
- c.move(east, false, false)
- end
- --else ss[1] = nil
- end
- end
- function moveZ()
- sRead()
- Z = ss[3]
- if Z ~= 0 then
- if Z > 0 then
- ss[3] = Z - 1
- sWrite()
- sleep(1)
- c.move(north, false, false)
- elseif Z < 0 then
- ss[3] = Z + 1
- sWrite()
- sleep(1)
- c.move(south, false, false)
- end
- --else ss[3] = nil
- end
- end
- function getDis()
- xDis()
- yDis()
- zDis()
- --zDis = zDis - 1
- ss = {xDis, yDis, zDis}
- sWrite()
- end
- clear()
- tArgs = {...}
- if #tArgs < 1 then
- sRead()
- if ss[2] ~= 0 then
- moveY()
- elseif ss[1] ~= 0 then
- moveX()
- elseif ss[3] ~= 0 then
- moveZ()
- end
- print("not vaild location")
- else tArgs = {...}
- print(tArgs[1])
- print(tArgs[2])
- print(tArgs[3])
- sleep(5)
- getDis()
- moveY()
- moveX()
- moveZ()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement